
(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 9 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 -2.3e+153)
(* (/ b a) -0.6666666666666666)
(if (<= b 4.2e-57)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e+153) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 4.2e-57) {
tmp = (sqrt(((b * b) - ((a * 3.0) * 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 <= (-2.3d+153)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 4.2d-57) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * 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 <= -2.3e+153) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 4.2e-57) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.3e+153: tmp = (b / a) * -0.6666666666666666 elif b <= 4.2e-57: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.3e+153) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 4.2e-57) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * 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 <= -2.3e+153) tmp = (b / a) * -0.6666666666666666; elseif (b <= 4.2e-57) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.3e+153], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 4.2e-57], 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 * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-57}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.3000000000000001e153Initial program 46.5%
sqr-neg46.5%
sqr-neg46.5%
associate-*l*46.5%
Simplified46.5%
sub-neg46.5%
sub-neg46.5%
*-commutative46.5%
cancel-sign-sub-inv46.5%
distribute-lft-neg-in46.5%
distribute-rgt-neg-in46.5%
metadata-eval46.5%
associate-*r*46.5%
fma-undefine46.5%
add-sqr-sqrt46.5%
pow246.5%
fma-undefine46.5%
add-sqr-sqrt33.3%
hypot-define56.7%
Applied egg-rr56.7%
Taylor expanded in b around -inf 91.4%
*-commutative91.4%
Simplified91.4%
if -2.3000000000000001e153 < b < 4.1999999999999999e-57Initial program 86.1%
if 4.1999999999999999e-57 < b Initial program 8.7%
sqr-neg8.7%
sqr-neg8.7%
associate-*l*8.7%
Simplified8.7%
Taylor expanded in b around inf 78.0%
associate-/l*79.4%
Simplified79.4%
Taylor expanded in a around 0 93.8%
*-commutative93.8%
associate-*l/93.9%
Simplified93.9%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(if (<= b -9e+153)
(* (/ b a) -0.6666666666666666)
(if (<= b 3.7e-47)
(/ (- (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 <= -9e+153) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 3.7e-47) {
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 <= (-9d+153)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 3.7d-47) 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 <= -9e+153) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 3.7e-47) {
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 <= -9e+153: tmp = (b / a) * -0.6666666666666666 elif b <= 3.7e-47: 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 <= -9e+153) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 3.7e-47) 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 <= -9e+153) tmp = (b / a) * -0.6666666666666666; elseif (b <= 3.7e-47) 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, -9e+153], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 3.7e-47], 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 -9 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{-47}:\\
\;\;\;\;\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 < -9.0000000000000002e153Initial program 46.5%
sqr-neg46.5%
sqr-neg46.5%
associate-*l*46.5%
Simplified46.5%
sub-neg46.5%
sub-neg46.5%
*-commutative46.5%
cancel-sign-sub-inv46.5%
distribute-lft-neg-in46.5%
distribute-rgt-neg-in46.5%
metadata-eval46.5%
associate-*r*46.5%
fma-undefine46.5%
add-sqr-sqrt46.5%
pow246.5%
fma-undefine46.5%
add-sqr-sqrt33.3%
hypot-define56.7%
Applied egg-rr56.7%
Taylor expanded in b around -inf 91.4%
*-commutative91.4%
Simplified91.4%
if -9.0000000000000002e153 < b < 3.7e-47Initial program 86.1%
sqr-neg86.1%
sqr-neg86.1%
associate-*l*86.1%
Simplified86.1%
if 3.7e-47 < b Initial program 8.7%
sqr-neg8.7%
sqr-neg8.7%
associate-*l*8.7%
Simplified8.7%
Taylor expanded in b around inf 78.0%
associate-/l*79.4%
Simplified79.4%
Taylor expanded in a around 0 93.8%
*-commutative93.8%
associate-*l/93.9%
Simplified93.9%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5.5e-128)
(* b (- (/ (* c -0.5) (- (pow b 2.0))) (/ 0.6666666666666666 a)))
(if (<= b 4.9e-52)
(/ (- (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 <= -5.5e-128) {
tmp = b * (((c * -0.5) / -pow(b, 2.0)) - (0.6666666666666666 / a));
} else if (b <= 4.9e-52) {
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 <= (-5.5d-128)) then
tmp = b * (((c * (-0.5d0)) / -(b ** 2.0d0)) - (0.6666666666666666d0 / a))
else if (b <= 4.9d-52) 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 <= -5.5e-128) {
tmp = b * (((c * -0.5) / -Math.pow(b, 2.0)) - (0.6666666666666666 / a));
} else if (b <= 4.9e-52) {
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 <= -5.5e-128: tmp = b * (((c * -0.5) / -math.pow(b, 2.0)) - (0.6666666666666666 / a)) elif b <= 4.9e-52: 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 <= -5.5e-128) tmp = Float64(b * Float64(Float64(Float64(c * -0.5) / Float64(-(b ^ 2.0))) - Float64(0.6666666666666666 / a))); elseif (b <= 4.9e-52) tmp = Float64(Float64(sqrt(Float64(a * Float64(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 <= -5.5e-128) tmp = b * (((c * -0.5) / -(b ^ 2.0)) - (0.6666666666666666 / a)); elseif (b <= 4.9e-52) 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, -5.5e-128], N[(b * N[(N[(N[(c * -0.5), $MachinePrecision] / (-N[Power[b, 2.0], $MachinePrecision])), $MachinePrecision] - N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.9e-52], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $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.5 \cdot 10^{-128}:\\
\;\;\;\;b \cdot \left(\frac{c \cdot -0.5}{-{b}^{2}} - \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 4.9 \cdot 10^{-52}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.5000000000000004e-128Initial program 80.0%
sqr-neg80.0%
sqr-neg80.0%
associate-*l*80.0%
Simplified80.0%
sub-neg80.0%
sub-neg80.0%
*-commutative80.0%
cancel-sign-sub-inv80.0%
distribute-lft-neg-in80.0%
distribute-rgt-neg-in80.0%
metadata-eval80.0%
associate-*r*80.0%
fma-undefine80.0%
add-sqr-sqrt79.7%
pow279.7%
fma-undefine79.7%
add-sqr-sqrt61.8%
hypot-define69.6%
Applied egg-rr69.6%
Taylor expanded in b around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
associate-*r/0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt81.3%
metadata-eval81.3%
*-commutative81.3%
associate-*r/81.3%
metadata-eval81.3%
Simplified81.3%
if -5.5000000000000004e-128 < b < 4.90000000000000019e-52Initial program 75.5%
sqr-neg75.5%
sqr-neg75.5%
associate-*l*75.4%
Simplified75.4%
add-cube-cbrt74.9%
pow375.0%
Applied egg-rr75.0%
add-cube-cbrt74.4%
pow374.4%
unpow374.4%
add-cube-cbrt74.8%
Applied egg-rr74.8%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt71.2%
associate-*r*71.2%
metadata-eval71.2%
rem-cube-cbrt71.4%
Simplified71.4%
if 4.90000000000000019e-52 < b Initial program 8.7%
sqr-neg8.7%
sqr-neg8.7%
associate-*l*8.7%
Simplified8.7%
Taylor expanded in b around inf 78.0%
associate-/l*79.4%
Simplified79.4%
Taylor expanded in a around 0 93.8%
*-commutative93.8%
associate-*l/93.9%
Simplified93.9%
Final simplification83.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.12e-147)
(* b (- (/ (* c -0.5) (- (pow b 2.0))) (/ 0.6666666666666666 a)))
(if (<= b 4.8e-105)
(* (sqrt (* c (/ -3.0 a))) 0.3333333333333333)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.12e-147) {
tmp = b * (((c * -0.5) / -pow(b, 2.0)) - (0.6666666666666666 / a));
} else if (b <= 4.8e-105) {
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 <= (-1.12d-147)) then
tmp = b * (((c * (-0.5d0)) / -(b ** 2.0d0)) - (0.6666666666666666d0 / a))
else if (b <= 4.8d-105) 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 <= -1.12e-147) {
tmp = b * (((c * -0.5) / -Math.pow(b, 2.0)) - (0.6666666666666666 / a));
} else if (b <= 4.8e-105) {
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 <= -1.12e-147: tmp = b * (((c * -0.5) / -math.pow(b, 2.0)) - (0.6666666666666666 / a)) elif b <= 4.8e-105: 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 <= -1.12e-147) tmp = Float64(b * Float64(Float64(Float64(c * -0.5) / Float64(-(b ^ 2.0))) - Float64(0.6666666666666666 / a))); elseif (b <= 4.8e-105) tmp = Float64(sqrt(Float64(c * Float64(-3.0 / a))) * 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 <= -1.12e-147) tmp = b * (((c * -0.5) / -(b ^ 2.0)) - (0.6666666666666666 / a)); elseif (b <= 4.8e-105) 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, -1.12e-147], N[(b * N[(N[(N[(c * -0.5), $MachinePrecision] / (-N[Power[b, 2.0], $MachinePrecision])), $MachinePrecision] - N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e-105], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.12 \cdot 10^{-147}:\\
\;\;\;\;b \cdot \left(\frac{c \cdot -0.5}{-{b}^{2}} - \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-105}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.12e-147Initial program 80.4%
sqr-neg80.4%
sqr-neg80.4%
associate-*l*80.3%
Simplified80.3%
sub-neg80.3%
sub-neg80.3%
*-commutative80.3%
cancel-sign-sub-inv80.3%
distribute-lft-neg-in80.3%
distribute-rgt-neg-in80.3%
metadata-eval80.3%
associate-*r*80.3%
fma-undefine80.3%
add-sqr-sqrt80.1%
pow280.1%
fma-undefine80.1%
add-sqr-sqrt62.6%
hypot-define70.2%
Applied egg-rr70.2%
Taylor expanded in b around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
associate-*r/0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt80.7%
metadata-eval80.7%
*-commutative80.7%
associate-*r/80.7%
metadata-eval80.7%
Simplified80.7%
if -1.12e-147 < b < 4.8000000000000003e-105Initial program 76.8%
sqr-neg76.8%
sqr-neg76.8%
associate-*l*76.8%
Simplified76.8%
add-cube-cbrt76.1%
pow376.2%
Applied egg-rr76.2%
add-cube-cbrt75.6%
pow375.6%
unpow375.7%
add-cube-cbrt76.1%
Applied egg-rr76.1%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt30.1%
associate-*l*30.1%
associate-/l*30.1%
rem-cube-cbrt30.3%
metadata-eval30.3%
Simplified30.3%
if 4.8000000000000003e-105 < b Initial program 13.3%
sqr-neg13.3%
sqr-neg13.3%
associate-*l*13.3%
Simplified13.3%
Taylor expanded in b around inf 73.4%
associate-/l*75.5%
Simplified75.5%
Taylor expanded in a around 0 89.7%
*-commutative89.7%
associate-*l/89.7%
Simplified89.7%
Final simplification73.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.35e-186)
(/ (* b -2.0) (* a 3.0))
(if (<= b 4.8e-105)
(* (sqrt (* c (/ -3.0 a))) 0.3333333333333333)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.35e-186) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 4.8e-105) {
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 <= (-3.35d-186)) then
tmp = (b * (-2.0d0)) / (a * 3.0d0)
else if (b <= 4.8d-105) 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 <= -3.35e-186) {
tmp = (b * -2.0) / (a * 3.0);
} else if (b <= 4.8e-105) {
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 <= -3.35e-186: tmp = (b * -2.0) / (a * 3.0) elif b <= 4.8e-105: 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 <= -3.35e-186) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); elseif (b <= 4.8e-105) tmp = Float64(sqrt(Float64(c * Float64(-3.0 / a))) * 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 <= -3.35e-186) tmp = (b * -2.0) / (a * 3.0); elseif (b <= 4.8e-105) 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, -3.35e-186], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e-105], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.35 \cdot 10^{-186}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-105}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.35000000000000017e-186Initial program 79.2%
sqr-neg79.2%
sqr-neg79.2%
associate-*l*79.2%
Simplified79.2%
Taylor expanded in b around -inf 77.2%
*-commutative77.2%
Simplified77.2%
if -3.35000000000000017e-186 < b < 4.8000000000000003e-105Initial program 79.0%
sqr-neg79.0%
sqr-neg79.0%
associate-*l*78.9%
Simplified78.9%
add-cube-cbrt78.3%
pow378.3%
Applied egg-rr78.3%
add-cube-cbrt77.7%
pow377.7%
unpow377.7%
add-cube-cbrt78.1%
Applied egg-rr78.1%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt30.1%
associate-*l*30.1%
associate-/l*30.2%
rem-cube-cbrt30.4%
metadata-eval30.4%
Simplified30.4%
if 4.8000000000000003e-105 < b Initial program 13.3%
sqr-neg13.3%
sqr-neg13.3%
associate-*l*13.3%
Simplified13.3%
Taylor expanded in b around inf 73.4%
associate-/l*75.5%
Simplified75.5%
Taylor expanded in a around 0 89.7%
*-commutative89.7%
associate-*l/89.7%
Simplified89.7%
Final simplification73.9%
(FPCore (a b c) :precision binary64 (if (<= b 1.85e-290) (/ (* b -2.0) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.85e-290) {
tmp = (b * -2.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 <= 1.85d-290) then
tmp = (b * (-2.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 <= 1.85e-290) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.85e-290: tmp = (b * -2.0) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.85e-290) tmp = Float64(Float64(b * -2.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 <= 1.85e-290) tmp = (b * -2.0) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.85e-290], N[(N[(b * -2.0), $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 1.85 \cdot 10^{-290}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.84999999999999989e-290Initial program 79.7%
sqr-neg79.7%
sqr-neg79.7%
associate-*l*79.7%
Simplified79.7%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if 1.84999999999999989e-290 < b Initial program 27.0%
sqr-neg27.0%
sqr-neg27.0%
associate-*l*27.0%
Simplified27.0%
Taylor expanded in b around inf 58.6%
associate-/l*60.9%
Simplified60.9%
Taylor expanded in a around 0 73.4%
*-commutative73.4%
associate-*l/73.4%
Simplified73.4%
Final simplification70.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.85e-290) (* (/ b a) -0.6666666666666666) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.85e-290) {
tmp = (b / a) * -0.6666666666666666;
} 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.85d-290) then
tmp = (b / a) * (-0.6666666666666666d0)
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.85e-290) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.85e-290: tmp = (b / a) * -0.6666666666666666 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.85e-290) tmp = Float64(Float64(b / a) * -0.6666666666666666); 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.85e-290) tmp = (b / a) * -0.6666666666666666; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.85e-290], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.85 \cdot 10^{-290}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.84999999999999989e-290Initial program 79.7%
sqr-neg79.7%
sqr-neg79.7%
associate-*l*79.7%
Simplified79.7%
sub-neg79.7%
sub-neg79.7%
*-commutative79.7%
cancel-sign-sub-inv79.7%
distribute-lft-neg-in79.7%
distribute-rgt-neg-in79.7%
metadata-eval79.7%
associate-*r*79.7%
fma-undefine79.7%
add-sqr-sqrt79.4%
pow279.4%
fma-undefine79.4%
add-sqr-sqrt65.4%
hypot-define72.8%
Applied egg-rr72.8%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if 1.84999999999999989e-290 < b Initial program 27.0%
sqr-neg27.0%
sqr-neg27.0%
associate-*l*27.0%
Simplified27.0%
Taylor expanded in b around inf 58.6%
associate-/l*60.9%
Simplified60.9%
Taylor expanded in a around 0 73.4%
*-commutative73.4%
associate-*l/73.4%
Simplified73.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.85e-290) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.85e-290) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 1.85d-290) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 1.85e-290) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.85e-290: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.85e-290) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.85e-290) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.85e-290], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.85 \cdot 10^{-290}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.84999999999999989e-290Initial program 79.7%
sqr-neg79.7%
sqr-neg79.7%
associate-*l*79.7%
Simplified79.7%
sub-neg79.7%
sub-neg79.7%
*-commutative79.7%
cancel-sign-sub-inv79.7%
distribute-lft-neg-in79.7%
distribute-rgt-neg-in79.7%
metadata-eval79.7%
associate-*r*79.7%
fma-undefine79.7%
add-sqr-sqrt79.4%
pow279.4%
fma-undefine79.4%
add-sqr-sqrt65.4%
hypot-define72.8%
Applied egg-rr72.8%
Taylor expanded in b around -inf 67.1%
*-commutative67.1%
Simplified67.1%
if 1.84999999999999989e-290 < b Initial program 27.0%
sqr-neg27.0%
sqr-neg27.0%
associate-*l*27.0%
Simplified27.0%
sub-neg27.0%
sub-neg27.0%
*-commutative27.0%
cancel-sign-sub-inv27.0%
distribute-lft-neg-in27.0%
distribute-rgt-neg-in27.0%
metadata-eval27.0%
associate-*r*27.0%
fma-undefine27.0%
add-sqr-sqrt25.0%
pow225.0%
fma-undefine25.0%
add-sqr-sqrt23.6%
hypot-define27.4%
Applied egg-rr27.4%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt73.4%
metadata-eval73.4%
associate-*r/73.4%
*-commutative73.4%
Simplified73.4%
Final simplification70.4%
(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 52.1%
sqr-neg52.1%
sqr-neg52.1%
associate-*l*52.1%
Simplified52.1%
sub-neg52.1%
sub-neg52.1%
*-commutative52.1%
cancel-sign-sub-inv52.1%
distribute-lft-neg-in52.1%
distribute-rgt-neg-in52.1%
metadata-eval52.1%
associate-*r*52.1%
fma-undefine52.1%
add-sqr-sqrt51.0%
pow251.0%
fma-undefine51.0%
add-sqr-sqrt43.5%
hypot-define49.0%
Applied egg-rr49.0%
Taylor expanded in b around -inf 33.3%
*-commutative33.3%
Simplified33.3%
herbie shell --seed 2024111
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))