Solution to a*x**3 + 3*b*x - 2c = 0
, where
a
and b**3 + a*c**2
are both non-negative
(zero generated, in lieu of infinity, if a = b = 0
)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | a | |||
real(kind=wp), | intent(in) | :: | b | |||
real(kind=wp), | intent(in) | :: | c |
pure function dcbsol (a, b, c) result(x) implicit none real(wp) :: x real(wp),intent(in) :: a real(wp),intent(in) :: b real(wp),intent(in) :: c real(wp) :: bsq,d if (a==zero .and. b==zero .or. c==zero) then x = zero else bsq = b*b d = sqrt(a) * abs(c) d = dcubrt(d + sqrt(b*bsq + d*d))**2 x = two * c / (d + b + bsq / d) end if end function dcbsol