
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (/ c b) -0.5))
(t_1 (/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))))
(if (<= b -1.5e+87)
(/ b (* a -1.5))
(if (<= b 4e-127)
t_1
(if (<= b 1e-58)
t_0
(if (<= b 1.65e-13)
t_1
(if (<= b 1.55e+35)
(*
c
(+
(*
c
(+
(* -0.5625 (/ (* c (pow a 2.0)) (pow b 5.0)))
(* -0.375 (/ a (pow b 3.0)))))
(* 0.5 (/ -1.0 b))))
t_0)))))))
double code(double a, double b, double c) {
double t_0 = (c / b) * -0.5;
double t_1 = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
double tmp;
if (b <= -1.5e+87) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = t_1;
} else if (b <= 1e-58) {
tmp = t_0;
} else if (b <= 1.65e-13) {
tmp = t_1;
} else if (b <= 1.55e+35) {
tmp = c * ((c * ((-0.5625 * ((c * pow(a, 2.0)) / pow(b, 5.0))) + (-0.375 * (a / pow(b, 3.0))))) + (0.5 * (-1.0 / b)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (c / b) * (-0.5d0)
t_1 = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
if (b <= (-1.5d+87)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4d-127) then
tmp = t_1
else if (b <= 1d-58) then
tmp = t_0
else if (b <= 1.65d-13) then
tmp = t_1
else if (b <= 1.55d+35) then
tmp = c * ((c * (((-0.5625d0) * ((c * (a ** 2.0d0)) / (b ** 5.0d0))) + ((-0.375d0) * (a / (b ** 3.0d0))))) + (0.5d0 * ((-1.0d0) / b)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (c / b) * -0.5;
double t_1 = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
double tmp;
if (b <= -1.5e+87) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = t_1;
} else if (b <= 1e-58) {
tmp = t_0;
} else if (b <= 1.65e-13) {
tmp = t_1;
} else if (b <= 1.55e+35) {
tmp = c * ((c * ((-0.5625 * ((c * Math.pow(a, 2.0)) / Math.pow(b, 5.0))) + (-0.375 * (a / Math.pow(b, 3.0))))) + (0.5 * (-1.0 / b)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = (c / b) * -0.5 t_1 = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) tmp = 0 if b <= -1.5e+87: tmp = b / (a * -1.5) elif b <= 4e-127: tmp = t_1 elif b <= 1e-58: tmp = t_0 elif b <= 1.65e-13: tmp = t_1 elif b <= 1.55e+35: tmp = c * ((c * ((-0.5625 * ((c * math.pow(a, 2.0)) / math.pow(b, 5.0))) + (-0.375 * (a / math.pow(b, 3.0))))) + (0.5 * (-1.0 / b))) else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(Float64(c / b) * -0.5) t_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)) tmp = 0.0 if (b <= -1.5e+87) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4e-127) tmp = t_1; elseif (b <= 1e-58) tmp = t_0; elseif (b <= 1.65e-13) tmp = t_1; elseif (b <= 1.55e+35) tmp = Float64(c * Float64(Float64(c * Float64(Float64(-0.5625 * Float64(Float64(c * (a ^ 2.0)) / (b ^ 5.0))) + Float64(-0.375 * Float64(a / (b ^ 3.0))))) + Float64(0.5 * Float64(-1.0 / b)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c) t_0 = (c / b) * -0.5; t_1 = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); tmp = 0.0; if (b <= -1.5e+87) tmp = b / (a * -1.5); elseif (b <= 4e-127) tmp = t_1; elseif (b <= 1e-58) tmp = t_0; elseif (b <= 1.65e-13) tmp = t_1; elseif (b <= 1.55e+35) tmp = c * ((c * ((-0.5625 * ((c * (a ^ 2.0)) / (b ^ 5.0))) + (-0.375 * (a / (b ^ 3.0))))) + (0.5 * (-1.0 / b))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.5e+87], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-127], t$95$1, If[LessEqual[b, 1e-58], t$95$0, If[LessEqual[b, 1.65e-13], t$95$1, If[LessEqual[b, 1.55e+35], N[(c * N[(N[(c * N[(N[(-0.5625 * N[(N[(c * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(a / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{b} \cdot -0.5\\
t_1 := \frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{if}\;b \leq -1.5 \cdot 10^{+87}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-127}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 10^{-58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{+35}:\\
\;\;\;\;c \cdot \left(c \cdot \left(-0.5625 \cdot \frac{c \cdot {a}^{2}}{{b}^{5}} + -0.375 \cdot \frac{a}{{b}^{3}}\right) + 0.5 \cdot \frac{-1}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.4999999999999999e87Initial program 49.0%
Applied egg-rr48.9%
sub-neg48.9%
distribute-rgt-out--48.9%
Simplified48.9%
Taylor expanded in b around -inf 91.0%
*-commutative91.0%
associate-*l/91.1%
associate-/l*91.0%
Simplified91.0%
clear-num91.0%
un-div-inv91.2%
div-inv91.4%
metadata-eval91.4%
Applied egg-rr91.4%
if -1.4999999999999999e87 < b < 4.0000000000000001e-127 or 1e-58 < b < 1.65e-13Initial program 83.6%
if 4.0000000000000001e-127 < b < 1e-58 or 1.54999999999999993e35 < b Initial program 17.5%
Taylor expanded in b around inf 83.5%
*-commutative83.5%
Simplified83.5%
if 1.65e-13 < b < 1.54999999999999993e35Initial program 19.9%
Taylor expanded in c around 0 92.6%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e+87)
(/ b (* a -1.5))
(if (<= b 4e-127)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+87) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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 <= (-1.5d+87)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4d-127) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+87) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e+87: tmp = b / (a * -1.5) elif b <= 4e-127: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e+87) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4e-127) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e+87) tmp = b / (a * -1.5); elseif (b <= 4e-127) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e+87], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-127], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{+87}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-127}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.4999999999999999e87Initial program 49.0%
Applied egg-rr48.9%
sub-neg48.9%
distribute-rgt-out--48.9%
Simplified48.9%
Taylor expanded in b around -inf 91.0%
*-commutative91.0%
associate-*l/91.1%
associate-/l*91.0%
Simplified91.0%
clear-num91.0%
un-div-inv91.2%
div-inv91.4%
metadata-eval91.4%
Applied egg-rr91.4%
if -1.4999999999999999e87 < b < 4.0000000000000001e-127Initial program 84.3%
if 4.0000000000000001e-127 < b Initial program 22.4%
Taylor expanded in b around inf 80.1%
*-commutative80.1%
Simplified80.1%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -3.3e-5)
(/ b (* a -1.5))
(if (<= b 4e-127)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e-5) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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 <= (-3.3d-5)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4d-127) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e-5) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.3e-5: tmp = b / (a * -1.5) elif b <= 4e-127: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.3e-5) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4e-127) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.3e-5) tmp = b / (a * -1.5); elseif (b <= 4e-127) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.3e-5], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-127], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.3 \cdot 10^{-5}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-127}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.3000000000000003e-5Initial program 57.4%
Applied egg-rr57.3%
sub-neg57.3%
distribute-rgt-out--57.3%
Simplified57.3%
Taylor expanded in b around -inf 87.4%
*-commutative87.4%
associate-*l/87.4%
associate-/l*87.3%
Simplified87.3%
clear-num87.2%
un-div-inv87.5%
div-inv87.6%
metadata-eval87.6%
Applied egg-rr87.6%
if -3.3000000000000003e-5 < b < 4.0000000000000001e-127Initial program 83.2%
prod-diff83.0%
*-commutative83.0%
fma-define83.0%
associate-+l+83.0%
pow283.0%
distribute-lft-neg-in83.0%
*-commutative83.0%
distribute-rgt-neg-in83.0%
metadata-eval83.0%
associate-*r*82.9%
*-commutative82.9%
*-commutative82.9%
fma-undefine82.9%
Applied egg-rr82.8%
Taylor expanded in b around 0 75.7%
distribute-rgt-out75.9%
metadata-eval75.9%
mul-1-neg75.9%
unsub-neg75.9%
associate-*r*75.9%
Simplified75.9%
associate-*r*75.9%
*-commutative75.9%
Applied egg-rr75.9%
if 4.0000000000000001e-127 < b Initial program 22.4%
Taylor expanded in b around inf 80.1%
*-commutative80.1%
Simplified80.1%
(FPCore (a b c)
:precision binary64
(if (<= b -0.0085)
(/ b (* a -1.5))
(if (<= b 4e-127)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.0085) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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 <= (-0.0085d0)) then
tmp = b / (a * (-1.5d0))
else if (b <= 4d-127) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.0085) {
tmp = b / (a * -1.5);
} else if (b <= 4e-127) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.0085: tmp = b / (a * -1.5) elif b <= 4e-127: tmp = (math.sqrt((a * (c * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.0085) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 4e-127) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.0085) tmp = b / (a * -1.5); elseif (b <= 4e-127) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.0085], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-127], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0085:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-127}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -0.0085000000000000006Initial program 57.4%
Applied egg-rr57.3%
sub-neg57.3%
distribute-rgt-out--57.3%
Simplified57.3%
Taylor expanded in b around -inf 87.4%
*-commutative87.4%
associate-*l/87.4%
associate-/l*87.3%
Simplified87.3%
clear-num87.2%
un-div-inv87.5%
div-inv87.6%
metadata-eval87.6%
Applied egg-rr87.6%
if -0.0085000000000000006 < b < 4.0000000000000001e-127Initial program 83.2%
prod-diff83.0%
*-commutative83.0%
fma-define83.0%
associate-+l+83.0%
pow283.0%
distribute-lft-neg-in83.0%
*-commutative83.0%
distribute-rgt-neg-in83.0%
metadata-eval83.0%
associate-*r*82.9%
*-commutative82.9%
*-commutative82.9%
fma-undefine82.9%
Applied egg-rr82.8%
Taylor expanded in b around 0 75.7%
distribute-rgt-out75.9%
metadata-eval75.9%
mul-1-neg75.9%
unsub-neg75.9%
associate-*r*75.9%
Simplified75.9%
if 4.0000000000000001e-127 < b Initial program 22.4%
Taylor expanded in b around inf 80.1%
*-commutative80.1%
Simplified80.1%
Final simplification81.5%
(FPCore (a b c)
:precision binary64
(if (<= b -0.000118)
(/ b (* a -1.5))
(if (<= b 3.5e-127)
(* (- (sqrt (* (* a c) -3.0)) b) (/ 0.3333333333333333 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.000118) {
tmp = b / (a * -1.5);
} else if (b <= 3.5e-127) {
tmp = (sqrt(((a * c) * -3.0)) - b) * (0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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 <= (-0.000118d0)) then
tmp = b / (a * (-1.5d0))
else if (b <= 3.5d-127) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) * (0.3333333333333333d0 / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.000118) {
tmp = b / (a * -1.5);
} else if (b <= 3.5e-127) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) * (0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.000118: tmp = b / (a * -1.5) elif b <= 3.5e-127: tmp = (math.sqrt(((a * c) * -3.0)) - b) * (0.3333333333333333 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.000118) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 3.5e-127) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.000118) tmp = b / (a * -1.5); elseif (b <= 3.5e-127) tmp = (sqrt(((a * c) * -3.0)) - b) * (0.3333333333333333 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.000118], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-127], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.000118:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-127}:\\
\;\;\;\;\left(\sqrt{\left(a \cdot c\right) \cdot -3} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.18e-4Initial program 57.4%
Applied egg-rr57.3%
sub-neg57.3%
distribute-rgt-out--57.3%
Simplified57.3%
Taylor expanded in b around -inf 87.4%
*-commutative87.4%
associate-*l/87.4%
associate-/l*87.3%
Simplified87.3%
clear-num87.2%
un-div-inv87.5%
div-inv87.6%
metadata-eval87.6%
Applied egg-rr87.6%
if -1.18e-4 < b < 3.49999999999999989e-127Initial program 83.2%
prod-diff83.0%
*-commutative83.0%
fma-define83.0%
associate-+l+83.0%
pow283.0%
distribute-lft-neg-in83.0%
*-commutative83.0%
distribute-rgt-neg-in83.0%
metadata-eval83.0%
associate-*r*82.9%
*-commutative82.9%
*-commutative82.9%
fma-undefine82.9%
Applied egg-rr82.8%
Taylor expanded in b around 0 75.7%
distribute-rgt-out75.9%
metadata-eval75.9%
mul-1-neg75.9%
unsub-neg75.9%
associate-*r*75.9%
Simplified75.9%
div-inv75.9%
associate-*r*75.8%
*-commutative75.8%
metadata-eval75.8%
div-inv75.8%
clear-num75.8%
Applied egg-rr75.8%
if 3.49999999999999989e-127 < b Initial program 22.4%
Taylor expanded in b around inf 80.1%
*-commutative80.1%
Simplified80.1%
(FPCore (a b c)
:precision binary64
(if (<= b -0.0025)
(/ b (* a -1.5))
(if (<= b 2.4e-127)
(* 0.3333333333333333 (/ (sqrt (* a (* c -3.0))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.0025) {
tmp = b / (a * -1.5);
} else if (b <= 2.4e-127) {
tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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 <= (-0.0025d0)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.4d-127) then
tmp = 0.3333333333333333d0 * (sqrt((a * (c * (-3.0d0)))) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -0.0025) {
tmp = b / (a * -1.5);
} else if (b <= 2.4e-127) {
tmp = 0.3333333333333333 * (Math.sqrt((a * (c * -3.0))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -0.0025: tmp = b / (a * -1.5) elif b <= 2.4e-127: tmp = 0.3333333333333333 * (math.sqrt((a * (c * -3.0))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -0.0025) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.4e-127) tmp = Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(c * -3.0))) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -0.0025) tmp = b / (a * -1.5); elseif (b <= 2.4e-127) tmp = 0.3333333333333333 * (sqrt((a * (c * -3.0))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -0.0025], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-127], N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0025:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-127}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -0.00250000000000000005Initial program 57.4%
Applied egg-rr57.3%
sub-neg57.3%
distribute-rgt-out--57.3%
Simplified57.3%
Taylor expanded in b around -inf 87.4%
*-commutative87.4%
associate-*l/87.4%
associate-/l*87.3%
Simplified87.3%
clear-num87.2%
un-div-inv87.5%
div-inv87.6%
metadata-eval87.6%
Applied egg-rr87.6%
if -0.00250000000000000005 < b < 2.39999999999999982e-127Initial program 83.2%
prod-diff83.0%
*-commutative83.0%
fma-define83.0%
associate-+l+83.0%
pow283.0%
distribute-lft-neg-in83.0%
*-commutative83.0%
distribute-rgt-neg-in83.0%
metadata-eval83.0%
associate-*r*82.9%
*-commutative82.9%
*-commutative82.9%
fma-undefine82.9%
Applied egg-rr82.8%
Taylor expanded in b around 0 73.3%
associate-*l/73.4%
Simplified73.6%
if 2.39999999999999982e-127 < b Initial program 22.4%
Taylor expanded in b around inf 80.1%
*-commutative80.1%
Simplified80.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-147)
(/ b (* a -1.5))
(if (<= b 1.45e-146)
(sqrt (* (* c (/ -3.0 a)) 0.1111111111111111))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-147) {
tmp = b / (a * -1.5);
} else if (b <= 1.45e-146) {
tmp = sqrt(((c * (-3.0 / a)) * 0.1111111111111111));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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 <= (-1.5d-147)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.45d-146) then
tmp = sqrt(((c * ((-3.0d0) / a)) * 0.1111111111111111d0))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-147) {
tmp = b / (a * -1.5);
} else if (b <= 1.45e-146) {
tmp = Math.sqrt(((c * (-3.0 / a)) * 0.1111111111111111));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e-147: tmp = b / (a * -1.5) elif b <= 1.45e-146: tmp = math.sqrt(((c * (-3.0 / a)) * 0.1111111111111111)) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-147) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.45e-146) tmp = sqrt(Float64(Float64(c * Float64(-3.0 / a)) * 0.1111111111111111)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e-147) tmp = b / (a * -1.5); elseif (b <= 1.45e-146) tmp = sqrt(((c * (-3.0 / a)) * 0.1111111111111111)); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-147], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-146], N[Sqrt[N[(N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision] * 0.1111111111111111), $MachinePrecision]], $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-147}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-146}:\\
\;\;\;\;\sqrt{\left(c \cdot \frac{-3}{a}\right) \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.5000000000000001e-147Initial program 62.5%
Applied egg-rr62.5%
sub-neg62.5%
distribute-rgt-out--62.5%
Simplified62.5%
Taylor expanded in b around -inf 78.6%
*-commutative78.6%
associate-*l/78.7%
associate-/l*78.5%
Simplified78.5%
clear-num78.5%
un-div-inv78.7%
div-inv78.8%
metadata-eval78.8%
Applied egg-rr78.8%
if -1.5000000000000001e-147 < b < 1.45000000000000005e-146Initial program 82.1%
prod-diff81.9%
*-commutative81.9%
fma-define81.9%
associate-+l+81.9%
pow281.9%
distribute-lft-neg-in81.9%
*-commutative81.9%
distribute-rgt-neg-in81.9%
metadata-eval81.9%
associate-*r*81.8%
*-commutative81.8%
*-commutative81.8%
fma-undefine81.8%
Applied egg-rr81.6%
Taylor expanded in a around inf 42.7%
distribute-rgt-out42.7%
metadata-eval42.7%
Simplified42.7%
add-sqr-sqrt42.6%
sqrt-unprod42.7%
*-commutative42.7%
*-commutative42.7%
swap-sqr42.7%
add-sqr-sqrt42.9%
associate-/l*42.9%
metadata-eval42.9%
Applied egg-rr42.9%
if 1.45000000000000005e-146 < b Initial program 24.4%
Taylor expanded in b around inf 78.2%
*-commutative78.2%
Simplified78.2%
(FPCore (a b c) :precision binary64 (if (<= b 2.1e-295) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-295) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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.1d-295) then
tmp = b / (a * (-1.5d0))
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-295) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.1e-295: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.1e-295) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.1e-295) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.1e-295], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-295}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.09999999999999993e-295Initial program 66.9%
Applied egg-rr66.8%
sub-neg66.8%
distribute-rgt-out--66.8%
Simplified66.8%
Taylor expanded in b around -inf 66.3%
*-commutative66.3%
associate-*l/66.4%
associate-/l*66.3%
Simplified66.3%
clear-num66.2%
un-div-inv66.4%
div-inv66.5%
metadata-eval66.5%
Applied egg-rr66.5%
if 2.09999999999999993e-295 < b Initial program 34.9%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.1e-295) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-295) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
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.1d-295) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.1e-295) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.1e-295: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.1e-295) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.1e-295) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.1e-295], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-295}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.09999999999999993e-295Initial program 66.9%
Taylor expanded in b around -inf 66.3%
*-commutative66.3%
Simplified66.3%
if 2.09999999999999993e-295 < b Initial program 34.9%
Taylor expanded in b around inf 65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (a b c) :precision binary64 (* (/ b a) -0.6666666666666666))
double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (b / a) * (-0.6666666666666666d0)
end function
public static double code(double a, double b, double c) {
return (b / a) * -0.6666666666666666;
}
def code(a, b, c): return (b / a) * -0.6666666666666666
function code(a, b, c) return Float64(Float64(b / a) * -0.6666666666666666) end
function tmp = code(a, b, c) tmp = (b / a) * -0.6666666666666666; end
code[a_, b_, c_] := N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a} \cdot -0.6666666666666666
\end{array}
Initial program 50.4%
Taylor expanded in b around -inf 33.4%
*-commutative33.4%
Simplified33.4%
(FPCore (a b c) :precision binary64 (* b (/ -0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b * ((-0.6666666666666666d0) / a)
end function
public static double code(double a, double b, double c) {
return b * (-0.6666666666666666 / a);
}
def code(a, b, c): return b * (-0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(-0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (-0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{-0.6666666666666666}{a}
\end{array}
Initial program 50.4%
Applied egg-rr49.8%
sub-neg49.8%
distribute-rgt-out--50.3%
Simplified50.3%
Taylor expanded in b around -inf 33.4%
*-commutative33.4%
associate-*l/33.5%
associate-/l*33.4%
Simplified33.4%
herbie shell --seed 2024095
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))