
(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 10 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.2e+128)
(/ (/ (- b) a) 1.5)
(if (<= b 1.6e-55)
(/ 1.0 (* (/ -3.0 (- b (sqrt (fma (* -3.0 c) a (* b b))))) a))
(*
(fma
(fma
(* -0.5625 c)
(* (/ a (pow b 5.0)) a)
(* -0.375 (/ a (* (* b b) b))))
c
(/ -0.5 b))
c))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e+128) {
tmp = (-b / a) / 1.5;
} else if (b <= 1.6e-55) {
tmp = 1.0 / ((-3.0 / (b - sqrt(fma((-3.0 * c), a, (b * b))))) * a);
} else {
tmp = fma(fma((-0.5625 * c), ((a / pow(b, 5.0)) * a), (-0.375 * (a / ((b * b) * b)))), c, (-0.5 / b)) * c;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.2e+128) tmp = Float64(Float64(Float64(-b) / a) / 1.5); elseif (b <= 1.6e-55) tmp = Float64(1.0 / Float64(Float64(-3.0 / Float64(b - sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))))) * a)); else tmp = Float64(fma(fma(Float64(-0.5625 * c), Float64(Float64(a / (b ^ 5.0)) * a), Float64(-0.375 * Float64(a / Float64(Float64(b * b) * b)))), c, Float64(-0.5 / b)) * c); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.2e+128], N[(N[((-b) / a), $MachinePrecision] / 1.5), $MachinePrecision], If[LessEqual[b, 1.6e-55], N[(1.0 / N[(N[(-3.0 / N[(b - N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.5625 * c), $MachinePrecision] * N[(N[(a / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + N[(-0.375 * N[(a / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c + N[(-0.5 / b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{-b}{a}}{1.5}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-55}:\\
\;\;\;\;\frac{1}{\frac{-3}{b - \sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)}} \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5625 \cdot c, \frac{a}{{b}^{5}} \cdot a, -0.375 \cdot \frac{a}{\left(b \cdot b\right) \cdot b}\right), c, \frac{-0.5}{b}\right) \cdot c\\
\end{array}
\end{array}
if b < -5.2e128Initial program 43.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6496.0
Applied rewrites96.0%
Applied rewrites96.1%
Applied rewrites96.2%
if -5.2e128 < b < 1.6000000000000001e-55Initial program 81.4%
Applied rewrites82.0%
Applied rewrites82.0%
if 1.6000000000000001e-55 < b Initial program 13.3%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.5%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2e+128)
(/ (/ (- b) a) 1.5)
(if (<= b 1.05e-55)
(/ 1.0 (* (/ -3.0 (- b (sqrt (fma (* -3.0 c) a (* b b))))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e+128) {
tmp = (-b / a) / 1.5;
} else if (b <= 1.05e-55) {
tmp = 1.0 / ((-3.0 / (b - sqrt(fma((-3.0 * c), a, (b * b))))) * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.2e+128) tmp = Float64(Float64(Float64(-b) / a) / 1.5); elseif (b <= 1.05e-55) tmp = Float64(1.0 / Float64(Float64(-3.0 / Float64(b - sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))))) * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.2e+128], N[(N[((-b) / a), $MachinePrecision] / 1.5), $MachinePrecision], If[LessEqual[b, 1.05e-55], N[(1.0 / N[(N[(-3.0 / N[(b - N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{-b}{a}}{1.5}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-55}:\\
\;\;\;\;\frac{1}{\frac{-3}{b - \sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)}} \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -5.2e128Initial program 43.9%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6496.0
Applied rewrites96.0%
Applied rewrites96.1%
Applied rewrites96.2%
if -5.2e128 < b < 1.0500000000000001e-55Initial program 81.4%
Applied rewrites82.0%
Applied rewrites82.0%
if 1.0500000000000001e-55 < b Initial program 13.3%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.2
Applied rewrites89.2%
Final simplification86.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e+137)
(/ (/ (- b) a) 1.5)
(if (<= b 1.05e-55)
(/ (/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) a) 3.0)
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e+137) {
tmp = (-b / a) / 1.5;
} else if (b <= 1.05e-55) {
tmp = ((sqrt(fma((-3.0 * c), a, (b * b))) - b) / a) / 3.0;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.15e+137) tmp = Float64(Float64(Float64(-b) / a) / 1.5); elseif (b <= 1.05e-55) tmp = Float64(Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / a) / 3.0); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.15e+137], N[(N[((-b) / a), $MachinePrecision] / 1.5), $MachinePrecision], If[LessEqual[b, 1.05e-55], 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[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{+137}:\\
\;\;\;\;\frac{\frac{-b}{a}}{1.5}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-55}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.15e137Initial program 39.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Applied rewrites95.8%
Applied rewrites95.9%
if -1.15e137 < b < 1.0500000000000001e-55Initial program 81.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites82.5%
if 1.0500000000000001e-55 < b Initial program 13.3%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.2
Applied rewrites89.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e+137)
(/ (/ (- b) a) 1.5)
(if (<= b 1.05e-55)
(* 0.3333333333333333 (/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e+137) {
tmp = (-b / a) / 1.5;
} else if (b <= 1.05e-55) {
tmp = 0.3333333333333333 * ((sqrt(fma((-3.0 * c), a, (b * b))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.15e+137) tmp = Float64(Float64(Float64(-b) / a) / 1.5); elseif (b <= 1.05e-55) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.15e+137], N[(N[((-b) / a), $MachinePrecision] / 1.5), $MachinePrecision], If[LessEqual[b, 1.05e-55], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{+137}:\\
\;\;\;\;\frac{\frac{-b}{a}}{1.5}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-55}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.15e137Initial program 39.2%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Applied rewrites95.8%
Applied rewrites95.9%
if -1.15e137 < b < 1.0500000000000001e-55Initial program 81.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
lower-*.f64N/A
Applied rewrites82.4%
if 1.0500000000000001e-55 < b Initial program 13.3%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.2
Applied rewrites89.2%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-87)
(/ (- b) (* 1.5 a))
(if (<= b 9.5e-56)
(/ (- (sqrt (* (* c a) -3.0)) b) (* a 3.0))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-87) {
tmp = -b / (1.5 * a);
} else if (b <= 9.5e-56) {
tmp = (sqrt(((c * a) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6.5d-87)) then
tmp = -b / (1.5d0 * a)
else if (b <= 9.5d-56) then
tmp = (sqrt(((c * a) * (-3.0d0))) - b) / (a * 3.0d0)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-87) {
tmp = -b / (1.5 * a);
} else if (b <= 9.5e-56) {
tmp = (Math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-87: tmp = -b / (1.5 * a) elif b <= 9.5e-56: tmp = (math.sqrt(((c * a) * -3.0)) - b) / (a * 3.0) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-87) tmp = Float64(Float64(-b) / Float64(1.5 * a)); elseif (b <= 9.5e-56) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-87) tmp = -b / (1.5 * a); elseif (b <= 9.5e-56) tmp = (sqrt(((c * a) * -3.0)) - b) / (a * 3.0); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-87], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.5e-56], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-87}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.5000000000000003e-87Initial program 67.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6482.8
Applied rewrites82.8%
Applied rewrites83.1%
if -6.5000000000000003e-87 < b < 9.4999999999999991e-56Initial program 75.8%
Applied rewrites75.8%
Taylor expanded in c around inf
lower-*.f64N/A
lower-*.f6472.5
Applied rewrites72.5%
if 9.4999999999999991e-56 < b Initial program 13.3%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.2
Applied rewrites89.2%
Final simplification81.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.25e-247) (/ (- b) (* 1.5 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.25e-247) {
tmp = -b / (1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.25d-247) then
tmp = -b / (1.5d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.25e-247) {
tmp = -b / (1.5 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.25e-247: tmp = -b / (1.5 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.25e-247) tmp = Float64(Float64(-b) / Float64(1.5 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.25e-247) tmp = -b / (1.5 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.25e-247], N[((-b) / N[(1.5 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.25 \cdot 10^{-247}:\\
\;\;\;\;\frac{-b}{1.5 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.2500000000000001e-247Initial program 74.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6457.3
Applied rewrites57.3%
Applied rewrites57.5%
if 2.2500000000000001e-247 < b Initial program 22.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Final simplification63.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.25e-247) (* (/ -0.6666666666666666 a) b) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.25e-247) {
tmp = (-0.6666666666666666 / a) * b;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.25d-247) then
tmp = ((-0.6666666666666666d0) / a) * b
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.25e-247) {
tmp = (-0.6666666666666666 / a) * b;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.25e-247: tmp = (-0.6666666666666666 / a) * b else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.25e-247) tmp = Float64(Float64(-0.6666666666666666 / a) * b); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.25e-247) tmp = (-0.6666666666666666 / a) * b; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.25e-247], N[(N[(-0.6666666666666666 / a), $MachinePrecision] * b), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.25 \cdot 10^{-247}:\\
\;\;\;\;\frac{-0.6666666666666666}{a} \cdot b\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 2.2500000000000001e-247Initial program 74.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6457.3
Applied rewrites57.3%
Applied rewrites57.3%
Applied rewrites57.3%
if 2.2500000000000001e-247 < b Initial program 22.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
(FPCore (a b c) :precision binary64 (if (<= b 7.5e-11) (* (/ -0.6666666666666666 a) b) (* (/ 0.5 b) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-11) {
tmp = (-0.6666666666666666 / a) * b;
} else {
tmp = (0.5 / b) * c;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 7.5d-11) then
tmp = ((-0.6666666666666666d0) / a) * b
else
tmp = (0.5d0 / b) * c
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-11) {
tmp = (-0.6666666666666666 / a) * b;
} else {
tmp = (0.5 / b) * c;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.5e-11: tmp = (-0.6666666666666666 / a) * b else: tmp = (0.5 / b) * c return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.5e-11) tmp = Float64(Float64(-0.6666666666666666 / a) * b); else tmp = Float64(Float64(0.5 / b) * c); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.5e-11) tmp = (-0.6666666666666666 / a) * b; else tmp = (0.5 / b) * c; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.5e-11], N[(N[(-0.6666666666666666 / a), $MachinePrecision] * b), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{-0.6666666666666666}{a} \cdot b\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot c\\
\end{array}
\end{array}
if b < 7.5e-11Initial program 69.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6447.9
Applied rewrites47.9%
Applied rewrites47.9%
Applied rewrites47.9%
if 7.5e-11 < b Initial program 12.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-/.f642.8
Applied rewrites2.8%
Taylor expanded in c around inf
Applied rewrites32.4%
(FPCore (a b c) :precision binary64 (if (<= b 7.5e-11) (* (/ b a) -0.6666666666666666) (* (/ 0.5 b) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-11) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (0.5 / b) * c;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 7.5d-11) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (0.5d0 / b) * c
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-11) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (0.5 / b) * c;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.5e-11: tmp = (b / a) * -0.6666666666666666 else: tmp = (0.5 / b) * c return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.5e-11) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(0.5 / b) * c); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.5e-11) tmp = (b / a) * -0.6666666666666666; else tmp = (0.5 / b) * c; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.5e-11], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(0.5 / b), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{b} \cdot c\\
\end{array}
\end{array}
if b < 7.5e-11Initial program 69.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6447.9
Applied rewrites47.9%
if 7.5e-11 < b Initial program 12.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-/.f642.8
Applied rewrites2.8%
Taylor expanded in c around inf
Applied rewrites32.4%
Final simplification43.9%
(FPCore (a b c) :precision binary64 (* (/ 0.5 b) c))
double code(double a, double b, double c) {
return (0.5 / b) * c;
}
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 / b) * c
end function
public static double code(double a, double b, double c) {
return (0.5 / b) * c;
}
def code(a, b, c): return (0.5 / b) * c
function code(a, b, c) return Float64(Float64(0.5 / b) * c) end
function tmp = code(a, b, c) tmp = (0.5 / b) * c; end
code[a_, b_, c_] := N[(N[(0.5 / b), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{b} \cdot c
\end{array}
Initial program 54.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
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6435.9
Applied rewrites35.9%
Taylor expanded in c around inf
Applied rewrites10.8%
herbie shell --seed 2024240
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))