
(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 -1.56e+88)
(* (/ b a) -0.6666666666666666)
(if (<= b 6.2e-36)
(/ (- (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 <= -1.56e+88) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 6.2e-36) {
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 <= (-1.56d+88)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 6.2d-36) 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 <= -1.56e+88) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 6.2e-36) {
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 <= -1.56e+88: tmp = (b / a) * -0.6666666666666666 elif b <= 6.2e-36: 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 <= -1.56e+88) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 6.2e-36) 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 <= -1.56e+88) tmp = (b / a) * -0.6666666666666666; elseif (b <= 6.2e-36) 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, -1.56e+88], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 6.2e-36], 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 -1.56 \cdot 10^{+88}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-36}:\\
\;\;\;\;\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 < -1.56000000000000008e88Initial program 49.0%
frac-2negN/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr49.0%
Taylor expanded in b around -inf
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6496.5%
Simplified96.5%
if -1.56000000000000008e88 < b < 6.1999999999999997e-36Initial program 79.5%
if 6.1999999999999997e-36 < b Initial program 14.3%
Taylor expanded in b around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6489.0%
Simplified89.0%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e+88)
(* (/ b a) -0.6666666666666666)
(if (<= b 1.8e-41)
(/ (- (sqrt (+ (* b b) (* a (* c -3.0)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+88) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (sqrt(((b * b) + (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 <= (-6.5d+88)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 1.8d-41) then
tmp = (sqrt(((b * b) + (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 <= -6.5e+88) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (Math.sqrt(((b * b) + (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 <= -6.5e+88: tmp = (b / a) * -0.6666666666666666 elif b <= 1.8e-41: tmp = (math.sqrt(((b * b) + (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 <= -6.5e+88) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 1.8e-41) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) + 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 <= -6.5e+88) tmp = (b / a) * -0.6666666666666666; elseif (b <= 1.8e-41) tmp = (sqrt(((b * b) + (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, -6.5e+88], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 1.8e-41], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(a * N[(c * -3.0), $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 -6.5 \cdot 10^{+88}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-41}:\\
\;\;\;\;\frac{\sqrt{b \cdot b + 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 < -6.5000000000000002e88Initial program 49.0%
frac-2negN/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr49.0%
Taylor expanded in b around -inf
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6496.5%
Simplified96.5%
if -6.5000000000000002e88 < b < 1.8e-41Initial program 79.5%
/-lowering-/.f64N/A
+-commutativeN/A
unsub-negN/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
sub-negN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
metadata-evalN/A
*-lowering-*.f6479.5%
Simplified79.5%
if 1.8e-41 < b Initial program 14.3%
Taylor expanded in b around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6489.0%
Simplified89.0%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e+94)
(* (/ b a) -0.6666666666666666)
(if (<= b 1.8e-41)
(* (- (sqrt (+ (* b b) (* a (* c -3.0)))) b) (/ 0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e+94) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (sqrt(((b * b) + (a * (c * -3.0)))) - b) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.7d+94)) then
tmp = (b / a) * (-0.6666666666666666d0)
else if (b <= 1.8d-41) then
tmp = (sqrt(((b * b) + (a * (c * (-3.0d0))))) - b) * (0.3333333333333333d0 / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e+94) {
tmp = (b / a) * -0.6666666666666666;
} else if (b <= 1.8e-41) {
tmp = (Math.sqrt(((b * b) + (a * (c * -3.0)))) - b) * (0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e+94: tmp = (b / a) * -0.6666666666666666 elif b <= 1.8e-41: tmp = (math.sqrt(((b * b) + (a * (c * -3.0)))) - b) * (0.3333333333333333 / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e+94) tmp = Float64(Float64(b / a) * -0.6666666666666666); elseif (b <= 1.8e-41) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(a * Float64(c * -3.0)))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.7e+94) tmp = (b / a) * -0.6666666666666666; elseif (b <= 1.8e-41) tmp = (sqrt(((b * b) + (a * (c * -3.0)))) - b) * (0.3333333333333333 / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e+94], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], If[LessEqual[b, 1.8e-41], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{+94}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-41}:\\
\;\;\;\;\left(\sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.7000000000000001e94Initial program 47.1%
frac-2negN/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr47.2%
Taylor expanded in b around -inf
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6496.3%
Simplified96.3%
if -1.7000000000000001e94 < b < 1.8e-41Initial program 79.8%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-evalN/A
+-commutativeN/A
unsub-negN/A
--lowering--.f64N/A
Applied egg-rr79.8%
if 1.8e-41 < b Initial program 14.3%
Taylor expanded in b around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6489.0%
Simplified89.0%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5.3e-62)
(* b (- (* (/ (/ c b) b) (- 0.0 -0.5)) (/ 0.6666666666666666 a)))
(if (<= b 8.6e-87)
(/ (- (sqrt (* c (* a -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-62) {
tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a));
} else if (b <= 8.6e-87) {
tmp = (sqrt((c * (a * -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.3d-62)) then
tmp = b * ((((c / b) / b) * (0.0d0 - (-0.5d0))) - (0.6666666666666666d0 / a))
else if (b <= 8.6d-87) then
tmp = (sqrt((c * (a * (-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.3e-62) {
tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a));
} else if (b <= 8.6e-87) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.3e-62: tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a)) elif b <= 8.6e-87: tmp = (math.sqrt((c * (a * -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.3e-62) tmp = Float64(b * Float64(Float64(Float64(Float64(c / b) / b) * Float64(0.0 - -0.5)) - Float64(0.6666666666666666 / a))); elseif (b <= 8.6e-87) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -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.3e-62) tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a)); elseif (b <= 8.6e-87) tmp = (sqrt((c * (a * -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.3e-62], N[(b * N[(N[(N[(N[(c / b), $MachinePrecision] / b), $MachinePrecision] * N[(0.0 - -0.5), $MachinePrecision]), $MachinePrecision] - N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-87], N[(N[(N[Sqrt[N[(c * N[(a * -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.3 \cdot 10^{-62}:\\
\;\;\;\;b \cdot \left(\frac{\frac{c}{b}}{b} \cdot \left(0 - -0.5\right) - \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.2999999999999997e-62Initial program 66.7%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f64N/A
neg-sub0N/A
--lowering--.f6485.9%
Simplified85.9%
if -5.2999999999999997e-62 < b < 8.59999999999999991e-87Initial program 78.0%
/-lowering-/.f64N/A
+-commutativeN/A
unsub-negN/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
sub-negN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
metadata-evalN/A
*-lowering-*.f6478.0%
Simplified78.0%
Taylor expanded in b around 0
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6472.7%
Simplified72.7%
if 8.59999999999999991e-87 < b Initial program 18.1%
Taylor expanded in b around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6483.3%
Simplified83.3%
Final simplification81.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.65e-60)
(* b (- (* (/ (/ c b) b) (- 0.0 -0.5)) (/ 0.6666666666666666 a)))
(if (<= b 8e-87)
(* (/ 0.3333333333333333 a) (- (sqrt (* a (* c -3.0))) b))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.65e-60) {
tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a));
} else if (b <= 8e-87) {
tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - b);
} 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.65d-60)) then
tmp = b * ((((c / b) / b) * (0.0d0 - (-0.5d0))) - (0.6666666666666666d0 / a))
else if (b <= 8d-87) then
tmp = (0.3333333333333333d0 / a) * (sqrt((a * (c * (-3.0d0)))) - b)
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.65e-60) {
tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a));
} else if (b <= 8e-87) {
tmp = (0.3333333333333333 / a) * (Math.sqrt((a * (c * -3.0))) - b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.65e-60: tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a)) elif b <= 8e-87: tmp = (0.3333333333333333 / a) * (math.sqrt((a * (c * -3.0))) - b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.65e-60) tmp = Float64(b * Float64(Float64(Float64(Float64(c / b) / b) * Float64(0.0 - -0.5)) - Float64(0.6666666666666666 / a))); elseif (b <= 8e-87) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(a * Float64(c * -3.0))) - b)); 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.65e-60) tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a)); elseif (b <= 8e-87) tmp = (0.3333333333333333 / a) * (sqrt((a * (c * -3.0))) - b); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.65e-60], N[(b * N[(N[(N[(N[(c / b), $MachinePrecision] / b), $MachinePrecision] * N[(0.0 - -0.5), $MachinePrecision]), $MachinePrecision] - N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-87], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{-60}:\\
\;\;\;\;b \cdot \left(\frac{\frac{c}{b}}{b} \cdot \left(0 - -0.5\right) - \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-87}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -3\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.6499999999999999e-60Initial program 66.7%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f64N/A
neg-sub0N/A
--lowering--.f6485.9%
Simplified85.9%
if -1.6499999999999999e-60 < b < 8.00000000000000014e-87Initial program 78.0%
/-lowering-/.f64N/A
+-commutativeN/A
unsub-negN/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
sub-negN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
metadata-evalN/A
*-lowering-*.f6478.0%
Simplified78.0%
Taylor expanded in b around 0
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6472.7%
Simplified72.7%
clear-numN/A
associate-/r/N/A
associate-/r*N/A
metadata-evalN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6472.5%
Applied egg-rr72.5%
if 8.00000000000000014e-87 < b Initial program 18.1%
Taylor expanded in b around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6483.3%
Simplified83.3%
Final simplification81.2%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* b (- (* (/ (/ c b) b) (- 0.0 -0.5)) (/ 0.6666666666666666 a))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (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-310)) then
tmp = b * ((((c / b) / b) * (0.0d0 - (-0.5d0))) - (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-310) {
tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(b * Float64(Float64(Float64(Float64(c / b) / b) * Float64(0.0 - -0.5)) - Float64(0.6666666666666666 / a))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = b * ((((c / b) / b) * (0.0 - -0.5)) - (0.6666666666666666 / a)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(b * N[(N[(N[(N[(c / b), $MachinePrecision] / b), $MachinePrecision] * N[(0.0 - -0.5), $MachinePrecision]), $MachinePrecision] - N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \left(\frac{\frac{c}{b}}{b} \cdot \left(0 - -0.5\right) - \frac{0.6666666666666666}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.8%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
associate-/r*N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f64N/A
neg-sub0N/A
--lowering--.f6467.0%
Simplified67.0%
if -9.999999999999969e-311 < b Initial program 34.8%
Taylor expanded in b around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6464.2%
Simplified64.2%
Final simplification65.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* (/ b a) -0.6666666666666666) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
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 <= (-1d-310)) 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 <= -1e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) 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 <= -1e-310) tmp = (b / a) * -0.6666666666666666; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], 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 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.8%
frac-2negN/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr70.8%
Taylor expanded in b around -inf
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6466.9%
Simplified66.9%
if -9.999999999999969e-311 < b Initial program 34.8%
Taylor expanded in b around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6464.2%
Simplified64.2%
(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 53.2%
frac-2negN/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr53.2%
Taylor expanded in b around -inf
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6435.6%
Simplified35.6%
(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 53.2%
Taylor expanded in b around -inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6435.6%
Simplified35.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6435.6%
Applied egg-rr35.6%
Final simplification35.6%
herbie shell --seed 2024150
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))