
(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 -9.6e+100)
(/ (/ b a) -1.5)
(if (<= b 9.4e-88)
(/ (- (sqrt (fma (* a -3.0) c (* b b))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.6e+100) {
tmp = (b / a) / -1.5;
} else if (b <= 9.4e-88) {
tmp = (sqrt(fma((a * -3.0), c, (b * b))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -9.6e+100) tmp = Float64(Float64(b / a) / -1.5); elseif (b <= 9.4e-88) tmp = Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -9.6e+100], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], If[LessEqual[b, 9.4e-88], N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.6 \cdot 10^{+100}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{elif}\;b \leq 9.4 \cdot 10^{-88}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.60000000000000046e100Initial program 50.1%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6492.3
Applied rewrites92.3%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6492.2
Applied rewrites92.2%
clear-numN/A
associate-*l/N/A
div-invN/A
times-fracN/A
lift-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
metadata-eval92.2
Applied rewrites92.2%
frac-timesN/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6492.4
Applied rewrites92.4%
if -9.60000000000000046e100 < b < 9.4e-88Initial program 80.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-eval80.3
Applied rewrites80.3%
if 9.4e-88 < b Initial program 18.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+128)
(/ (/ b a) -1.5)
(if (<= b 9.4e-88)
(/ (* (- (sqrt (fma (* a -3.0) c (* b b))) b) 0.3333333333333333) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+128) {
tmp = (b / a) / -1.5;
} else if (b <= 9.4e-88) {
tmp = ((sqrt(fma((a * -3.0), c, (b * b))) - b) * 0.3333333333333333) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+128) tmp = Float64(Float64(b / a) / -1.5); elseif (b <= 9.4e-88) tmp = Float64(Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) * 0.3333333333333333) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+128], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], If[LessEqual[b, 9.4e-88], N[(N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{elif}\;b \leq 9.4 \cdot 10^{-88}:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b\right) \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.59999999999999993e128Initial program 43.0%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.1
Applied rewrites93.1%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.0
Applied rewrites93.0%
clear-numN/A
associate-*l/N/A
div-invN/A
times-fracN/A
lift-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
metadata-eval93.1
Applied rewrites93.1%
frac-timesN/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6493.3
Applied rewrites93.3%
if -1.59999999999999993e128 < b < 9.4e-88Initial program 80.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-eval80.8
Applied rewrites80.8%
lift-neg.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6480.7
Applied rewrites80.7%
if 9.4e-88 < b Initial program 18.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+128)
(/ (/ b a) -1.5)
(if (<= b 9.4e-88)
(* (/ -0.3333333333333333 a) (- b (sqrt (fma a (* -3.0 c) (* b b)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+128) {
tmp = (b / a) / -1.5;
} else if (b <= 9.4e-88) {
tmp = (-0.3333333333333333 / a) * (b - sqrt(fma(a, (-3.0 * c), (b * b))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+128) tmp = Float64(Float64(b / a) / -1.5); elseif (b <= 9.4e-88) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(fma(a, Float64(-3.0 * c), Float64(b * b))))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+128], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], If[LessEqual[b, 9.4e-88], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{elif}\;b \leq 9.4 \cdot 10^{-88}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.59999999999999993e128Initial program 43.0%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.1
Applied rewrites93.1%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.0
Applied rewrites93.0%
clear-numN/A
associate-*l/N/A
div-invN/A
times-fracN/A
lift-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
metadata-eval93.1
Applied rewrites93.1%
frac-timesN/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6493.3
Applied rewrites93.3%
if -1.59999999999999993e128 < b < 9.4e-88Initial program 80.8%
Applied rewrites80.7%
if 9.4e-88 < b Initial program 18.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e-86)
(fma c (/ 0.5 b) (/ (* b -0.6666666666666666) a))
(if (<= b 9.4e-88)
(/ (- (sqrt (* a (* -3.0 c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-86) {
tmp = fma(c, (0.5 / b), ((b * -0.6666666666666666) / a));
} else if (b <= 9.4e-88) {
tmp = (sqrt((a * (-3.0 * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.35e-86) tmp = fma(c, Float64(0.5 / b), Float64(Float64(b * -0.6666666666666666) / a)); elseif (b <= 9.4e-88) tmp = Float64(Float64(sqrt(Float64(a * Float64(-3.0 * c))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.35e-86], N[(c * N[(0.5 / b), $MachinePrecision] + N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.4e-88], N[(N[(N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b \cdot -0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 9.4 \cdot 10^{-88}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-3 \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.34999999999999996e-86Initial program 68.1%
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.f6480.1
Applied rewrites80.1%
Taylor expanded in c around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.2
Applied rewrites80.2%
if -1.34999999999999996e-86 < b < 9.4e-88Initial program 74.1%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
if 9.4e-88 < b Initial program 18.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e-86)
(fma c (/ 0.5 b) (/ (* b -0.6666666666666666) a))
(if (<= b 9.4e-88)
(/ (* 0.3333333333333333 (- (sqrt (* -3.0 (* a c))) b)) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-86) {
tmp = fma(c, (0.5 / b), ((b * -0.6666666666666666) / a));
} else if (b <= 9.4e-88) {
tmp = (0.3333333333333333 * (sqrt((-3.0 * (a * c))) - b)) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.35e-86) tmp = fma(c, Float64(0.5 / b), Float64(Float64(b * -0.6666666666666666) / a)); elseif (b <= 9.4e-88) tmp = Float64(Float64(0.3333333333333333 * Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b)) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.35e-86], N[(c * N[(0.5 / b), $MachinePrecision] + N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.4e-88], N[(N[(0.3333333333333333 * N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b \cdot -0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 9.4 \cdot 10^{-88}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \left(\sqrt{-3 \cdot \left(a \cdot c\right)} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.34999999999999996e-86Initial program 68.1%
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.f6480.1
Applied rewrites80.1%
Taylor expanded in c around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.2
Applied rewrites80.2%
if -1.34999999999999996e-86 < b < 9.4e-88Initial program 74.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-eval74.1
Applied rewrites74.1%
lift-neg.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites73.7%
Taylor expanded in b around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
if 9.4e-88 < b Initial program 18.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification79.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (fma c (/ 0.5 b) (/ (* b -0.6666666666666666) a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = fma(c, (0.5 / b), ((b * -0.6666666666666666) / a));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = fma(c, Float64(0.5 / b), Float64(Float64(b * -0.6666666666666666) / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(c * N[(0.5 / b), $MachinePrecision] + N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{0.5}{b}, \frac{b \cdot -0.6666666666666666}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 69.2%
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.f6458.2
Applied rewrites58.2%
Taylor expanded in c around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6459.1
Applied rewrites59.1%
if -4.999999999999985e-310 < b Initial program 32.9%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.7
Applied rewrites67.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.25e-286) (/ (/ b a) -1.5) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.25e-286) {
tmp = (b / a) / -1.5;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.25d-286) then
tmp = (b / a) / (-1.5d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.25e-286) {
tmp = (b / a) / -1.5;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.25e-286: tmp = (b / a) / -1.5 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.25e-286) tmp = Float64(Float64(b / a) / -1.5); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.25e-286) tmp = (b / a) / -1.5; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.25e-286], N[(N[(b / a), $MachinePrecision] / -1.5), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.25 \cdot 10^{-286}:\\
\;\;\;\;\frac{\frac{b}{a}}{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.25000000000000009e-286Initial program 69.2%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6457.4
Applied rewrites57.4%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6457.3
Applied rewrites57.3%
clear-numN/A
associate-*l/N/A
div-invN/A
times-fracN/A
lift-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
metadata-eval57.3
Applied rewrites57.3%
frac-timesN/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
if 1.25000000000000009e-286 < b Initial program 32.1%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.2
Applied rewrites69.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.25e-286) (* (/ b a) -0.6666666666666666) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.25e-286) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 1.25d-286) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 1.25e-286) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.25e-286: tmp = (b / a) * -0.6666666666666666 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.25e-286) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.25e-286) tmp = (b / a) * -0.6666666666666666; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.25e-286], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.25 \cdot 10^{-286}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 1.25000000000000009e-286Initial program 69.2%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6457.4
Applied rewrites57.4%
/-rgt-identityN/A
div-invN/A
metadata-evalN/A
times-fracN/A
un-div-invN/A
lift-/.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6457.4
Applied rewrites57.4%
if 1.25000000000000009e-286 < b Initial program 32.1%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.2
Applied rewrites69.2%
(FPCore (a b c) :precision binary64 (if (<= b 15000000000000.0) (* (/ b a) -0.6666666666666666) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 15000000000000.0) {
tmp = (b / a) * -0.6666666666666666;
} 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 <= 15000000000000.0d0) then
tmp = (b / a) * (-0.6666666666666666d0)
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 <= 15000000000000.0) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 15000000000000.0: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 15000000000000.0) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 15000000000000.0) tmp = (b / a) * -0.6666666666666666; else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 15000000000000.0], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 15000000000000:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 1.5e13Initial program 67.9%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6442.9
Applied rewrites42.9%
/-rgt-identityN/A
div-invN/A
metadata-evalN/A
times-fracN/A
un-div-invN/A
lift-/.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6442.9
Applied rewrites42.9%
if 1.5e13 < b Initial program 12.8%
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.f642.4
Applied rewrites2.4%
Taylor expanded in c around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.2
Applied rewrites2.2%
Taylor expanded in b around 0
lower-/.f6426.3
Applied rewrites26.3%
(FPCore (a b c) :precision binary64 (if (<= b 15000000000000.0) (* b (/ -0.6666666666666666 a)) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 15000000000000.0) {
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 <= 15000000000000.0d0) 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 <= 15000000000000.0) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 15000000000000.0: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 15000000000000.0) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 15000000000000.0) tmp = b * (-0.6666666666666666 / a); else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 15000000000000.0], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 15000000000000:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 1.5e13Initial program 67.9%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6442.9
Applied rewrites42.9%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6442.9
Applied rewrites42.9%
if 1.5e13 < b Initial program 12.8%
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.f642.4
Applied rewrites2.4%
Taylor expanded in c around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.2
Applied rewrites2.2%
Taylor expanded in b around 0
lower-/.f6426.3
Applied rewrites26.3%
Final simplification37.7%
(FPCore (a b c) :precision binary64 (* c (/ 0.5 b)))
double code(double a, double b, double c) {
return c * (0.5 / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * (0.5d0 / b)
end function
public static double code(double a, double b, double c) {
return c * (0.5 / b);
}
def code(a, b, c): return c * (0.5 / b)
function code(a, b, c) return Float64(c * Float64(0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (0.5 / b); end
code[a_, b_, c_] := N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{0.5}{b}
\end{array}
Initial program 50.9%
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.f6429.9
Applied rewrites29.9%
Taylor expanded in c around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6423.3
Applied rewrites23.3%
Taylor expanded in b around 0
lower-/.f6410.2
Applied rewrites10.2%
(FPCore (a b c) :precision binary64 (* b (/ 0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (0.6666666666666666 / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b * (0.6666666666666666d0 / a)
end function
public static double code(double a, double b, double c) {
return b * (0.6666666666666666 / a);
}
def code(a, b, c): return b * (0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{0.6666666666666666}{a}
\end{array}
Initial program 50.9%
Applied rewrites33.7%
Taylor expanded in b around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.3
Applied rewrites2.3%
Taylor expanded in b around inf
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f642.8
Applied rewrites2.8%
herbie shell --seed 2024216
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))