
(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 12 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 -3.5e+157)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 1.26e-61)
(/ (- (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 <= -3.5e+157) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 1.26e-61) {
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 <= (-3.5d+157)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 1.26d-61) 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 <= -3.5e+157) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 1.26e-61) {
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 <= -3.5e+157: tmp = ((b * 2.0) / -3.0) / a elif b <= 1.26e-61: 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 <= -3.5e+157) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 1.26e-61) 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 <= -3.5e+157) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 1.26e-61) 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, -3.5e+157], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.26e-61], 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 -3.5 \cdot 10^{+157}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-61}:\\
\;\;\;\;\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 < -3.50000000000000002e157Initial program 23.5%
sqr-neg23.5%
sqr-neg23.5%
associate-*l*23.5%
Simplified23.5%
frac-2neg23.5%
div-inv23.5%
Applied egg-rr23.5%
Taylor expanded in b around -inf 98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.5%
Simplified98.5%
associate-*r/98.6%
associate-*l/98.7%
metadata-eval98.7%
times-frac98.6%
*-commutative98.6%
associate-/r*98.8%
Applied egg-rr98.8%
if -3.50000000000000002e157 < b < 1.2599999999999999e-61Initial program 79.4%
if 1.2599999999999999e-61 < b Initial program 21.6%
sqr-neg21.6%
sqr-neg21.6%
associate-*l*21.6%
Simplified21.6%
Taylor expanded in b around inf 83.8%
*-commutative83.8%
Simplified83.8%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e+157)
(/ (/ (* b 2.0) -3.0) a)
(if (<= b 3.4e-62)
(/ (- (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 <= -3.5e+157) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.4e-62) {
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 <= (-3.5d+157)) then
tmp = ((b * 2.0d0) / (-3.0d0)) / a
else if (b <= 3.4d-62) 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 <= -3.5e+157) {
tmp = ((b * 2.0) / -3.0) / a;
} else if (b <= 3.4e-62) {
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 <= -3.5e+157: tmp = ((b * 2.0) / -3.0) / a elif b <= 3.4e-62: 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 <= -3.5e+157) tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a); elseif (b <= 3.4e-62) 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 <= -3.5e+157) tmp = ((b * 2.0) / -3.0) / a; elseif (b <= 3.4e-62) 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, -3.5e+157], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.4e-62], 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 -3.5 \cdot 10^{+157}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-62}:\\
\;\;\;\;\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 < -3.50000000000000002e157Initial program 23.5%
sqr-neg23.5%
sqr-neg23.5%
associate-*l*23.5%
Simplified23.5%
frac-2neg23.5%
div-inv23.5%
Applied egg-rr23.5%
Taylor expanded in b around -inf 98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.5%
Simplified98.5%
associate-*r/98.6%
associate-*l/98.7%
metadata-eval98.7%
times-frac98.6%
*-commutative98.6%
associate-/r*98.8%
Applied egg-rr98.8%
if -3.50000000000000002e157 < b < 3.39999999999999988e-62Initial program 79.4%
sqr-neg79.4%
sqr-neg79.4%
associate-*l*79.4%
Simplified79.4%
if 3.39999999999999988e-62 < b Initial program 21.6%
sqr-neg21.6%
sqr-neg21.6%
associate-*l*21.6%
Simplified21.6%
Taylor expanded in b around inf 83.8%
*-commutative83.8%
Simplified83.8%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e-56)
(* b (- (* 0.6666666666666666 (/ -1.0 a)) (* -0.5 (/ c (pow b 2.0)))))
(if (<= b 7.2e-61)
(/ (- (sqrt (* c (* -3.0 a))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e-56) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / pow(b, 2.0))));
} else if (b <= 7.2e-61) {
tmp = (sqrt((c * (-3.0 * a))) - 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.7d-56)) then
tmp = b * ((0.6666666666666666d0 * ((-1.0d0) / a)) - ((-0.5d0) * (c / (b ** 2.0d0))))
else if (b <= 7.2d-61) then
tmp = (sqrt((c * ((-3.0d0) * a))) - 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.7e-56) {
tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / Math.pow(b, 2.0))));
} else if (b <= 7.2e-61) {
tmp = (Math.sqrt((c * (-3.0 * a))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e-56: tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / math.pow(b, 2.0)))) elif b <= 7.2e-61: tmp = (math.sqrt((c * (-3.0 * a))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e-56) tmp = Float64(b * Float64(Float64(0.6666666666666666 * Float64(-1.0 / a)) - Float64(-0.5 * Float64(c / (b ^ 2.0))))); elseif (b <= 7.2e-61) tmp = Float64(Float64(sqrt(Float64(c * Float64(-3.0 * a))) - 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.7e-56) tmp = b * ((0.6666666666666666 * (-1.0 / a)) - (-0.5 * (c / (b ^ 2.0)))); elseif (b <= 7.2e-61) tmp = (sqrt((c * (-3.0 * a))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e-56], 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, 7.2e-61], N[(N[(N[Sqrt[N[(c * N[(-3.0 * a), $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.7 \cdot 10^{-56}:\\
\;\;\;\;b \cdot \left(0.6666666666666666 \cdot \frac{-1}{a} - -0.5 \cdot \frac{c}{{b}^{2}}\right)\\
\mathbf{elif}\;b \leq 7.2 \cdot 10^{-61}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.69999999999999991e-56Initial program 59.1%
sqr-neg59.1%
sqr-neg59.1%
associate-*l*59.1%
Simplified59.1%
Taylor expanded in b around -inf 88.9%
if -1.69999999999999991e-56 < b < 7.20000000000000028e-61Initial program 70.5%
sqr-neg70.5%
sqr-neg70.5%
associate-*l*70.4%
Simplified70.4%
Taylor expanded in b around 0 65.8%
*-commutative65.8%
associate-*l*65.8%
sqrt-prod46.8%
Applied egg-rr46.8%
+-commutative46.8%
unsub-neg46.8%
sqrt-unprod65.8%
*-commutative65.8%
associate-*l*65.9%
Applied egg-rr65.9%
if 7.20000000000000028e-61 < b Initial program 21.6%
sqr-neg21.6%
sqr-neg21.6%
associate-*l*21.6%
Simplified21.6%
Taylor expanded in b around inf 83.8%
*-commutative83.8%
Simplified83.8%
Final simplification80.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.8e-54)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 1.6e-62)
(/ (- (sqrt (* c (* -3.0 a))) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.8e-54) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 1.6e-62) {
tmp = (sqrt((c * (-3.0 * a))) - 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 <= (-5.8d-54)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 1.6d-62) then
tmp = (sqrt((c * ((-3.0d0) * a))) - 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 <= -5.8e-54) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 1.6e-62) {
tmp = (Math.sqrt((c * (-3.0 * a))) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.8e-54: tmp = ((b * 2.0) / a) / -3.0 elif b <= 1.6e-62: tmp = (math.sqrt((c * (-3.0 * a))) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.8e-54) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 1.6e-62) tmp = Float64(Float64(sqrt(Float64(c * Float64(-3.0 * a))) - 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 <= -5.8e-54) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 1.6e-62) tmp = (sqrt((c * (-3.0 * a))) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.8e-54], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 1.6e-62], N[(N[(N[Sqrt[N[(c * N[(-3.0 * a), $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 -5.8 \cdot 10^{-54}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-62}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.80000000000000029e-54Initial program 59.1%
sqr-neg59.1%
sqr-neg59.1%
associate-*l*59.1%
Simplified59.1%
frac-2neg59.1%
div-inv59.0%
Applied egg-rr59.0%
Taylor expanded in b around -inf 88.3%
*-commutative88.3%
associate-*l/88.3%
associate-/l*88.2%
Simplified88.2%
associate-*r/88.3%
associate-*l/88.3%
metadata-eval88.3%
times-frac88.4%
associate-/r*88.5%
Applied egg-rr88.5%
if -5.80000000000000029e-54 < b < 1.60000000000000011e-62Initial program 70.5%
sqr-neg70.5%
sqr-neg70.5%
associate-*l*70.4%
Simplified70.4%
Taylor expanded in b around 0 65.8%
*-commutative65.8%
associate-*l*65.8%
sqrt-prod46.8%
Applied egg-rr46.8%
+-commutative46.8%
unsub-neg46.8%
sqrt-unprod65.8%
*-commutative65.8%
associate-*l*65.9%
Applied egg-rr65.9%
if 1.60000000000000011e-62 < b Initial program 21.6%
sqr-neg21.6%
sqr-neg21.6%
associate-*l*21.6%
Simplified21.6%
Taylor expanded in b around inf 83.8%
*-commutative83.8%
Simplified83.8%
Final simplification80.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e-56)
(/ (/ (* b 2.0) a) -3.0)
(if (<= b 9.5e-61)
(* (- b (sqrt (* -3.0 (* a c)))) (/ -0.3333333333333333 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-56) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 9.5e-61) {
tmp = (b - sqrt((-3.0 * (a * c)))) * (-0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.05d-56)) then
tmp = ((b * 2.0d0) / a) / (-3.0d0)
else if (b <= 9.5d-61) then
tmp = (b - sqrt(((-3.0d0) * (a * c)))) * ((-0.3333333333333333d0) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-56) {
tmp = ((b * 2.0) / a) / -3.0;
} else if (b <= 9.5e-61) {
tmp = (b - Math.sqrt((-3.0 * (a * c)))) * (-0.3333333333333333 / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-56: tmp = ((b * 2.0) / a) / -3.0 elif b <= 9.5e-61: tmp = (b - math.sqrt((-3.0 * (a * c)))) * (-0.3333333333333333 / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-56) tmp = Float64(Float64(Float64(b * 2.0) / a) / -3.0); elseif (b <= 9.5e-61) tmp = Float64(Float64(b - sqrt(Float64(-3.0 * Float64(a * c)))) * Float64(-0.3333333333333333 / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-56) tmp = ((b * 2.0) / a) / -3.0; elseif (b <= 9.5e-61) tmp = (b - sqrt((-3.0 * (a * c)))) * (-0.3333333333333333 / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-56], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 9.5e-61], N[(N[(b - N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-61}:\\
\;\;\;\;\left(b - \sqrt{-3 \cdot \left(a \cdot c\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.05000000000000003e-56Initial program 59.1%
sqr-neg59.1%
sqr-neg59.1%
associate-*l*59.1%
Simplified59.1%
frac-2neg59.1%
div-inv59.0%
Applied egg-rr59.0%
Taylor expanded in b around -inf 88.3%
*-commutative88.3%
associate-*l/88.3%
associate-/l*88.2%
Simplified88.2%
associate-*r/88.3%
associate-*l/88.3%
metadata-eval88.3%
times-frac88.4%
associate-/r*88.5%
Applied egg-rr88.5%
if -1.05000000000000003e-56 < b < 9.49999999999999986e-61Initial program 70.5%
sqr-neg70.5%
sqr-neg70.5%
associate-*l*70.4%
Simplified70.4%
frac-2neg70.4%
div-inv70.4%
Applied egg-rr70.4%
Taylor expanded in a around 0 70.3%
Taylor expanded in b around 0 65.7%
*-commutative65.7%
Simplified65.7%
if 9.49999999999999986e-61 < b Initial program 21.6%
sqr-neg21.6%
sqr-neg21.6%
associate-*l*21.6%
Simplified21.6%
Taylor expanded in b around inf 83.8%
*-commutative83.8%
Simplified83.8%
Final simplification80.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (/ (* b 2.0) a) -3.0) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((b * 2.0) / 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 <= (-5d-310)) then
tmp = ((b * 2.0d0) / 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 <= -5e-310) {
tmp = ((b * 2.0) / a) / -3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((b * 2.0) / a) / -3.0 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(b * 2.0) / 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 <= -5e-310) tmp = ((b * 2.0) / a) / -3.0; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(b * 2.0), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 63.4%
sqr-neg63.4%
sqr-neg63.4%
associate-*l*63.4%
Simplified63.4%
frac-2neg63.4%
div-inv63.3%
Applied egg-rr63.2%
Taylor expanded in b around -inf 67.3%
*-commutative67.3%
associate-*l/67.3%
associate-/l*67.3%
Simplified67.3%
associate-*r/67.3%
associate-*l/67.3%
metadata-eval67.3%
times-frac67.4%
associate-/r*67.5%
Applied egg-rr67.5%
if -4.999999999999985e-310 < b Initial program 32.2%
sqr-neg32.2%
sqr-neg32.2%
associate-*l*32.1%
Simplified32.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (/ (* b 2.0) -3.0) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = ((b * 2.0) / -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 <= (-5d-310)) then
tmp = ((b * 2.0d0) / (-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 <= -5e-310) {
tmp = ((b * 2.0) / -3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = ((b * 2.0) / -3.0) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(b * 2.0) / -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 <= -5e-310) tmp = ((b * 2.0) / -3.0) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 63.4%
sqr-neg63.4%
sqr-neg63.4%
associate-*l*63.4%
Simplified63.4%
frac-2neg63.4%
div-inv63.3%
Applied egg-rr63.2%
Taylor expanded in b around -inf 67.3%
*-commutative67.3%
associate-*l/67.3%
associate-/l*67.3%
Simplified67.3%
associate-*r/67.3%
associate-*l/67.3%
metadata-eval67.3%
times-frac67.4%
*-commutative67.4%
associate-/r*67.5%
Applied egg-rr67.5%
if -4.999999999999985e-310 < b Initial program 32.2%
sqr-neg32.2%
sqr-neg32.2%
associate-*l*32.1%
Simplified32.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (* a -1.5)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / (a * -1.5) else: tmp = (c / b) * -0.5 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 / b) * -0.5); 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 / b) * -0.5; 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 / b), $MachinePrecision] * -0.5), $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}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 63.4%
sqr-neg63.4%
sqr-neg63.4%
associate-*l*63.4%
Simplified63.4%
frac-2neg63.4%
div-inv63.3%
Applied egg-rr63.2%
Taylor expanded in b around -inf 67.3%
*-commutative67.3%
associate-*l/67.3%
associate-/l*67.3%
Simplified67.3%
clear-num67.2%
un-div-inv67.4%
div-inv67.4%
metadata-eval67.4%
Applied egg-rr67.4%
if -4.999999999999985e-310 < b Initial program 32.2%
sqr-neg32.2%
sqr-neg32.2%
associate-*l*32.1%
Simplified32.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* (/ b a) -0.6666666666666666) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b / a) * -0.6666666666666666; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 63.4%
sqr-neg63.4%
sqr-neg63.4%
associate-*l*63.4%
Simplified63.4%
Taylor expanded in b around -inf 67.3%
*-commutative67.3%
Simplified67.3%
if -4.999999999999985e-310 < b Initial program 32.2%
sqr-neg32.2%
sqr-neg32.2%
associate-*l*32.1%
Simplified32.1%
Taylor expanded in b around inf 67.5%
*-commutative67.5%
Simplified67.5%
(FPCore (a b c) :precision binary64 (if (<= b 7.8e-302) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.8e-302) {
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 <= 7.8d-302) 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 <= 7.8e-302) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.8e-302: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.8e-302) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.8e-302) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.8e-302], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.8 \cdot 10^{-302}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 7.7999999999999998e-302Initial program 63.4%
sqr-neg63.4%
sqr-neg63.4%
associate-*l*63.4%
Simplified63.4%
Taylor expanded in b around -inf 67.3%
*-commutative67.3%
Simplified67.3%
if 7.7999999999999998e-302 < b Initial program 32.2%
sqr-neg32.2%
sqr-neg32.2%
associate-*l*32.1%
Simplified32.1%
Taylor expanded in c around 0 60.2%
fmm-def60.2%
associate-/l*63.8%
associate-*r/63.8%
metadata-eval63.8%
distribute-neg-frac63.8%
metadata-eval63.8%
Simplified63.8%
Taylor expanded in a around 0 67.3%
(FPCore (a b c) :precision binary64 (if (<= b 1e-309) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1e-309) {
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 <= 1d-309) 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 <= 1e-309) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1e-309: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / 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(c * Float64(-0.5 / 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 = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1e-309], 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 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 1.000000000000002e-309Initial program 63.4%
sqr-neg63.4%
sqr-neg63.4%
associate-*l*63.4%
Simplified63.4%
frac-2neg63.4%
div-inv63.3%
Applied egg-rr63.2%
Taylor expanded in b around -inf 67.3%
*-commutative67.3%
associate-*l/67.3%
associate-/l*67.3%
Simplified67.3%
if 1.000000000000002e-309 < b Initial program 32.2%
sqr-neg32.2%
sqr-neg32.2%
associate-*l*32.1%
Simplified32.1%
Taylor expanded in c around 0 60.2%
fmm-def60.2%
associate-/l*63.8%
associate-*r/63.8%
metadata-eval63.8%
distribute-neg-frac63.8%
metadata-eval63.8%
Simplified63.8%
Taylor expanded in a around 0 67.3%
(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 48.4%
sqr-neg48.4%
sqr-neg48.4%
associate-*l*48.3%
Simplified48.3%
frac-2neg48.3%
div-inv48.3%
Applied egg-rr48.3%
Taylor expanded in b around -inf 36.2%
*-commutative36.2%
associate-*l/36.2%
associate-/l*36.2%
Simplified36.2%
herbie shell --seed 2024170
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))