
(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 -7.2e+63)
(/ b (* a -1.5))
(if (<= b 2.3e-78)
(/ (- (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 <= -7.2e+63) {
tmp = b / (a * -1.5);
} else if (b <= 2.3e-78) {
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 <= (-7.2d+63)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.3d-78) 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 <= -7.2e+63) {
tmp = b / (a * -1.5);
} else if (b <= 2.3e-78) {
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 <= -7.2e+63: tmp = b / (a * -1.5) elif b <= 2.3e-78: 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 <= -7.2e+63) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.3e-78) 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 <= -7.2e+63) tmp = b / (a * -1.5); elseif (b <= 2.3e-78) 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, -7.2e+63], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-78], 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 -7.2 \cdot 10^{+63}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-78}:\\
\;\;\;\;\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 < -7.19999999999999998e63Initial program 64.8%
add-cube-cbrt64.4%
pow364.4%
Applied egg-rr64.4%
Taylor expanded in b around -inf 95.9%
associate-*r/95.9%
rem-cube-cbrt96.6%
*-commutative96.6%
times-frac96.4%
metadata-eval96.4%
associate-*r/96.5%
*-commutative96.5%
associate-/l*96.3%
Simplified96.3%
clear-num96.3%
un-div-inv96.5%
div-inv96.6%
metadata-eval96.6%
Applied egg-rr96.6%
if -7.19999999999999998e63 < b < 2.3000000000000002e-78Initial program 82.4%
if 2.3000000000000002e-78 < b Initial program 18.6%
sqr-neg18.6%
sqr-neg18.6%
associate-*l*18.6%
Simplified18.6%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.06e+63)
(/ b (* a -1.5))
(if (<= b 2.2e-78)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.06e+63) {
tmp = b / (a * -1.5);
} else if (b <= 2.2e-78) {
tmp = (sqrt(((b * b) - (3.0 * (a * 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.06d+63)) then
tmp = b / (a * (-1.5d0))
else if (b <= 2.2d-78) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * 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.06e+63) {
tmp = b / (a * -1.5);
} else if (b <= 2.2e-78) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.06e+63: tmp = b / (a * -1.5) elif b <= 2.2e-78: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.06e+63) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 2.2e-78) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * 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.06e+63) tmp = b / (a * -1.5); elseif (b <= 2.2e-78) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.06e+63], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-78], 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 / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.06 \cdot 10^{+63}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-78}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.0600000000000001e63Initial program 64.8%
add-cube-cbrt64.4%
pow364.4%
Applied egg-rr64.4%
Taylor expanded in b around -inf 95.9%
associate-*r/95.9%
rem-cube-cbrt96.6%
*-commutative96.6%
times-frac96.4%
metadata-eval96.4%
associate-*r/96.5%
*-commutative96.5%
associate-/l*96.3%
Simplified96.3%
clear-num96.3%
un-div-inv96.5%
div-inv96.6%
metadata-eval96.6%
Applied egg-rr96.6%
if -1.0600000000000001e63 < b < 2.1999999999999999e-78Initial program 82.4%
sqr-neg82.4%
sqr-neg82.4%
associate-*l*82.3%
Simplified82.3%
if 2.1999999999999999e-78 < b Initial program 18.6%
sqr-neg18.6%
sqr-neg18.6%
associate-*l*18.6%
Simplified18.6%
Taylor expanded in b around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.55e-27)
(/ b (* a -1.5))
(if (<= b 1.65e-85)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-27) {
tmp = b / (a * -1.5);
} else if (b <= 1.65e-85) {
tmp = (sqrt((c * (a * -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 <= (-1.55d-27)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.65d-85) then
tmp = (sqrt((c * (a * (-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 <= -1.55e-27) {
tmp = b / (a * -1.5);
} else if (b <= 1.65e-85) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.55e-27: tmp = b / (a * -1.5) elif b <= 1.65e-85: tmp = (math.sqrt((c * (a * -3.0))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.55e-27) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.65e-85) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -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 <= -1.55e-27) tmp = b / (a * -1.5); elseif (b <= 1.65e-85) tmp = (sqrt((c * (a * -3.0))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.55e-27], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-85], N[(N[(N[Sqrt[N[(c * N[(a * -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 -1.55 \cdot 10^{-27}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-85}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.5499999999999999e-27Initial program 72.6%
add-cube-cbrt72.2%
pow372.2%
Applied egg-rr72.2%
Taylor expanded in b around -inf 94.6%
associate-*r/94.6%
rem-cube-cbrt95.2%
*-commutative95.2%
times-frac95.0%
metadata-eval95.0%
associate-*r/95.1%
*-commutative95.1%
associate-/l*95.0%
Simplified95.0%
clear-num95.0%
un-div-inv95.1%
div-inv95.2%
metadata-eval95.2%
Applied egg-rr95.2%
if -1.5499999999999999e-27 < b < 1.64999999999999986e-85Initial program 78.1%
sqr-neg78.1%
sqr-neg78.1%
associate-*l*78.0%
Simplified78.0%
Taylor expanded in b around 0 68.6%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
+-commutative68.7%
unsub-neg68.7%
associate-*l*68.6%
*-commutative68.6%
Applied egg-rr68.6%
associate-*r*68.6%
*-commutative68.6%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
if 1.64999999999999986e-85 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.0%
*-commutative86.0%
Simplified86.0%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.55e-27)
(/ b (* a -1.5))
(if (<= b 1.42e-81)
(/ (* 0.3333333333333333 (- (sqrt (* a (* c -3.0))) b)) a)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-27) {
tmp = b / (a * -1.5);
} else if (b <= 1.42e-81) {
tmp = (0.3333333333333333 * (sqrt((a * (c * -3.0))) - b)) / 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 <= (-1.55d-27)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.42d-81) then
tmp = (0.3333333333333333d0 * (sqrt((a * (c * (-3.0d0)))) - b)) / 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 <= -1.55e-27) {
tmp = b / (a * -1.5);
} else if (b <= 1.42e-81) {
tmp = (0.3333333333333333 * (Math.sqrt((a * (c * -3.0))) - b)) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.55e-27: tmp = b / (a * -1.5) elif b <= 1.42e-81: tmp = (0.3333333333333333 * (math.sqrt((a * (c * -3.0))) - b)) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.55e-27) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.42e-81) tmp = Float64(Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(c * -3.0))) - b)) / 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 <= -1.55e-27) tmp = b / (a * -1.5); elseif (b <= 1.42e-81) tmp = (0.3333333333333333 * (sqrt((a * (c * -3.0))) - b)) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.55e-27], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.42e-81], N[(N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.55 \cdot 10^{-27}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.42 \cdot 10^{-81}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \left(\sqrt{a \cdot \left(c \cdot -3\right)} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.5499999999999999e-27Initial program 72.6%
add-cube-cbrt72.2%
pow372.2%
Applied egg-rr72.2%
Taylor expanded in b around -inf 94.6%
associate-*r/94.6%
rem-cube-cbrt95.2%
*-commutative95.2%
times-frac95.0%
metadata-eval95.0%
associate-*r/95.1%
*-commutative95.1%
associate-/l*95.0%
Simplified95.0%
clear-num95.0%
un-div-inv95.1%
div-inv95.2%
metadata-eval95.2%
Applied egg-rr95.2%
if -1.5499999999999999e-27 < b < 1.42000000000000009e-81Initial program 78.1%
sqr-neg78.1%
sqr-neg78.1%
associate-*l*78.0%
Simplified78.0%
Taylor expanded in b around 0 68.6%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
+-commutative68.7%
unsub-neg68.7%
associate-*l*68.6%
*-commutative68.6%
Applied egg-rr68.6%
associate-*r*68.6%
*-commutative68.6%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
div-sub68.7%
sub-neg68.7%
*-un-lft-identity68.7%
times-frac68.5%
metadata-eval68.5%
associate-*l*68.5%
*-commutative68.5%
*-un-lft-identity68.5%
times-frac68.5%
metadata-eval68.5%
Applied egg-rr68.5%
sub-neg68.5%
distribute-lft-out--68.5%
div-sub68.5%
associate-*r/68.5%
Simplified68.5%
if 1.42000000000000009e-81 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.0%
*-commutative86.0%
Simplified86.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-27)
(/ b (* a -1.5))
(if (<= b 1.16e-80)
(* 0.3333333333333333 (/ (- (sqrt (* a (* c -3.0))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-27) {
tmp = b / (a * -1.5);
} else if (b <= 1.16e-80) {
tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - b) / 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 <= (-3.8d-27)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.16d-80) then
tmp = 0.3333333333333333d0 * ((sqrt((a * (c * (-3.0d0)))) - b) / 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 <= -3.8e-27) {
tmp = b / (a * -1.5);
} else if (b <= 1.16e-80) {
tmp = 0.3333333333333333 * ((Math.sqrt((a * (c * -3.0))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-27: tmp = b / (a * -1.5) elif b <= 1.16e-80: tmp = 0.3333333333333333 * ((math.sqrt((a * (c * -3.0))) - b) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-27) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.16e-80) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / 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 <= -3.8e-27) tmp = b / (a * -1.5); elseif (b <= 1.16e-80) tmp = 0.3333333333333333 * ((sqrt((a * (c * -3.0))) - b) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-27], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.16e-80], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-27}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.16 \cdot 10^{-80}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.8e-27Initial program 72.6%
add-cube-cbrt72.2%
pow372.2%
Applied egg-rr72.2%
Taylor expanded in b around -inf 94.6%
associate-*r/94.6%
rem-cube-cbrt95.2%
*-commutative95.2%
times-frac95.0%
metadata-eval95.0%
associate-*r/95.1%
*-commutative95.1%
associate-/l*95.0%
Simplified95.0%
clear-num95.0%
un-div-inv95.1%
div-inv95.2%
metadata-eval95.2%
Applied egg-rr95.2%
if -3.8e-27 < b < 1.15999999999999996e-80Initial program 78.1%
sqr-neg78.1%
sqr-neg78.1%
associate-*l*78.0%
Simplified78.0%
Taylor expanded in b around 0 68.6%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
+-commutative68.7%
unsub-neg68.7%
associate-*l*68.6%
*-commutative68.6%
Applied egg-rr68.6%
associate-*r*68.6%
*-commutative68.6%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
*-un-lft-identity68.7%
times-frac68.5%
metadata-eval68.5%
associate-*l*68.5%
*-commutative68.5%
Applied egg-rr68.5%
if 1.15999999999999996e-80 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.0%
*-commutative86.0%
Simplified86.0%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-27)
(/ b (* a -1.5))
(if (<= b 6.3e-81)
(* 0.3333333333333333 (/ (+ b (sqrt (* c (* a -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-27) {
tmp = b / (a * -1.5);
} else if (b <= 6.3e-81) {
tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -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 <= (-3.8d-27)) then
tmp = b / (a * (-1.5d0))
else if (b <= 6.3d-81) then
tmp = 0.3333333333333333d0 * ((b + sqrt((c * (a * (-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 <= -3.8e-27) {
tmp = b / (a * -1.5);
} else if (b <= 6.3e-81) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-27: tmp = b / (a * -1.5) elif b <= 6.3e-81: tmp = 0.3333333333333333 * ((b + math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-27) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 6.3e-81) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -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 <= -3.8e-27) tmp = b / (a * -1.5); elseif (b <= 6.3e-81) tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-27], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.3e-81], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-27}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 6.3 \cdot 10^{-81}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.8e-27Initial program 72.6%
add-cube-cbrt72.2%
pow372.2%
Applied egg-rr72.2%
Taylor expanded in b around -inf 94.6%
associate-*r/94.6%
rem-cube-cbrt95.2%
*-commutative95.2%
times-frac95.0%
metadata-eval95.0%
associate-*r/95.1%
*-commutative95.1%
associate-/l*95.0%
Simplified95.0%
clear-num95.0%
un-div-inv95.1%
div-inv95.2%
metadata-eval95.2%
Applied egg-rr95.2%
if -3.8e-27 < b < 6.30000000000000023e-81Initial program 78.1%
sqr-neg78.1%
sqr-neg78.1%
associate-*l*78.0%
Simplified78.0%
Taylor expanded in b around 0 68.6%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
*-un-lft-identity68.7%
times-frac68.5%
metadata-eval68.5%
add-sqr-sqrt42.5%
sqrt-unprod68.1%
sqr-neg68.1%
sqrt-unprod25.8%
add-sqr-sqrt67.0%
associate-*l*67.0%
*-commutative67.0%
Applied egg-rr67.0%
associate-*r*67.0%
*-commutative67.0%
associate-*r*67.0%
*-commutative67.0%
Simplified67.0%
if 6.30000000000000023e-81 < b Initial program 19.2%
sqr-neg19.2%
sqr-neg19.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in b around inf 86.0%
*-commutative86.0%
Simplified86.0%
Final simplification83.4%
(FPCore (a b c) :precision binary64 (if (<= b 3.5e-302) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.5e-302) {
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 <= 3.5d-302) 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 <= 3.5e-302) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.5e-302: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.5e-302) 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 <= 3.5e-302) tmp = b / (a * -1.5); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.5e-302], 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 3.5 \cdot 10^{-302}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.5000000000000001e-302Initial program 76.4%
add-cube-cbrt75.7%
pow375.7%
Applied egg-rr75.7%
Taylor expanded in b around -inf 67.5%
associate-*r/67.5%
rem-cube-cbrt68.0%
*-commutative68.0%
times-frac67.8%
metadata-eval67.8%
associate-*r/67.9%
*-commutative67.9%
associate-/l*67.8%
Simplified67.8%
clear-num67.8%
un-div-inv67.9%
div-inv68.0%
metadata-eval68.0%
Applied egg-rr68.0%
if 3.5000000000000001e-302 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*30.9%
Simplified30.9%
Taylor expanded in b around inf 68.8%
*-commutative68.8%
Simplified68.8%
(FPCore (a b c) :precision binary64 (if (<= b 3.5e-302) (* b (/ -0.6666666666666666 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.5e-302) {
tmp = b * (-0.6666666666666666 / 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 <= 3.5d-302) then
tmp = b * ((-0.6666666666666666d0) / 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 <= 3.5e-302) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.5e-302: tmp = b * (-0.6666666666666666 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.5e-302) tmp = Float64(b * Float64(-0.6666666666666666 / 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 <= 3.5e-302) tmp = b * (-0.6666666666666666 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.5e-302], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.5 \cdot 10^{-302}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 3.5000000000000001e-302Initial program 76.4%
add-cube-cbrt75.7%
pow375.7%
Applied egg-rr75.7%
Taylor expanded in b around -inf 67.5%
associate-*r/67.5%
rem-cube-cbrt68.0%
*-commutative68.0%
times-frac67.8%
metadata-eval67.8%
associate-*r/67.9%
*-commutative67.9%
associate-/l*67.8%
Simplified67.8%
if 3.5000000000000001e-302 < b Initial program 31.0%
sqr-neg31.0%
sqr-neg31.0%
associate-*l*30.9%
Simplified30.9%
Taylor expanded in b around inf 68.8%
*-commutative68.8%
Simplified68.8%
(FPCore (a b c) :precision binary64 (if (<= b 8e+26) (* b (/ -0.6666666666666666 a)) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e+26) {
tmp = b * (-0.6666666666666666 / 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 <= 8d+26) then
tmp = b * ((-0.6666666666666666d0) / 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 <= 8e+26) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e+26: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e+26) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8e+26) tmp = b * (-0.6666666666666666 / a); else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e+26], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{+26}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 8.00000000000000038e26Initial program 71.4%
add-cube-cbrt70.5%
pow370.5%
Applied egg-rr70.5%
Taylor expanded in b around -inf 49.0%
associate-*r/49.0%
rem-cube-cbrt49.3%
*-commutative49.3%
times-frac49.2%
metadata-eval49.2%
associate-*r/49.3%
*-commutative49.3%
associate-/l*49.2%
Simplified49.2%
if 8.00000000000000038e26 < b Initial program 11.3%
add-cube-cbrt11.2%
pow311.2%
Applied egg-rr11.2%
Taylor expanded in b around inf 94.2%
associate-*r/94.4%
rem-cube-cbrt94.8%
Simplified94.8%
div-inv94.7%
*-commutative94.7%
*-commutative94.7%
add-sqr-sqrt94.6%
sqrt-unprod63.6%
sqr-neg63.6%
sqrt-unprod0.0%
add-sqr-sqrt33.1%
distribute-rgt-neg-in33.1%
distribute-lft-neg-in33.1%
metadata-eval33.1%
Applied egg-rr33.1%
associate-*r/33.1%
*-rgt-identity33.1%
associate-*r/33.1%
associate-/r*33.1%
metadata-eval33.1%
Simplified33.1%
(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 54.2%
add-cube-cbrt53.6%
pow353.6%
Applied egg-rr53.6%
Taylor expanded in b around -inf 35.9%
associate-*r/35.9%
rem-cube-cbrt36.1%
*-commutative36.1%
times-frac36.0%
metadata-eval36.0%
associate-*r/36.0%
*-commutative36.0%
associate-/l*36.0%
Simplified36.0%
herbie shell --seed 2024121
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))