(FPCore (a b c)
:precision binary64
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
↓
(FPCore (a b c)
:precision binary64
(if (<= b -2.5e-74)
(/ (- c) b)
(if (<= b 1.35e+57)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
↓
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e-74) {
tmp = -c / b;
} else if (b <= 1.35e+57) {
tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
↓
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.5d-74)) then
tmp = -c / b
else if (b <= 1.35d+57) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (c * a))))) / (a * 2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
return (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
↓
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e-74) {
tmp = -c / b;
} else if (b <= 1.35e+57) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c):
return (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
↓
def code(a, b, c):
tmp = 0
if b <= -2.5e-74:
tmp = -c / b
elif b <= 1.35e+57:
tmp = (-b - math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0)
else:
tmp = (c / b) - (b / a)
return tmp
function code(a, b, c)
return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a))
end
↓
function code(a, b, c)
tmp = 0.0
if (b <= -2.5e-74)
tmp = Float64(Float64(-c) / b);
elseif (b <= 1.35e+57)
tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / Float64(a * 2.0));
else
tmp = Float64(Float64(c / b) - Float64(b / a));
end
return tmp
end
function tmp = code(a, b, c)
tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
end
↓
function tmp_2 = code(a, b, c)
tmp = 0.0;
if (b <= -2.5e-74)
tmp = -c / b;
elseif (b <= 1.35e+57)
tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
else
tmp = (c / b) - (b / a);
end
tmp_2 = tmp;
end
herbie shell --seed 2022217
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))