
(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 10 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
(if (<= b -5e+155)
(* b (/ -0.6666666666666666 a))
(if (<= b 3.8e-33)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+155) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 3.8e-33) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
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 <= (-5d+155)) then
tmp = b * ((-0.6666666666666666d0) / a)
else if (b <= 3.8d-33) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+155) {
tmp = b * (-0.6666666666666666 / a);
} else if (b <= 3.8e-33) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+155: tmp = b * (-0.6666666666666666 / a) elif b <= 3.8e-33: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+155) tmp = Float64(b * Float64(-0.6666666666666666 / a)); elseif (b <= 3.8e-33) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+155) tmp = b * (-0.6666666666666666 / a); elseif (b <= 3.8e-33) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+155], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e-33], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+155}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-33}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.9999999999999999e155Initial program 37.9%
sqr-neg37.9%
sqr-neg37.9%
associate-*l*37.9%
Simplified37.9%
Applied egg-rr1.2%
*-commutative1.2%
associate-*l/1.2%
associate-*r/1.2%
associate-*r*1.2%
*-commutative1.2%
associate-*r*1.2%
*-commutative1.2%
Simplified1.2%
Taylor expanded in b around inf 0.7%
*-commutative0.7%
Simplified0.7%
add-sqr-sqrt0.3%
sqrt-unprod43.1%
swap-sqr43.2%
metadata-eval43.2%
metadata-eval43.2%
swap-sqr43.1%
sqrt-unprod55.4%
add-sqr-sqrt97.4%
*-commutative97.4%
clear-num97.4%
un-div-inv97.5%
Applied egg-rr97.5%
associate-/r/97.6%
Simplified97.6%
if -4.9999999999999999e155 < b < 3.79999999999999994e-33Initial program 79.2%
sqr-neg79.2%
sqr-neg79.2%
associate-*l*79.2%
Simplified79.2%
if 3.79999999999999994e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt81.6%
metadata-eval81.6%
distribute-rgt-neg-in81.6%
distribute-frac-neg81.6%
distribute-frac-neg281.6%
times-frac81.8%
neg-mul-181.8%
remove-double-neg81.8%
*-commutative81.8%
associate-*l*82.1%
metadata-eval82.1%
Simplified82.1%
Final simplification83.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e-54)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 3.4e-33)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-54) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 3.4e-33) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
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.3d-54)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 3.4d-33) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-54) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 3.4e-33) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.3e-54: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 3.4e-33: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.3e-54) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 3.4e-33) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.3e-54) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 3.4e-33) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.3e-54], N[(b * N[(N[(0.6666666666666666 * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-33], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{-54}:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-33}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.2999999999999999e-54Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in b around -inf 89.5%
if -2.2999999999999999e-54 < b < 3.4000000000000001e-33Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.1%
Simplified67.1%
Taylor expanded in b around 0 61.3%
if 3.4000000000000001e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt81.6%
metadata-eval81.6%
distribute-rgt-neg-in81.6%
distribute-frac-neg81.6%
distribute-frac-neg281.6%
times-frac81.8%
neg-mul-181.8%
remove-double-neg81.8%
*-commutative81.8%
associate-*l*82.1%
metadata-eval82.1%
Simplified82.1%
Final simplification79.5%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-57)
(/ b (* a -1.5))
(if (<= b 3.4e-33)
(/ (- (sqrt (* (* a c) -3.0)) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-57) {
tmp = b / (a * -1.5);
} else if (b <= 3.4e-33) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
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.8d-57)) then
tmp = b / (a * (-1.5d0))
else if (b <= 3.4d-33) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-57) {
tmp = b / (a * -1.5);
} else if (b <= 3.4e-33) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-57: tmp = b / (a * -1.5) elif b <= 3.4e-33: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-57) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 3.4e-33) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.8e-57) tmp = b / (a * -1.5); elseif (b <= 3.4e-33) tmp = (sqrt(((a * c) * -3.0)) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-57], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-33], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-57}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-33}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.7999999999999997e-57Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Applied egg-rr6.6%
*-commutative6.6%
associate-*l/6.6%
associate-*r/6.6%
associate-*r*6.6%
*-commutative6.6%
associate-*r*6.6%
*-commutative6.6%
Simplified6.6%
Taylor expanded in b around inf 1.0%
*-commutative1.0%
Simplified1.0%
add-sqr-sqrt0.5%
sqrt-unprod33.5%
swap-sqr33.5%
metadata-eval33.5%
metadata-eval33.5%
swap-sqr33.5%
sqrt-unprod49.6%
add-sqr-sqrt89.1%
*-commutative89.1%
clear-num89.1%
un-div-inv89.1%
Applied egg-rr89.1%
associate-/r/89.1%
Simplified89.1%
*-commutative89.1%
clear-num89.1%
un-div-inv89.2%
div-inv89.2%
metadata-eval89.2%
Applied egg-rr89.2%
if -3.7999999999999997e-57 < b < 3.4000000000000001e-33Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.1%
Simplified67.1%
Taylor expanded in b around 0 61.3%
if 3.4000000000000001e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt81.6%
metadata-eval81.6%
distribute-rgt-neg-in81.6%
distribute-frac-neg81.6%
distribute-frac-neg281.6%
times-frac81.8%
neg-mul-181.8%
remove-double-neg81.8%
*-commutative81.8%
associate-*l*82.1%
metadata-eval82.1%
Simplified82.1%
Final simplification79.4%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e-56)
(/ b (* a -1.5))
(if (<= b 5.8e-33)
(/ (+ b (sqrt (* a (* c -3.0)))) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-56) {
tmp = b / (a * -1.5);
} else if (b <= 5.8e-33) {
tmp = (b + sqrt((a * (c * -3.0)))) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
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 <= (-4.5d-56)) then
tmp = b / (a * (-1.5d0))
else if (b <= 5.8d-33) then
tmp = (b + sqrt((a * (c * (-3.0d0))))) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-56) {
tmp = b / (a * -1.5);
} else if (b <= 5.8e-33) {
tmp = (b + Math.sqrt((a * (c * -3.0)))) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e-56: tmp = b / (a * -1.5) elif b <= 5.8e-33: tmp = (b + math.sqrt((a * (c * -3.0)))) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-56) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 5.8e-33) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -3.0)))) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.5e-56) tmp = b / (a * -1.5); elseif (b <= 5.8e-33) tmp = (b + sqrt((a * (c * -3.0)))) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-56], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-33], N[(N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-33}:\\
\;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -3\right)}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.5000000000000001e-56Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Applied egg-rr6.6%
*-commutative6.6%
associate-*l/6.6%
associate-*r/6.6%
associate-*r*6.6%
*-commutative6.6%
associate-*r*6.6%
*-commutative6.6%
Simplified6.6%
Taylor expanded in b around inf 1.0%
*-commutative1.0%
Simplified1.0%
add-sqr-sqrt0.5%
sqrt-unprod33.5%
swap-sqr33.5%
metadata-eval33.5%
metadata-eval33.5%
swap-sqr33.5%
sqrt-unprod49.6%
add-sqr-sqrt89.1%
*-commutative89.1%
clear-num89.1%
un-div-inv89.1%
Applied egg-rr89.1%
associate-/r/89.1%
Simplified89.1%
*-commutative89.1%
clear-num89.1%
un-div-inv89.2%
div-inv89.2%
metadata-eval89.2%
Applied egg-rr89.2%
if -4.5000000000000001e-56 < b < 5.80000000000000005e-33Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.1%
Simplified67.1%
Taylor expanded in b around 0 61.3%
*-commutative61.3%
associate-*r*61.2%
Simplified61.2%
*-un-lft-identity61.2%
add-sqr-sqrt25.6%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-prod35.4%
add-sqr-sqrt60.4%
Applied egg-rr60.4%
*-lft-identity60.4%
Simplified60.4%
if 5.80000000000000005e-33 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt81.6%
metadata-eval81.6%
distribute-rgt-neg-in81.6%
distribute-frac-neg81.6%
distribute-frac-neg281.6%
times-frac81.8%
neg-mul-181.8%
remove-double-neg81.8%
*-commutative81.8%
associate-*l*82.1%
metadata-eval82.1%
Simplified82.1%
Final simplification79.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.16e-57)
(/ b (* a -1.5))
(if (<= b 3.2e-32)
(* 0.3333333333333333 (/ (+ b (sqrt (* (* a c) -3.0))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.16e-57) {
tmp = b / (a * -1.5);
} else if (b <= 3.2e-32) {
tmp = 0.3333333333333333 * ((b + sqrt(((a * c) * -3.0))) / a);
} else {
tmp = (c * -0.5) / b;
}
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.16d-57)) then
tmp = b / (a * (-1.5d0))
else if (b <= 3.2d-32) then
tmp = 0.3333333333333333d0 * ((b + sqrt(((a * c) * (-3.0d0)))) / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.16e-57) {
tmp = b / (a * -1.5);
} else if (b <= 3.2e-32) {
tmp = 0.3333333333333333 * ((b + Math.sqrt(((a * c) * -3.0))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.16e-57: tmp = b / (a * -1.5) elif b <= 3.2e-32: tmp = 0.3333333333333333 * ((b + math.sqrt(((a * c) * -3.0))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.16e-57) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 3.2e-32) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(Float64(a * c) * -3.0))) / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.16e-57) tmp = b / (a * -1.5); elseif (b <= 3.2e-32) tmp = 0.3333333333333333 * ((b + sqrt(((a * c) * -3.0))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.16e-57], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.2e-32], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.16 \cdot 10^{-57}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-32}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{\left(a \cdot c\right) \cdot -3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.15999999999999996e-57Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
associate-*l*69.9%
Simplified69.9%
Applied egg-rr6.6%
*-commutative6.6%
associate-*l/6.6%
associate-*r/6.6%
associate-*r*6.6%
*-commutative6.6%
associate-*r*6.6%
*-commutative6.6%
Simplified6.6%
Taylor expanded in b around inf 1.0%
*-commutative1.0%
Simplified1.0%
add-sqr-sqrt0.5%
sqrt-unprod33.5%
swap-sqr33.5%
metadata-eval33.5%
metadata-eval33.5%
swap-sqr33.5%
sqrt-unprod49.6%
add-sqr-sqrt89.1%
*-commutative89.1%
clear-num89.1%
un-div-inv89.1%
Applied egg-rr89.1%
associate-/r/89.1%
Simplified89.1%
*-commutative89.1%
clear-num89.1%
un-div-inv89.2%
div-inv89.2%
metadata-eval89.2%
Applied egg-rr89.2%
if -1.15999999999999996e-57 < b < 3.2000000000000002e-32Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.1%
Simplified67.1%
Taylor expanded in b around 0 61.3%
*-commutative61.3%
associate-*r*61.2%
Simplified61.2%
*-un-lft-identity61.2%
times-frac61.1%
metadata-eval61.1%
add-sqr-sqrt25.6%
sqrt-unprod60.6%
sqr-neg60.6%
sqrt-prod35.3%
add-sqr-sqrt60.4%
Applied egg-rr60.4%
Taylor expanded in a around 0 60.4%
if 3.2000000000000002e-32 < b Initial program 17.6%
sqr-neg17.6%
sqr-neg17.6%
associate-*l*17.6%
Simplified17.6%
Applied egg-rr23.1%
un-div-inv23.1%
div-inv23.1%
metadata-eval23.1%
Applied egg-rr23.1%
Taylor expanded in b around inf 0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt81.6%
metadata-eval81.6%
distribute-rgt-neg-in81.6%
distribute-frac-neg81.6%
distribute-frac-neg281.6%
times-frac81.8%
neg-mul-181.8%
remove-double-neg81.8%
*-commutative81.8%
associate-*l*82.1%
metadata-eval82.1%
Simplified82.1%
Final simplification79.1%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e-138)
(/ b (* a -1.5))
(if (<= b 1.32e-199)
(* (sqrt (/ (* c -3.0) a)) (- -0.3333333333333333))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-138) {
tmp = b / (a * -1.5);
} else if (b <= 1.32e-199) {
tmp = sqrt(((c * -3.0) / a)) * -(-0.3333333333333333);
} else {
tmp = (c * -0.5) / b;
}
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 <= (-4.5d-138)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.32d-199) then
tmp = sqrt(((c * (-3.0d0)) / a)) * -(-0.3333333333333333d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-138) {
tmp = b / (a * -1.5);
} else if (b <= 1.32e-199) {
tmp = Math.sqrt(((c * -3.0) / a)) * -(-0.3333333333333333);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e-138: tmp = b / (a * -1.5) elif b <= 1.32e-199: tmp = math.sqrt(((c * -3.0) / a)) * -(-0.3333333333333333) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-138) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.32e-199) tmp = Float64(sqrt(Float64(Float64(c * -3.0) / a)) * Float64(-(-0.3333333333333333))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.5e-138) tmp = b / (a * -1.5); elseif (b <= 1.32e-199) tmp = sqrt(((c * -3.0) / a)) * -(-0.3333333333333333); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-138], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.32e-199], N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-138}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.32 \cdot 10^{-199}:\\
\;\;\;\;\sqrt{\frac{c \cdot -3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.50000000000000008e-138Initial program 71.0%
sqr-neg71.0%
sqr-neg71.0%
associate-*l*71.0%
Simplified71.0%
Applied egg-rr10.4%
*-commutative10.4%
associate-*l/10.4%
associate-*r/10.4%
associate-*r*10.4%
*-commutative10.4%
associate-*r*10.4%
*-commutative10.4%
Simplified10.4%
Taylor expanded in b around inf 1.1%
*-commutative1.1%
Simplified1.1%
add-sqr-sqrt0.6%
sqrt-unprod32.2%
swap-sqr32.3%
metadata-eval32.3%
metadata-eval32.3%
swap-sqr32.2%
sqrt-unprod46.7%
add-sqr-sqrt84.2%
*-commutative84.2%
clear-num84.2%
un-div-inv84.2%
Applied egg-rr84.2%
associate-/r/84.3%
Simplified84.3%
*-commutative84.3%
clear-num84.2%
un-div-inv84.3%
div-inv84.3%
metadata-eval84.3%
Applied egg-rr84.3%
if -4.50000000000000008e-138 < b < 1.3199999999999999e-199Initial program 69.8%
add-cube-cbrt69.5%
pow369.5%
Applied egg-rr69.5%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt41.8%
rem-cube-cbrt42.0%
Simplified42.0%
if 1.3199999999999999e-199 < b Initial program 26.5%
sqr-neg26.5%
sqr-neg26.5%
associate-*l*26.5%
Simplified26.5%
Applied egg-rr30.6%
un-div-inv30.7%
div-inv30.6%
metadata-eval30.6%
Applied egg-rr30.6%
Taylor expanded in b around inf 0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt70.3%
metadata-eval70.3%
distribute-rgt-neg-in70.3%
distribute-frac-neg70.3%
distribute-frac-neg270.3%
times-frac70.5%
neg-mul-170.5%
remove-double-neg70.5%
*-commutative70.5%
associate-*l*70.7%
metadata-eval70.7%
Simplified70.7%
Final simplification73.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
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 <= (-5d-310)) then
tmp = b / (a * (-1.5d0))
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Applied egg-rr18.3%
*-commutative18.3%
associate-*l/18.3%
associate-*r/18.3%
associate-*r*18.3%
*-commutative18.3%
associate-*r*18.3%
*-commutative18.3%
Simplified18.3%
Taylor expanded in b around inf 1.4%
*-commutative1.4%
Simplified1.4%
add-sqr-sqrt0.8%
sqrt-unprod28.5%
swap-sqr28.5%
metadata-eval28.5%
metadata-eval28.5%
swap-sqr28.5%
sqrt-unprod41.0%
add-sqr-sqrt73.9%
*-commutative73.9%
clear-num73.9%
un-div-inv73.9%
Applied egg-rr73.9%
associate-/r/74.0%
Simplified74.0%
*-commutative74.0%
clear-num73.9%
un-div-inv74.0%
div-inv74.0%
metadata-eval74.0%
Applied egg-rr74.0%
if -4.999999999999985e-310 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Applied egg-rr35.0%
un-div-inv35.0%
div-inv35.0%
metadata-eval35.0%
Applied egg-rr35.0%
Taylor expanded in b around inf 0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt62.4%
metadata-eval62.4%
distribute-rgt-neg-in62.4%
distribute-frac-neg62.4%
distribute-frac-neg262.4%
times-frac62.6%
neg-mul-162.6%
remove-double-neg62.6%
*-commutative62.6%
associate-*l*62.8%
metadata-eval62.8%
Simplified62.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.3e-308) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.3e-308) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
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.3d-308) then
tmp = b / (a * (-1.5d0))
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.3e-308) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.3e-308: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.3e-308) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.3e-308) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.3e-308], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.3 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.2999999999999999e-308Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Applied egg-rr18.3%
*-commutative18.3%
associate-*l/18.3%
associate-*r/18.3%
associate-*r*18.3%
*-commutative18.3%
associate-*r*18.3%
*-commutative18.3%
Simplified18.3%
Taylor expanded in b around inf 1.4%
*-commutative1.4%
Simplified1.4%
add-sqr-sqrt0.8%
sqrt-unprod28.5%
swap-sqr28.5%
metadata-eval28.5%
metadata-eval28.5%
swap-sqr28.5%
sqrt-unprod41.0%
add-sqr-sqrt73.9%
*-commutative73.9%
clear-num73.9%
un-div-inv73.9%
Applied egg-rr73.9%
associate-/r/74.0%
Simplified74.0%
*-commutative74.0%
clear-num73.9%
un-div-inv74.0%
div-inv74.0%
metadata-eval74.0%
Applied egg-rr74.0%
if 2.2999999999999999e-308 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around inf 62.8%
*-commutative62.8%
Simplified62.8%
Final simplification68.5%
(FPCore (a b c) :precision binary64 (if (<= b 6e-309) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
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 <= 6d-309) then
tmp = b * ((-0.6666666666666666d0) / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6e-309: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6e-309) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6e-309) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6e-309], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.000000000000001e-309Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
associate-*l*71.1%
Simplified71.1%
Applied egg-rr18.3%
*-commutative18.3%
associate-*l/18.3%
associate-*r/18.3%
associate-*r*18.3%
*-commutative18.3%
associate-*r*18.3%
*-commutative18.3%
Simplified18.3%
Taylor expanded in b around inf 1.4%
*-commutative1.4%
Simplified1.4%
add-sqr-sqrt0.8%
sqrt-unprod28.5%
swap-sqr28.5%
metadata-eval28.5%
metadata-eval28.5%
swap-sqr28.5%
sqrt-unprod41.0%
add-sqr-sqrt73.9%
*-commutative73.9%
clear-num73.9%
un-div-inv73.9%
Applied egg-rr73.9%
associate-/r/74.0%
Simplified74.0%
if 6.000000000000001e-309 < b Initial program 31.4%
sqr-neg31.4%
sqr-neg31.4%
associate-*l*31.4%
Simplified31.4%
Taylor expanded in b around inf 62.8%
*-commutative62.8%
Simplified62.8%
Final simplification68.5%
(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 51.6%
sqr-neg51.6%
sqr-neg51.6%
associate-*l*51.6%
Simplified51.6%
Applied egg-rr22.0%
*-commutative22.0%
associate-*l/22.0%
associate-*r/22.0%
associate-*r*22.0%
*-commutative22.0%
associate-*r*22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in b around inf 2.6%
*-commutative2.6%
Simplified2.6%
add-sqr-sqrt1.3%
sqrt-unprod16.1%
swap-sqr16.1%
metadata-eval16.1%
metadata-eval16.1%
swap-sqr16.1%
sqrt-unprod21.8%
add-sqr-sqrt39.0%
*-commutative39.0%
clear-num39.0%
un-div-inv39.0%
Applied egg-rr39.0%
associate-/r/39.0%
Simplified39.0%
Final simplification39.0%
herbie shell --seed 2024112
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))