
(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 -1e+153)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 8.2e-57)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(*
c
(fma
c
(* a (fma a (* c (/ -0.5625 (pow b 5.0))) (/ -0.375 (* b (* b b)))))
(/ -0.5 b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+153) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 8.2e-57) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = c * fma(c, (a * fma(a, (c * (-0.5625 / pow(b, 5.0))), (-0.375 / (b * (b * b))))), (-0.5 / b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e+153) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 8.2e-57) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(c * fma(c, Float64(a * fma(a, Float64(c * Float64(-0.5625 / (b ^ 5.0))), Float64(-0.375 / Float64(b * Float64(b * b))))), Float64(-0.5 / b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e+153], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.2e-57], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(c * N[(c * N[(a * N[(a * N[(c * N[(-0.5625 / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.375 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+153}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-57}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \mathsf{fma}\left(c, a \cdot \mathsf{fma}\left(a, c \cdot \frac{-0.5625}{{b}^{5}}, \frac{-0.375}{b \cdot \left(b \cdot b\right)}\right), \frac{-0.5}{b}\right)\\
\end{array}
\end{array}
if b < -1e153Initial program 31.7%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6492.6
Simplified92.6%
if -1e153 < b < 8.2000000000000003e-57Initial program 84.7%
if 8.2000000000000003e-57 < b Initial program 13.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6413.7
Simplified13.7%
Taylor expanded in c around 0
lower-*.f64N/A
sub-negN/A
+-commutativeN/A
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
lower-fma.f64N/A
Simplified78.4%
Taylor expanded in a around 0
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.6
Simplified85.6%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+153)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.25e-42)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* (/ c b) (fma -0.375 (* a (/ c (* b b))) -0.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+153) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.25e-42) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = (c / b) * fma(-0.375, (a * (c / (b * b))), -0.5);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e+153) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.25e-42) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * fma(-0.375, Float64(a * Float64(c / Float64(b * b))), -0.5)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e+153], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.25e-42], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * N[(-0.375 * N[(a * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+153}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.25 \cdot 10^{-42}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot \mathsf{fma}\left(-0.375, a \cdot \frac{c}{b \cdot b}, -0.5\right)\\
\end{array}
\end{array}
if b < -1e153Initial program 31.7%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6492.6
Simplified92.6%
if -1e153 < b < 2.25e-42Initial program 84.2%
if 2.25e-42 < b Initial program 12.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6412.9
Simplified12.9%
Taylor expanded in c around 0
lower-*.f64N/A
sub-negN/A
+-commutativeN/A
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
lower-fma.f64N/A
Simplified78.9%
Taylor expanded in c around 0
sub-negN/A
distribute-rgt-inN/A
associate-*r/N/A
associate-*l/N/A
unpow3N/A
unpow2N/A
times-fracN/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*l/N/A
associate-*r/N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-/.f64N/A
associate-/l*N/A
Simplified85.9%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+153)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.25e-42)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (* 3.0 a))
(* (/ c b) (fma -0.375 (* a (/ c (* b b))) -0.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+153) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.25e-42) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (3.0 * a);
} else {
tmp = (c / b) * fma(-0.375, (a * (c / (b * b))), -0.5);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e+153) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.25e-42) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * fma(-0.375, Float64(a * Float64(c / Float64(b * b))), -0.5)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e+153], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.25e-42], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * N[(-0.375 * N[(a * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+153}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.25 \cdot 10^{-42}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot \mathsf{fma}\left(-0.375, a \cdot \frac{c}{b \cdot b}, -0.5\right)\\
\end{array}
\end{array}
if b < -1e153Initial program 31.7%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6492.6
Simplified92.6%
if -1e153 < b < 2.25e-42Initial program 84.2%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6484.2
Simplified84.2%
if 2.25e-42 < b Initial program 12.9%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6412.9
Simplified12.9%
Taylor expanded in c around 0
lower-*.f64N/A
sub-negN/A
+-commutativeN/A
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
lower-fma.f64N/A
Simplified78.9%
Taylor expanded in c around 0
sub-negN/A
distribute-rgt-inN/A
associate-*r/N/A
associate-*l/N/A
unpow3N/A
unpow2N/A
times-fracN/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*l/N/A
associate-*r/N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-/.f64N/A
associate-/l*N/A
Simplified85.9%
Final simplification85.7%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e-272) (/ (* b -2.0) (* 3.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
tmp = (b * -2.0) / (3.0 * 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 * (-2.0d0)) / (3.0d0 * 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 * -2.0) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e-272: tmp = (b * -2.0) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e-272) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * 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 <= 5.1e-272) tmp = (b * -2.0) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e-272], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $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 \cdot -2}{3 \cdot a}\\
\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-*.f6455.6
Simplified55.6%
if 5.0999999999999998e-272 < b Initial program 24.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6424.6
Simplified24.6%
Taylor expanded in b around inf
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 (/ 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 / Float64(-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 <= 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[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.1 \cdot 10^{-272}:\\
\;\;\;\;b \cdot \frac{0.6666666666666666}{-a}\\
\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
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f6453.4
Simplified53.4%
Taylor expanded in c around 0
lower-/.f6455.5
Simplified55.5%
if 5.0999999999999998e-272 < b Initial program 24.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6424.6
Simplified24.6%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/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(Float64(b * -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 <= 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[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $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 \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 5.0999999999999998e-272Initial program 78.3%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6478.3
Simplified78.3%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6455.5
Simplified55.5%
if 5.0999999999999998e-272 < b Initial program 24.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6424.6
Simplified24.6%
Taylor expanded in b around inf
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 -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(Float64(b * -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[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $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 \cdot -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 a around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6478.3
Simplified78.3%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6455.5
Simplified55.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) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e-272) {
tmp = -0.6666666666666666 * (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 <= 5.1d-272) then
tmp = (-0.6666666666666666d0) * (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 <= 5.1e-272) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e-272: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e-272) tmp = Float64(-0.6666666666666666 * Float64(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 <= 5.1e-272) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e-272], N[(-0.6666666666666666 * N[(b / 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}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{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%
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 (* -0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.6666666666666666d0) * (b / a)
end function
public static double code(double a, double b, double c) {
return -0.6666666666666666 * (b / a);
}
def code(a, b, c): return -0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(-0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = -0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 51.5%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6429.1
Simplified29.1%
Final simplification29.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)))