
(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 -5.6e+159)
(/ (* -2.0 b) (* a 3.0))
(if (<= b 2.3e-60)
(/ (/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) a) 3.0)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.6e+159) {
tmp = (-2.0 * b) / (a * 3.0);
} else if (b <= 2.3e-60) {
tmp = ((sqrt(fma((-3.0 * c), a, (b * b))) - b) / a) / 3.0;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.6e+159) tmp = Float64(Float64(-2.0 * b) / Float64(a * 3.0)); elseif (b <= 2.3e-60) tmp = Float64(Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / a) / 3.0); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.6e+159], N[(N[(-2.0 * b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-60], N[(N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{+159}:\\
\;\;\;\;\frac{-2 \cdot b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.6000000000000002e159Initial program 40.5%
Taylor expanded in b around -inf
lower-*.f6497.6
Applied rewrites97.6%
if -5.6000000000000002e159 < b < 2.3000000000000001e-60Initial program 83.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites84.6%
if 2.3000000000000001e-60 < b Initial program 14.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.6
Applied rewrites91.6%
Final simplification89.3%
(FPCore (a b c)
:precision binary64
(if (<= b -5.6e+159)
(/ (* -2.0 b) (* a 3.0))
(if (<= b 2.3e-60)
(* (/ 0.3333333333333333 a) (- (sqrt (fma (* -3.0 c) a (* b b))) b))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.6e+159) {
tmp = (-2.0 * b) / (a * 3.0);
} else if (b <= 2.3e-60) {
tmp = (0.3333333333333333 / a) * (sqrt(fma((-3.0 * c), a, (b * b))) - b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.6e+159) tmp = Float64(Float64(-2.0 * b) / Float64(a * 3.0)); elseif (b <= 2.3e-60) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.6e+159], N[(N[(-2.0 * b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-60], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{+159}:\\
\;\;\;\;\frac{-2 \cdot b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.6000000000000002e159Initial program 40.5%
Taylor expanded in b around -inf
lower-*.f6497.6
Applied rewrites97.6%
if -5.6000000000000002e159 < b < 2.3000000000000001e-60Initial program 83.9%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval83.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6483.7
Applied rewrites84.5%
if 2.3000000000000001e-60 < b Initial program 14.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.6
Applied rewrites91.6%
Final simplification89.3%
(FPCore (a b c)
:precision binary64
(if (<= b -4e-16)
(* (fma (/ c (* b b)) -0.5 (/ 0.6666666666666666 a)) (- b))
(if (<= b 2.3e-60)
(* (/ (- (sqrt (* (* c a) -3.0)) b) a) 0.3333333333333333)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-16) {
tmp = fma((c / (b * b)), -0.5, (0.6666666666666666 / a)) * -b;
} else if (b <= 2.3e-60) {
tmp = ((sqrt(((c * a) * -3.0)) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e-16) tmp = Float64(fma(Float64(c / Float64(b * b)), -0.5, Float64(0.6666666666666666 / a)) * Float64(-b)); elseif (b <= 2.3e-60) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e-16], N[(N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * -0.5 + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision] * (-b)), $MachinePrecision], If[LessEqual[b, 2.3e-60], N[(N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right) \cdot \left(-b\right)\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.9999999999999999e-16Initial program 66.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites66.9%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6491.2
Applied rewrites91.2%
if -3.9999999999999999e-16 < b < 2.3000000000000001e-60Initial program 78.3%
Taylor expanded in c around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.2
Applied rewrites74.2%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites75.3%
if 2.3000000000000001e-60 < b Initial program 14.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.6
Applied rewrites91.6%
Final simplification86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4e-16)
(fma (/ b a) -0.6666666666666666 (* 0.5 (/ c b)))
(if (<= b 2.3e-60)
(* (/ (- (sqrt (* (* c a) -3.0)) b) a) 0.3333333333333333)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-16) {
tmp = fma((b / a), -0.6666666666666666, (0.5 * (c / b)));
} else if (b <= 2.3e-60) {
tmp = ((sqrt(((c * a) * -3.0)) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e-16) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(0.5 * Float64(c / b))); elseif (b <= 2.3e-60) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e-16], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-60], N[(N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.6666666666666666, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.9999999999999999e-16Initial program 66.8%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6491.2
Applied rewrites91.2%
Taylor expanded in c around 0
Applied rewrites91.1%
if -3.9999999999999999e-16 < b < 2.3000000000000001e-60Initial program 78.3%
Taylor expanded in c around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.2
Applied rewrites74.2%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites75.3%
if 2.3000000000000001e-60 < b Initial program 14.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.6
Applied rewrites91.6%
Final simplification86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4e-16)
(fma (/ b a) -0.6666666666666666 (* 0.5 (/ c b)))
(if (<= b 2.3e-60)
(* (- (sqrt (* (* c a) -3.0)) b) (/ 0.3333333333333333 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-16) {
tmp = fma((b / a), -0.6666666666666666, (0.5 * (c / b)));
} else if (b <= 2.3e-60) {
tmp = (sqrt(((c * a) * -3.0)) - b) * (0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e-16) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(0.5 * Float64(c / b))); elseif (b <= 2.3e-60) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e-16], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-60], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.6666666666666666, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;\left(\sqrt{\left(c \cdot a\right) \cdot -3} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.9999999999999999e-16Initial program 66.8%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6491.2
Applied rewrites91.2%
Taylor expanded in c around 0
Applied rewrites91.1%
if -3.9999999999999999e-16 < b < 2.3000000000000001e-60Initial program 78.3%
Taylor expanded in c around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.2
Applied rewrites74.2%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6475.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6475.2
Applied rewrites75.2%
if 2.3000000000000001e-60 < b Initial program 14.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.6
Applied rewrites91.6%
Final simplification86.2%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (fma (/ b a) -0.6666666666666666 (* 0.5 (/ c b))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = fma((b / a), -0.6666666666666666, (0.5 * (c / b)));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(0.5 * Float64(c / b))); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.6666666666666666, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.5%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6464.1
Applied rewrites64.1%
Taylor expanded in c around 0
Applied rewrites64.2%
if -4.999999999999985e-310 < b Initial program 31.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6468.7
Applied rewrites68.7%
Final simplification66.7%
(FPCore (a b c) :precision binary64 (if (<= b 5e-310) (/ (* -2.0 b) (* a 3.0)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-310) {
tmp = (-2.0 * b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 5d-310) then
tmp = ((-2.0d0) * b) / (a * 3.0d0)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5e-310) {
tmp = (-2.0 * b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-310: tmp = (-2.0 * b) / (a * 3.0) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-310) tmp = Float64(Float64(-2.0 * b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5e-310) tmp = (-2.0 * b) / (a * 3.0); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-310], N[(N[(-2.0 * b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-2 \cdot b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.999999999999985e-310Initial program 72.5%
Taylor expanded in b around -inf
lower-*.f6464.0
Applied rewrites64.0%
if 4.999999999999985e-310 < b Initial program 31.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6468.7
Applied rewrites68.7%
Final simplification66.6%
(FPCore (a b c) :precision binary64 (if (<= b 5e-310) (* (/ 0.6666666666666666 a) (- b)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-310) {
tmp = (0.6666666666666666 / a) * -b;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 5d-310) then
tmp = (0.6666666666666666d0 / a) * -b
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5e-310) {
tmp = (0.6666666666666666 / a) * -b;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-310: tmp = (0.6666666666666666 / a) * -b else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-310) tmp = Float64(Float64(0.6666666666666666 / a) * Float64(-b)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5e-310) tmp = (0.6666666666666666 / a) * -b; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-310], N[(N[(0.6666666666666666 / a), $MachinePrecision] * (-b)), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-310}:\\
\;\;\;\;\frac{0.6666666666666666}{a} \cdot \left(-b\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.999999999999985e-310Initial program 72.5%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6464.1
Applied rewrites64.1%
Taylor expanded in c around 0
Applied rewrites63.8%
if 4.999999999999985e-310 < b Initial program 31.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6468.7
Applied rewrites68.7%
Final simplification66.5%
(FPCore (a b c) :precision binary64 (if (<= b 5e-310) (/ (* -0.6666666666666666 b) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-310) {
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 <= 5d-310) 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 <= 5e-310) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-310: tmp = (-0.6666666666666666 * b) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-310) tmp = Float64(Float64(-0.6666666666666666 * 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 <= 5e-310) tmp = (-0.6666666666666666 * b) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-310], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.999999999999985e-310Initial program 72.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites73.1%
Taylor expanded in b around -inf
lower-*.f6463.8
Applied rewrites63.8%
if 4.999999999999985e-310 < b Initial program 31.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6468.7
Applied rewrites68.7%
Final simplification66.5%
(FPCore (a b c) :precision binary64 (if (<= b 5e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5e-310) {
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 <= 5d-310) 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 <= 5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5e-310) 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 <= 5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5e-310], 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 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 4.999999999999985e-310Initial program 72.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6463.8
Applied rewrites63.8%
if 4.999999999999985e-310 < b Initial program 31.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6468.7
Applied rewrites68.7%
Final simplification66.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e+26) (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e+26) {
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 <= 2.9d+26) 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 <= 2.9e+26) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e+26: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e+26) 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 <= 2.9e+26) tmp = -0.6666666666666666 * (b / a); else tmp = 0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e+26], 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 2.9 \cdot 10^{+26}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 2.9e26Initial program 69.4%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6445.1
Applied rewrites45.1%
if 2.9e26 < b Initial program 13.6%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.2
Applied rewrites2.2%
Taylor expanded in c around inf
Applied rewrites32.8%
(FPCore (a b c) :precision binary64 (* 0.5 (/ c b)))
double code(double a, double b, double c) {
return 0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.5d0 * (c / b)
end function
public static double code(double a, double b, double c) {
return 0.5 * (c / b);
}
def code(a, b, c): return 0.5 * (c / b)
function code(a, b, c) return Float64(0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = 0.5 * (c / b); end
code[a_, b_, c_] := N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{c}{b}
\end{array}
Initial program 50.3%
Taylor expanded in b around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6430.2
Applied rewrites30.2%
Taylor expanded in c around inf
Applied rewrites13.4%
herbie shell --seed 2024270
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))