
(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 -1.45e+104)
(/ -0.6666666666666666 (/ a b))
(if (<= b 1e-114)
(/ (+ (- b) (sqrt (fma b b (* (* -3.0 a) c)))) (* 3.0 a))
(/ (fma (* (* -0.375 (/ a b)) c) (/ c b) (* -0.5 c)) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e+104) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 1e-114) {
tmp = (-b + sqrt(fma(b, b, ((-3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = fma(((-0.375 * (a / b)) * c), (c / b), (-0.5 * c)) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.45e+104) tmp = Float64(-0.6666666666666666 / Float64(a / b)); elseif (b <= 1e-114) tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c)))) / Float64(3.0 * a)); else tmp = Float64(fma(Float64(Float64(-0.375 * Float64(a / b)) * c), Float64(c / b), Float64(-0.5 * c)) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.45e+104], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-114], N[(N[((-b) + N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.375 * N[(a / b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * N[(c / b), $MachinePrecision] + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{+104}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{elif}\;b \leq 10^{-114}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-0.375 \cdot \frac{a}{b}\right) \cdot c, \frac{c}{b}, -0.5 \cdot c\right)}{b}\\
\end{array}
\end{array}
if b < -1.4499999999999999e104Initial program 67.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6494.5
Applied rewrites94.5%
Applied rewrites94.6%
if -1.4499999999999999e104 < b < 1.0000000000000001e-114Initial program 86.9%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval86.9
Applied rewrites86.9%
if 1.0000000000000001e-114 < b Initial program 19.3%
Taylor expanded in b around inf
lower-/.f64N/A
+-commutativeN/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
*-commutativeN/A
*-rgt-identityN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6474.1
Applied rewrites74.1%
Applied rewrites86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e+104)
(/ -0.6666666666666666 (/ a b))
(if (<= b 1e-114)
(/ (+ (- b) (sqrt (fma b b (* (* -3.0 a) c)))) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e+104) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 1e-114) {
tmp = (-b + sqrt(fma(b, b, ((-3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.45e+104) tmp = Float64(-0.6666666666666666 / Float64(a / b)); elseif (b <= 1e-114) tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c)))) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.45e+104], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-114], N[(N[((-b) + N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{+104}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{elif}\;b \leq 10^{-114}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.4499999999999999e104Initial program 67.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6494.5
Applied rewrites94.5%
Applied rewrites94.6%
if -1.4499999999999999e104 < b < 1.0000000000000001e-114Initial program 86.9%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval86.9
Applied rewrites86.9%
if 1.0000000000000001e-114 < b Initial program 19.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e+104)
(/ -0.6666666666666666 (/ a b))
(if (<= b 1e-114)
(/ (- (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 <= -1.45e+104) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 1e-114) {
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 <= -1.45e+104) tmp = Float64(-0.6666666666666666 / Float64(a / b)); elseif (b <= 1e-114) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.45e+104], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-114], N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 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 -1.45 \cdot 10^{+104}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{elif}\;b \leq 10^{-114}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.4499999999999999e104Initial program 67.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6494.5
Applied rewrites94.5%
Applied rewrites94.6%
if -1.4499999999999999e104 < b < 1.0000000000000001e-114Initial program 86.9%
Applied rewrites86.8%
if 1.0000000000000001e-114 < b Initial program 19.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e+152)
(/ (* -0.6666666666666666 b) a)
(if (<= b 5.2e-137)
(* (/ 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 <= -3.6e+152) {
tmp = (-0.6666666666666666 * b) / a;
} else if (b <= 5.2e-137) {
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 <= -3.6e+152) tmp = Float64(Float64(-0.6666666666666666 * b) / a); elseif (b <= 5.2e-137) 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, -3.6e+152], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 5.2e-137], 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 -3.6 \cdot 10^{+152}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-137}:\\
\;\;\;\;\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 < -3.5999999999999999e152Initial program 55.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites55.1%
Taylor expanded in b around -inf
lower-*.f6494.7
Applied rewrites94.7%
if -3.5999999999999999e152 < b < 5.1999999999999999e-137Initial program 88.7%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval88.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6488.5
Applied rewrites88.5%
if 5.1999999999999999e-137 < b Initial program 19.9%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e-60)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.2e-137)
(/ (- (sqrt (* (* c a) -3.0)) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-60) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.2e-137) {
tmp = (sqrt(((c * a) * -3.0)) - b) / (3.0 * 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 <= (-7.5d-60)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 5.2d-137) then
tmp = (sqrt(((c * a) * (-3.0d0))) - b) / (3.0d0 * 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 <= -7.5e-60) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.2e-137) {
tmp = (Math.sqrt(((c * a) * -3.0)) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-60: tmp = (-2.0 * b) / (3.0 * a) elif b <= 5.2e-137: tmp = (math.sqrt(((c * a) * -3.0)) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-60) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.2e-137) tmp = Float64(Float64(sqrt(Float64(Float64(c * a) * -3.0)) - b) / Float64(3.0 * 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 <= -7.5e-60) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 5.2e-137) tmp = (sqrt(((c * a) * -3.0)) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-60], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-137], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-60}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-137}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -7.5000000000000002e-60Initial program 79.9%
Taylor expanded in b around -inf
lower-*.f6487.5
Applied rewrites87.5%
if -7.5000000000000002e-60 < b < 5.1999999999999999e-137Initial program 80.5%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites69.6%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6469.7
Applied rewrites69.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
metadata-evalN/A
metadata-evalN/A
associate-/r*N/A
metadata-evalN/A
un-div-invN/A
lower-/.f64N/A
Applied rewrites69.9%
if 5.1999999999999999e-137 < b Initial program 19.9%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e-60)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 1e-114)
(/ (- (sqrt (* (* c -3.0) a)) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-60) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1e-114) {
tmp = (sqrt(((c * -3.0) * a)) - b) / (3.0 * 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 <= (-7.5d-60)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 1d-114) then
tmp = (sqrt(((c * (-3.0d0)) * a)) - b) / (3.0d0 * 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 <= -7.5e-60) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 1e-114) {
tmp = (Math.sqrt(((c * -3.0) * a)) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-60: tmp = (-2.0 * b) / (3.0 * a) elif b <= 1e-114: tmp = (math.sqrt(((c * -3.0) * a)) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-60) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 1e-114) tmp = Float64(Float64(sqrt(Float64(Float64(c * -3.0) * a)) - b) / Float64(3.0 * 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 <= -7.5e-60) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 1e-114) tmp = (sqrt(((c * -3.0) * a)) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-60], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-114], N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-60}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 10^{-114}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot -3\right) \cdot a} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -7.5000000000000002e-60Initial program 79.9%
Taylor expanded in b around -inf
lower-*.f6487.5
Applied rewrites87.5%
if -7.5000000000000002e-60 < b < 1.0000000000000001e-114Initial program 79.5%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.2
Applied rewrites69.2%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6469.2
Applied rewrites69.2%
if 1.0000000000000001e-114 < b Initial program 19.3%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e-60)
(/ (* -2.0 b) (* 3.0 a))
(if (<= b 5.2e-137)
(* (/ 0.3333333333333333 a) (- (sqrt (* (* c -3.0) a)) b))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-60) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.2e-137) {
tmp = (0.3333333333333333 / a) * (sqrt(((c * -3.0) * 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 <= (-7.5d-60)) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else if (b <= 5.2d-137) then
tmp = (0.3333333333333333d0 / a) * (sqrt(((c * (-3.0d0)) * 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 <= -7.5e-60) {
tmp = (-2.0 * b) / (3.0 * a);
} else if (b <= 5.2e-137) {
tmp = (0.3333333333333333 / a) * (Math.sqrt(((c * -3.0) * a)) - b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-60: tmp = (-2.0 * b) / (3.0 * a) elif b <= 5.2e-137: tmp = (0.3333333333333333 / a) * (math.sqrt(((c * -3.0) * a)) - b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-60) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); elseif (b <= 5.2e-137) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(Float64(Float64(c * -3.0) * a)) - 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 <= -7.5e-60) tmp = (-2.0 * b) / (3.0 * a); elseif (b <= 5.2e-137) tmp = (0.3333333333333333 / a) * (sqrt(((c * -3.0) * a)) - b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-60], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-137], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-60}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-137}:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\left(c \cdot -3\right) \cdot a} - b\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -7.5000000000000002e-60Initial program 79.9%
Taylor expanded in b around -inf
lower-*.f6487.5
Applied rewrites87.5%
if -7.5000000000000002e-60 < b < 5.1999999999999999e-137Initial program 80.5%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6469.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6469.9
Applied rewrites69.8%
if 5.1999999999999999e-137 < b Initial program 19.9%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (/ (* -2.0 b) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = (-2.0 * b) / (3.0 * 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 <= (-1d-309)) then
tmp = ((-2.0d0) * b) / (3.0d0 * 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 <= -1e-309) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = (-2.0 * b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * 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 <= -1e-309) tmp = (-2.0 * b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 81.0%
Taylor expanded in b around -inf
lower-*.f6473.9
Applied rewrites73.9%
if -1.000000000000002e-309 < b Initial program 30.0%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6471.1
Applied rewrites71.1%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (* (/ 0.6666666666666666 (- a)) b) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
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 <= (-1d-309)) 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 <= -1e-309) {
tmp = (0.6666666666666666 / -a) * b;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = (0.6666666666666666 / -a) * b else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(Float64(0.6666666666666666 / Float64(-a)) * 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 <= -1e-309) tmp = (0.6666666666666666 / -a) * b; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], 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 -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{0.6666666666666666}{-a} \cdot b\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 81.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6473.9
Applied rewrites73.9%
Applied rewrites73.8%
Applied rewrites73.7%
Applied rewrites73.9%
if -1.000000000000002e-309 < b Initial program 30.0%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6471.1
Applied rewrites71.1%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
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 <= (-1d-309)) 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 <= -1e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) 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 <= -1e-309) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], 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 -1 \cdot 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 81.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6473.9
Applied rewrites73.9%
if -1.000000000000002e-309 < b Initial program 30.0%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6471.1
Applied rewrites71.1%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (* -0.6666666666666666 (/ b a)) (/ 0.0 a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.0 / a;
}
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-309)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = 0.0d0 / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.0 / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(0.0 / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-309) tmp = -0.6666666666666666 * (b / a); else tmp = 0.0 / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 81.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6473.9
Applied rewrites73.9%
if -1.000000000000002e-309 < b Initial program 30.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites30.0%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f6424.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6424.4
Applied rewrites24.4%
Taylor expanded in a around 0
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgt18.5
Applied rewrites18.5%
Final simplification43.8%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 53.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites53.2%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f6450.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.2
Applied rewrites50.2%
Taylor expanded in a around 0
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgt11.2
Applied rewrites11.2%
Final simplification11.2%
herbie shell --seed 2024309
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))