
(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 -1.55e+79)
(/ b (/ a -0.6666666666666666))
(if (<= b 4.6e-74)
(/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e+79) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 4.6e-74) {
tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} 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.55d+79)) then
tmp = b / (a / (-0.6666666666666666d0))
else if (b <= 4.6d-74) then
tmp = (sqrt(((b * b) - ((a * 3.0d0) * c))) - b) / (a * 3.0d0)
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.55e+79) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 4.6e-74) {
tmp = (Math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.55e+79: tmp = b / (a / -0.6666666666666666) elif b <= 4.6e-74: tmp = (math.sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.55e+79) tmp = Float64(b / Float64(a / -0.6666666666666666)); elseif (b <= 4.6e-74) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)); 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.55e+79) tmp = b / (a / -0.6666666666666666); elseif (b <= 4.6e-74) tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.55e+79], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.6e-74], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.55 \cdot 10^{+79}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-74}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.5499999999999999e79Initial program 52.5%
neg-sub052.5%
sqr-neg52.5%
associate-+l-52.5%
sub0-neg52.5%
neg-mul-152.5%
Simplified52.6%
associate-*r*52.6%
metadata-eval52.6%
distribute-rgt-neg-in52.6%
*-commutative52.6%
fma-neg52.6%
associate-*r*52.6%
*-commutative52.6%
associate-*l*52.6%
Applied egg-rr52.6%
Taylor expanded in b around -inf 87.9%
associate-*r/88.1%
associate-/l*88.1%
Simplified88.1%
associate-/r/88.1%
Applied egg-rr88.1%
associate-*l/88.1%
*-commutative88.1%
associate-/l*88.2%
Applied egg-rr88.2%
if -1.5499999999999999e79 < b < 4.59999999999999961e-74Initial program 85.8%
if 4.59999999999999961e-74 < b Initial program 14.8%
sqr-neg14.8%
sqr-neg14.8%
associate-*l*14.8%
Simplified14.8%
Taylor expanded in b around inf 88.0%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3.3e+80)
(/ b (/ a -0.6666666666666666))
(if (<= b 1.66e-72)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (/ a 0.3333333333333333))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.3e+80) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 1.66e-72) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
} 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 <= (-3.3d+80)) then
tmp = b / (a / (-0.6666666666666666d0))
else if (b <= 1.66d-72) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a / 0.3333333333333333d0)
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 <= -3.3e+80) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 1.66e-72) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.3e+80: tmp = b / (a / -0.6666666666666666) elif b <= 1.66e-72: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.3e+80) tmp = Float64(b / Float64(a / -0.6666666666666666)); elseif (b <= 1.66e-72) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a / 0.3333333333333333)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.3e+80) tmp = b / (a / -0.6666666666666666); elseif (b <= 1.66e-72) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a / 0.3333333333333333); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.3e+80], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.66e-72], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a / 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.3 \cdot 10^{+80}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{elif}\;b \leq 1.66 \cdot 10^{-72}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{\frac{a}{0.3333333333333333}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.29999999999999991e80Initial program 52.5%
neg-sub052.5%
sqr-neg52.5%
associate-+l-52.5%
sub0-neg52.5%
neg-mul-152.5%
Simplified52.6%
associate-*r*52.6%
metadata-eval52.6%
distribute-rgt-neg-in52.6%
*-commutative52.6%
fma-neg52.6%
associate-*r*52.6%
*-commutative52.6%
associate-*l*52.6%
Applied egg-rr52.6%
Taylor expanded in b around -inf 87.9%
associate-*r/88.1%
associate-/l*88.1%
Simplified88.1%
associate-/r/88.1%
Applied egg-rr88.1%
associate-*l/88.1%
*-commutative88.1%
associate-/l*88.2%
Applied egg-rr88.2%
if -3.29999999999999991e80 < b < 1.6600000000000001e-72Initial program 85.8%
neg-sub085.8%
sqr-neg85.8%
associate-+l-85.8%
sub0-neg85.8%
neg-mul-185.8%
Simplified85.6%
associate-*r*85.6%
metadata-eval85.6%
distribute-rgt-neg-in85.6%
*-commutative85.6%
fma-neg85.6%
associate-*r*85.6%
*-commutative85.6%
associate-*l*85.6%
Applied egg-rr85.6%
if 1.6600000000000001e-72 < b Initial program 14.8%
sqr-neg14.8%
sqr-neg14.8%
associate-*l*14.8%
Simplified14.8%
Taylor expanded in b around inf 88.0%
Final simplification87.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.2e+80)
(/ b (/ a -0.6666666666666666))
(if (<= b 1.1e-72)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.2e+80) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 1.1e-72) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} 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.2d+80)) then
tmp = b / (a / (-0.6666666666666666d0))
else if (b <= 1.1d-72) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
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.2e+80) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 1.1e-72) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.2e+80: tmp = b / (a / -0.6666666666666666) elif b <= 1.1e-72: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.2e+80) tmp = Float64(b / Float64(a / -0.6666666666666666)); elseif (b <= 1.1e-72) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); 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.2e+80) tmp = b / (a / -0.6666666666666666); elseif (b <= 1.1e-72) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.2e+80], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.1e-72], 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[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{+80}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-72}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.1999999999999999e80Initial program 52.5%
neg-sub052.5%
sqr-neg52.5%
associate-+l-52.5%
sub0-neg52.5%
neg-mul-152.5%
Simplified52.6%
associate-*r*52.6%
metadata-eval52.6%
distribute-rgt-neg-in52.6%
*-commutative52.6%
fma-neg52.6%
associate-*r*52.6%
*-commutative52.6%
associate-*l*52.6%
Applied egg-rr52.6%
Taylor expanded in b around -inf 87.9%
associate-*r/88.1%
associate-/l*88.1%
Simplified88.1%
associate-/r/88.1%
Applied egg-rr88.1%
associate-*l/88.1%
*-commutative88.1%
associate-/l*88.2%
Applied egg-rr88.2%
if -1.1999999999999999e80 < b < 1.10000000000000001e-72Initial program 85.8%
sqr-neg85.8%
sqr-neg85.8%
associate-*l*85.8%
Simplified85.8%
if 1.10000000000000001e-72 < b Initial program 14.8%
sqr-neg14.8%
sqr-neg14.8%
associate-*l*14.8%
Simplified14.8%
Taylor expanded in b around inf 88.0%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-144)
(/ b (/ a -0.6666666666666666))
(if (<= b 3.7e-72)
(* (/ 0.3333333333333333 a) (- (sqrt (* c (* a -3.0))) b))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-144) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 3.7e-72) {
tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - b);
} 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 <= (-4.6d-144)) then
tmp = b / (a / (-0.6666666666666666d0))
else if (b <= 3.7d-72) then
tmp = (0.3333333333333333d0 / a) * (sqrt((c * (a * (-3.0d0)))) - b)
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 <= -4.6e-144) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 3.7e-72) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((c * (a * -3.0))) - b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-144: tmp = b / (a / -0.6666666666666666) elif b <= 3.7e-72: tmp = (0.3333333333333333 / a) * (math.sqrt((c * (a * -3.0))) - b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-144) tmp = Float64(b / Float64(a / -0.6666666666666666)); elseif (b <= 3.7e-72) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(c * Float64(a * -3.0))) - b)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e-144) tmp = b / (a / -0.6666666666666666); elseif (b <= 3.7e-72) tmp = (0.3333333333333333 / a) * (sqrt((c * (a * -3.0))) - b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-144], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.7e-72], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-144}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{-72}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{c \cdot \left(a \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.6e-144Initial program 71.3%
neg-sub071.3%
sqr-neg71.3%
associate-+l-71.3%
sub0-neg71.3%
neg-mul-171.3%
Simplified71.2%
associate-*r*71.2%
metadata-eval71.2%
distribute-rgt-neg-in71.2%
*-commutative71.2%
fma-neg71.2%
associate-*r*71.2%
*-commutative71.2%
associate-*l*71.2%
Applied egg-rr71.2%
Taylor expanded in b around -inf 79.5%
associate-*r/79.6%
associate-/l*79.5%
Simplified79.5%
associate-/r/79.5%
Applied egg-rr79.5%
associate-*l/79.6%
*-commutative79.6%
associate-/l*79.6%
Applied egg-rr79.6%
if -4.6e-144 < b < 3.6999999999999998e-72Initial program 77.8%
neg-sub077.8%
sqr-neg77.8%
associate-+l-77.8%
sub0-neg77.8%
neg-mul-177.8%
Simplified77.7%
associate-*r*77.7%
metadata-eval77.7%
distribute-rgt-neg-in77.7%
*-commutative77.7%
fma-neg77.7%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.7%
Applied egg-rr77.7%
Taylor expanded in b around 0 76.6%
*-commutative76.6%
*-commutative76.6%
*-commutative76.6%
associate-*l*76.5%
Simplified76.5%
expm1-log1p-u55.0%
expm1-udef18.3%
associate-/r/18.3%
associate-*r*18.3%
Applied egg-rr18.3%
expm1-def55.1%
expm1-log1p76.8%
*-commutative76.8%
associate-*r/76.7%
associate-*l/76.7%
associate-*l*76.6%
Simplified76.6%
if 3.6999999999999998e-72 < b Initial program 14.8%
sqr-neg14.8%
sqr-neg14.8%
associate-*l*14.8%
Simplified14.8%
Taylor expanded in b around inf 88.0%
Final simplification82.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-144)
(/ b (/ a -0.6666666666666666))
(if (<= b 6.8e-74)
(* 0.3333333333333333 (/ (- (sqrt (* (* a c) -3.0)) b) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-144) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 6.8e-74) {
tmp = 0.3333333333333333 * ((sqrt(((a * c) * -3.0)) - b) / 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 <= (-4.6d-144)) then
tmp = b / (a / (-0.6666666666666666d0))
else if (b <= 6.8d-74) then
tmp = 0.3333333333333333d0 * ((sqrt(((a * c) * (-3.0d0))) - b) / 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 <= -4.6e-144) {
tmp = b / (a / -0.6666666666666666);
} else if (b <= 6.8e-74) {
tmp = 0.3333333333333333 * ((Math.sqrt(((a * c) * -3.0)) - b) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-144: tmp = b / (a / -0.6666666666666666) elif b <= 6.8e-74: tmp = 0.3333333333333333 * ((math.sqrt(((a * c) * -3.0)) - b) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-144) tmp = Float64(b / Float64(a / -0.6666666666666666)); elseif (b <= 6.8e-74) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / 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 <= -4.6e-144) tmp = b / (a / -0.6666666666666666); elseif (b <= 6.8e-74) tmp = 0.3333333333333333 * ((sqrt(((a * c) * -3.0)) - b) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-144], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.8e-74], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-144}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-74}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.6e-144Initial program 71.3%
neg-sub071.3%
sqr-neg71.3%
associate-+l-71.3%
sub0-neg71.3%
neg-mul-171.3%
Simplified71.2%
associate-*r*71.2%
metadata-eval71.2%
distribute-rgt-neg-in71.2%
*-commutative71.2%
fma-neg71.2%
associate-*r*71.2%
*-commutative71.2%
associate-*l*71.2%
Applied egg-rr71.2%
Taylor expanded in b around -inf 79.5%
associate-*r/79.6%
associate-/l*79.5%
Simplified79.5%
associate-/r/79.5%
Applied egg-rr79.5%
associate-*l/79.6%
*-commutative79.6%
associate-/l*79.6%
Applied egg-rr79.6%
if -4.6e-144 < b < 6.8000000000000001e-74Initial program 77.8%
neg-sub077.8%
sqr-neg77.8%
associate-+l-77.8%
sub0-neg77.8%
neg-mul-177.8%
Simplified77.7%
associate-*r*77.7%
metadata-eval77.7%
distribute-rgt-neg-in77.7%
*-commutative77.7%
fma-neg77.7%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.7%
Applied egg-rr77.7%
Taylor expanded in b around 0 76.6%
*-commutative76.6%
*-commutative76.6%
*-commutative76.6%
associate-*l*76.5%
Simplified76.5%
associate-/r/76.7%
associate-*r*76.8%
Applied egg-rr76.8%
if 6.8000000000000001e-74 < b Initial program 14.8%
sqr-neg14.8%
sqr-neg14.8%
associate-*l*14.8%
Simplified14.8%
Taylor expanded in b around inf 88.0%
Final simplification82.2%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.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 <= (-1d-309)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.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 <= -1e-309) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.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 <= -1e-309) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 73.8%
sqr-neg73.8%
sqr-neg73.8%
associate-*l*73.7%
Simplified73.7%
Taylor expanded in b around -inf 65.6%
if -1.000000000000002e-309 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.1%
Simplified30.1%
Taylor expanded in b around inf 70.3%
Final simplification68.0%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-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 <= (-1d-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 <= -1e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-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 <= -1e-309) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-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 -1 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 73.8%
neg-sub073.8%
sqr-neg73.8%
associate-+l-73.8%
sub0-neg73.8%
neg-mul-173.8%
Simplified73.7%
associate-*r*73.7%
metadata-eval73.7%
distribute-rgt-neg-in73.7%
*-commutative73.7%
fma-neg73.7%
associate-*r*73.7%
*-commutative73.7%
associate-*l*73.7%
Applied egg-rr73.7%
Taylor expanded in b around -inf 65.2%
associate-*r/65.3%
associate-/l*65.3%
Simplified65.3%
associate-/r/65.3%
Applied egg-rr65.3%
if -1.000000000000002e-309 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.1%
Simplified30.1%
Taylor expanded in b around inf 70.3%
Final simplification67.9%
(FPCore (a b c) :precision binary64 (if (<= b 4e-309) (/ -0.6666666666666666 (/ a b)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4e-309) {
tmp = -0.6666666666666666 / (a / b);
} 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 <= 4d-309) then
tmp = (-0.6666666666666666d0) / (a / b)
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 <= 4e-309) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4e-309: tmp = -0.6666666666666666 / (a / b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4e-309) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4e-309) tmp = -0.6666666666666666 / (a / b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4e-309], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-309}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 3.9999999999999977e-309Initial program 73.8%
neg-sub073.8%
sqr-neg73.8%
associate-+l-73.8%
sub0-neg73.8%
neg-mul-173.8%
Simplified73.7%
associate-*r*73.7%
metadata-eval73.7%
distribute-rgt-neg-in73.7%
*-commutative73.7%
fma-neg73.7%
associate-*r*73.7%
*-commutative73.7%
associate-*l*73.7%
Applied egg-rr73.7%
Taylor expanded in b around -inf 65.2%
associate-*r/65.3%
associate-/l*65.3%
Simplified65.3%
if 3.9999999999999977e-309 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.1%
Simplified30.1%
Taylor expanded in b around inf 70.3%
Final simplification67.9%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (/ b (/ a -0.6666666666666666)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
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 <= (-1d-309)) 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 <= -1e-309) {
tmp = b / (a / -0.6666666666666666);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = b / (a / -0.6666666666666666) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(b / Float64(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 <= -1e-309) tmp = b / (a / -0.6666666666666666); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 73.8%
neg-sub073.8%
sqr-neg73.8%
associate-+l-73.8%
sub0-neg73.8%
neg-mul-173.8%
Simplified73.7%
associate-*r*73.7%
metadata-eval73.7%
distribute-rgt-neg-in73.7%
*-commutative73.7%
fma-neg73.7%
associate-*r*73.7%
*-commutative73.7%
associate-*l*73.7%
Applied egg-rr73.7%
Taylor expanded in b around -inf 65.2%
associate-*r/65.3%
associate-/l*65.3%
Simplified65.3%
associate-/r/65.3%
Applied egg-rr65.3%
associate-*l/65.3%
*-commutative65.3%
associate-/l*65.4%
Applied egg-rr65.4%
if -1.000000000000002e-309 < b Initial program 30.2%
sqr-neg30.2%
sqr-neg30.2%
associate-*l*30.1%
Simplified30.1%
Taylor expanded in b around inf 70.3%
Final simplification67.9%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 50.9%
sqr-neg50.9%
sqr-neg50.9%
associate-*l*50.9%
Simplified50.9%
Taylor expanded in b around inf 37.9%
Final simplification37.9%
herbie shell --seed 2023264
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))