
(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 -3.6e+143)
(/ b (* a -1.5))
(if (<= b 8.6e-43)
(/ (/ (- b (sqrt (fma b b (* (* a c) -3.0)))) a) -3.0)
(* c (fma -0.375 (* c (/ a (* b (* b b)))) (/ -0.5 b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+143) {
tmp = b / (a * -1.5);
} else if (b <= 8.6e-43) {
tmp = ((b - sqrt(fma(b, b, ((a * c) * -3.0)))) / a) / -3.0;
} else {
tmp = c * fma(-0.375, (c * (a / (b * (b * b)))), (-0.5 / b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+143) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 8.6e-43) tmp = Float64(Float64(Float64(b - sqrt(fma(b, b, Float64(Float64(a * c) * -3.0)))) / a) / -3.0); else tmp = Float64(c * fma(-0.375, Float64(c * Float64(a / Float64(b * Float64(b * b)))), Float64(-0.5 / b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+143], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-43], N[(N[(N[(b - N[Sqrt[N[(b * b + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(c * N[(-0.375 * N[(c * N[(a / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-43}:\\
\;\;\;\;\frac{\frac{b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \mathsf{fma}\left(-0.375, c \cdot \frac{a}{b \cdot \left(b \cdot b\right)}, \frac{-0.5}{b}\right)\\
\end{array}
\end{array}
if b < -3.5999999999999999e143Initial program 39.0%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.1
Simplified93.1%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6493.2
Applied egg-rr93.2%
clear-numN/A
un-div-invN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval93.4
Applied egg-rr93.4%
if -3.5999999999999999e143 < b < 8.59999999999999927e-43Initial program 83.8%
Applied egg-rr83.9%
if 8.59999999999999927e-43 < b Initial program 12.9%
Taylor expanded in c around 0
sub-negN/A
distribute-lft-inN/A
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
distribute-lft-inN/A
lower-*.f64N/A
associate-*r/N/A
associate-*l/N/A
associate-*r*N/A
associate-*r/N/A
lower-fma.f64N/A
Simplified85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e+143)
(/ b (* a -1.5))
(if (<= b 8.6e-43)
(* (- b (sqrt (fma b b (* (* a c) -3.0)))) (/ -0.3333333333333333 a))
(* c (fma -0.375 (* c (/ a (* b (* b b)))) (/ -0.5 b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+143) {
tmp = b / (a * -1.5);
} else if (b <= 8.6e-43) {
tmp = (b - sqrt(fma(b, b, ((a * c) * -3.0)))) * (-0.3333333333333333 / a);
} else {
tmp = c * fma(-0.375, (c * (a / (b * (b * b)))), (-0.5 / b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+143) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 8.6e-43) tmp = Float64(Float64(b - sqrt(fma(b, b, Float64(Float64(a * c) * -3.0)))) * Float64(-0.3333333333333333 / a)); else tmp = Float64(c * fma(-0.375, Float64(c * Float64(a / Float64(b * Float64(b * b)))), Float64(-0.5 / b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+143], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.6e-43], N[(N[(b - N[Sqrt[N[(b * b + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-0.375 * N[(c * N[(a / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-43}:\\
\;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \mathsf{fma}\left(-0.375, c \cdot \frac{a}{b \cdot \left(b \cdot b\right)}, \frac{-0.5}{b}\right)\\
\end{array}
\end{array}
if b < -3.5999999999999999e143Initial program 39.0%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.1
Simplified93.1%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6493.2
Applied egg-rr93.2%
clear-numN/A
un-div-invN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval93.4
Applied egg-rr93.4%
if -3.5999999999999999e143 < b < 8.59999999999999927e-43Initial program 83.8%
Applied egg-rr83.8%
if 8.59999999999999927e-43 < b Initial program 12.9%
Taylor expanded in c around 0
sub-negN/A
distribute-lft-inN/A
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
distribute-lft-inN/A
lower-*.f64N/A
associate-*r/N/A
associate-*l/N/A
associate-*r*N/A
associate-*r/N/A
lower-fma.f64N/A
Simplified85.9%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+153)
(/ b (* a -1.5))
(if (<= b 1.15e-61)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+153) {
tmp = b / (a * -1.5);
} else if (b <= 1.15e-61) {
tmp = (sqrt(((b * b) - (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 <= (-1d+153)) then
tmp = b / (a * (-1.5d0))
else if (b <= 1.15d-61) then
tmp = (sqrt(((b * b) - (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 <= -1e+153) {
tmp = b / (a * -1.5);
} else if (b <= 1.15e-61) {
tmp = (Math.sqrt(((b * b) - (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 <= -1e+153: tmp = b / (a * -1.5) elif b <= 1.15e-61: tmp = (math.sqrt(((b * b) - (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 <= -1e+153) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.15e-61) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - 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 <= -1e+153) tmp = b / (a * -1.5); elseif (b <= 1.15e-61) tmp = (sqrt(((b * b) - (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, -1e+153], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e-61], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 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 -1 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-61}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 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 < -1e153Initial program 31.7%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6492.4
Simplified92.4%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6492.4
Applied egg-rr92.4%
clear-numN/A
un-div-invN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval92.6
Applied egg-rr92.6%
if -1e153 < b < 1.14999999999999996e-61Initial program 84.7%
if 1.14999999999999996e-61 < b Initial program 13.6%
Applied egg-rr13.7%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.2
Simplified85.2%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e+143)
(/ b (* a -1.5))
(if (<= b 1.15e-61)
(* (- b (sqrt (fma b b (* (* a c) -3.0)))) (/ -0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+143) {
tmp = b / (a * -1.5);
} else if (b <= 1.15e-61) {
tmp = (b - sqrt(fma(b, b, ((a * c) * -3.0)))) * (-0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+143) tmp = Float64(b / Float64(a * -1.5)); elseif (b <= 1.15e-61) tmp = Float64(Float64(b - sqrt(fma(b, b, Float64(Float64(a * c) * -3.0)))) * Float64(-0.3333333333333333 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+143], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e-61], N[(N[(b - N[Sqrt[N[(b * b + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 -3.6 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-61}:\\
\;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.5999999999999999e143Initial program 39.0%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.1
Simplified93.1%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6493.2
Applied egg-rr93.2%
clear-numN/A
un-div-invN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval93.4
Applied egg-rr93.4%
if -3.5999999999999999e143 < b < 1.14999999999999996e-61Initial program 84.3%
Applied egg-rr84.3%
if 1.14999999999999996e-61 < b Initial program 13.6%
Applied egg-rr13.7%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.2
Simplified85.2%
Final simplification85.7%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e-272) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
tmp = b / (a * -1.5);
} 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.1d-272) then
tmp = b / (a * (-1.5d0))
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.1e-272) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e-272: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e-272) tmp = Float64(b / Float64(a * -1.5)); 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.1e-272) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e-272], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.1 \cdot 10^{-272}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 5.0999999999999998e-272Initial program 78.3%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.4
Simplified55.4%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6455.5
Applied egg-rr55.5%
clear-numN/A
un-div-invN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval55.6
Applied egg-rr55.6%
if 5.0999999999999998e-272 < b Initial program 24.6%
Applied egg-rr24.6%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6472.0
Simplified72.0%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e-272) (/ b (* a -1.5)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
tmp = b / (a * -1.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 <= 5.1d-272) then
tmp = b / (a * (-1.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 <= 5.1e-272) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e-272: tmp = b / (a * -1.5) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e-272) tmp = Float64(b / Float64(a * -1.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 <= 5.1e-272) tmp = b / (a * -1.5); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e-272], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.1 \cdot 10^{-272}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 5.0999999999999998e-272Initial program 78.3%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.4
Simplified55.4%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6455.5
Applied egg-rr55.5%
clear-numN/A
un-div-invN/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval55.6
Applied egg-rr55.6%
if 5.0999999999999998e-272 < b Initial program 24.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6472.0
Simplified72.0%
Final simplification63.8%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e-272) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
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 <= 5.1d-272) 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 <= 5.1e-272) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e-272: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e-272) 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 <= 5.1e-272) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e-272], 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 5.1 \cdot 10^{-272}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 5.0999999999999998e-272Initial program 78.3%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.4
Simplified55.4%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6455.5
Applied egg-rr55.5%
if 5.0999999999999998e-272 < b Initial program 24.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6472.0
Simplified72.0%
Final simplification63.7%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e-272) (* b (/ -0.6666666666666666 a)) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
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 <= 5.1d-272) 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 <= 5.1e-272) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e-272: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e-272) 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 <= 5.1e-272) tmp = b * (-0.6666666666666666 / a); else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e-272], 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 5.1 \cdot 10^{-272}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < 5.0999999999999998e-272Initial program 78.3%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.4
Simplified55.4%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6455.5
Applied egg-rr55.5%
if 5.0999999999999998e-272 < b Initial program 24.6%
Applied egg-rr20.1%
Taylor expanded in b around inf
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f643.2
Simplified3.2%
Taylor expanded in c around inf
lower-*.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f643.3
Simplified3.3%
Taylor expanded in b around 0
lower-/.f6471.8
Simplified71.8%
(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 51.5%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6429.1
Simplified29.1%
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6429.1
Applied egg-rr29.1%
herbie shell --seed 2024215
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))