
(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 14 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.15e+95)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 7.5e-47)
(/ (/ (- b (sqrt (fma a (* c -3.0) (* b b)))) a) -3.0)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e+95) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.5e-47) {
tmp = ((b - sqrt(fma(a, (c * -3.0), (b * b)))) / a) / -3.0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.15e+95) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7.5e-47) tmp = Float64(Float64(Float64(b - sqrt(fma(a, Float64(c * -3.0), Float64(b * b)))) / a) / -3.0); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.15e+95], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-47], N[(N[(N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{+95}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-47}:\\
\;\;\;\;\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{a}}{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.14999999999999999e95Initial program 45.9%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6495.4
Applied rewrites95.4%
if -1.14999999999999999e95 < b < 7.49999999999999969e-47Initial program 81.6%
Applied rewrites81.6%
if 7.49999999999999969e-47 < b Initial program 14.2%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+70)
(/ 1.0 (/ (* a -1.5) b))
(if (<= b 7.5e-47)
(/ (- (sqrt (fma (* a -3.0) c (* b b))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e+70) {
tmp = 1.0 / ((a * -1.5) / b);
} else if (b <= 7.5e-47) {
tmp = (sqrt(fma((a * -3.0), c, (b * b))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e+70) tmp = Float64(1.0 / Float64(Float64(a * -1.5) / b)); elseif (b <= 7.5e-47) tmp = Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e+70], N[(1.0 / N[(N[(a * -1.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-47], N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{+70}:\\
\;\;\;\;\frac{1}{\frac{a \cdot -1.5}{b}}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-47}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.79999999999999974e70Initial program 49.1%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.5
Applied rewrites95.5%
Applied rewrites95.5%
Applied rewrites95.6%
if -4.79999999999999974e70 < b < 7.49999999999999969e-47Initial program 80.9%
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.9
Applied rewrites80.9%
if 7.49999999999999969e-47 < b Initial program 14.2%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+70)
(/ 1.0 (/ (* a -1.5) b))
(if (<= b 7.5e-47)
(/ (- (sqrt (fma a (* c -3.0) (* b b))) b) (* 3.0 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e+70) {
tmp = 1.0 / ((a * -1.5) / b);
} else if (b <= 7.5e-47) {
tmp = (sqrt(fma(a, (c * -3.0), (b * b))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e+70) tmp = Float64(1.0 / Float64(Float64(a * -1.5) / b)); elseif (b <= 7.5e-47) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -3.0), Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e+70], N[(1.0 / N[(N[(a * -1.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-47], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{+70}:\\
\;\;\;\;\frac{1}{\frac{a \cdot -1.5}{b}}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-47}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.79999999999999974e70Initial program 49.1%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6495.5
Applied rewrites95.5%
Applied rewrites95.5%
Applied rewrites95.6%
if -4.79999999999999974e70 < b < 7.49999999999999969e-47Initial program 80.9%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6480.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.8
Applied rewrites80.8%
if 7.49999999999999969e-47 < b Initial program 14.2%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e+95)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 7.5e-47)
(* (- b (sqrt (fma a (* c -3.0) (* b b)))) (/ -0.3333333333333333 a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e+95) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.5e-47) {
tmp = (b - sqrt(fma(a, (c * -3.0), (b * b)))) * (-0.3333333333333333 / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.15e+95) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7.5e-47) tmp = Float64(Float64(b - sqrt(fma(a, Float64(c * -3.0), Float64(b * b)))) * Float64(-0.3333333333333333 / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.15e+95], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-47], N[(N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{+95}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-47}:\\
\;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.14999999999999999e95Initial program 45.9%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6495.4
Applied rewrites95.4%
if -1.14999999999999999e95 < b < 7.49999999999999969e-47Initial program 81.6%
Applied rewrites81.5%
if 7.49999999999999969e-47 < b Initial program 14.2%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-44)
(/ -0.6666666666666666 (/ a b))
(if (<= b 3.4e-47)
(/ (- b (sqrt (* c (* a -3.0)))) (* a -3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-44) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 3.4e-47) {
tmp = (b - sqrt((c * (a * -3.0)))) / (a * -3.0);
} 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 <= (-6d-44)) then
tmp = (-0.6666666666666666d0) / (a / b)
else if (b <= 3.4d-47) then
tmp = (b - sqrt((c * (a * (-3.0d0))))) / (a * (-3.0d0))
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 <= -6e-44) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 3.4e-47) {
tmp = (b - Math.sqrt((c * (a * -3.0)))) / (a * -3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-44: tmp = -0.6666666666666666 / (a / b) elif b <= 3.4e-47: tmp = (b - math.sqrt((c * (a * -3.0)))) / (a * -3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-44) tmp = Float64(-0.6666666666666666 / Float64(a / b)); elseif (b <= 3.4e-47) tmp = Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.0)))) / Float64(a * -3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e-44) tmp = -0.6666666666666666 / (a / b); elseif (b <= 3.4e-47) tmp = (b - sqrt((c * (a * -3.0)))) / (a * -3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-44], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-47], N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 -6 \cdot 10^{-44}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-47}:\\
\;\;\;\;\frac{b - \sqrt{c \cdot \left(a \cdot -3\right)}}{a \cdot -3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.0000000000000005e-44Initial program 60.2%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
Applied rewrites91.5%
Applied rewrites91.6%
if -6.0000000000000005e-44 < b < 3.4000000000000002e-47Initial program 78.5%
Applied rewrites78.4%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6472.9
Applied rewrites73.0%
if 3.4000000000000002e-47 < b Initial program 14.2%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-44)
(/ -0.6666666666666666 (/ a b))
(if (<= b 3.4e-47)
(* -0.3333333333333333 (/ (- b (sqrt (* a (* c -3.0)))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-44) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 3.4e-47) {
tmp = -0.3333333333333333 * ((b - sqrt((a * (c * -3.0)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-6d-44)) then
tmp = (-0.6666666666666666d0) / (a / b)
else if (b <= 3.4d-47) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((a * (c * (-3.0d0))))) / a)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e-44) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 3.4e-47) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((a * (c * -3.0)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-44: tmp = -0.6666666666666666 / (a / b) elif b <= 3.4e-47: tmp = -0.3333333333333333 * ((b - math.sqrt((a * (c * -3.0)))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-44) tmp = Float64(-0.6666666666666666 / Float64(a / b)); elseif (b <= 3.4e-47) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(a * Float64(c * -3.0)))) / a)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e-44) tmp = -0.6666666666666666 / (a / b); elseif (b <= 3.4e-47) tmp = -0.3333333333333333 * ((b - sqrt((a * (c * -3.0)))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-44], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-47], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-44}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-47}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{a \cdot \left(c \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.0000000000000005e-44Initial program 60.2%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
Applied rewrites91.5%
Applied rewrites91.6%
if -6.0000000000000005e-44 < b < 3.4000000000000002e-47Initial program 78.5%
Applied rewrites78.4%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/r*N/A
div-invN/A
lower-*.f64N/A
Applied rewrites72.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
div-invN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites73.0%
if 3.4000000000000002e-47 < b Initial program 14.2%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Final simplification84.6%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-44)
(/ -0.6666666666666666 (/ a b))
(if (<= b 3.4e-47)
(* (/ -0.3333333333333333 a) (- b (sqrt (* a (* c -3.0)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-44) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 3.4e-47) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((a * (c * -3.0))));
} 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 <= (-6d-44)) then
tmp = (-0.6666666666666666d0) / (a / b)
else if (b <= 3.4d-47) then
tmp = ((-0.3333333333333333d0) / a) * (b - sqrt((a * (c * (-3.0d0)))))
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 <= -6e-44) {
tmp = -0.6666666666666666 / (a / b);
} else if (b <= 3.4e-47) {
tmp = (-0.3333333333333333 / a) * (b - Math.sqrt((a * (c * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-44: tmp = -0.6666666666666666 / (a / b) elif b <= 3.4e-47: tmp = (-0.3333333333333333 / a) * (b - math.sqrt((a * (c * -3.0)))) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-44) tmp = Float64(-0.6666666666666666 / Float64(a / b)); elseif (b <= 3.4e-47) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(a * Float64(c * -3.0))))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e-44) tmp = -0.6666666666666666 / (a / b); elseif (b <= 3.4e-47) tmp = (-0.3333333333333333 / a) * (b - sqrt((a * (c * -3.0)))); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-44], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-47], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-44}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-47}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -6.0000000000000005e-44Initial program 60.2%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
Applied rewrites91.5%
Applied rewrites91.6%
if -6.0000000000000005e-44 < b < 3.4000000000000002e-47Initial program 78.5%
Applied rewrites78.4%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/r*N/A
div-invN/A
lower-*.f64N/A
Applied rewrites72.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6472.8
Applied rewrites72.9%
if 3.4000000000000002e-47 < b Initial program 14.2%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Final simplification84.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (fma (/ b a) -0.6666666666666666 (/ (* c 0.5) b)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = fma((b / a), -0.6666666666666666, ((c * 0.5) / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(Float64(c * 0.5) / b)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(N[(c * 0.5), $MachinePrecision] / b), $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(\frac{b}{a}, -0.6666666666666666, \frac{c \cdot 0.5}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 66.3%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f6470.3
Applied rewrites70.3%
Taylor expanded in c around 0
Applied rewrites72.0%
if -4.999999999999985e-310 < b Initial program 35.3%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites63.2%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ -0.6666666666666666 (/ a b)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 / (a / b);
} 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 <= (-5d-310)) then
tmp = (-0.6666666666666666d0) / (a / b)
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 <= -5e-310) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 / (a / b) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(Float64(c * -0.5) / 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 = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 66.3%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.8
Applied rewrites71.8%
Applied rewrites71.8%
Applied rewrites71.8%
if -4.999999999999985e-310 < b Initial program 35.3%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites63.2%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (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 = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 66.3%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.8
Applied rewrites71.8%
if -4.999999999999985e-310 < b Initial program 35.3%
Taylor expanded in b around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.2
Applied rewrites63.2%
(FPCore (a b c) :precision binary64 (if (<= b 2.8e+26) (/ (* b -0.6666666666666666) a) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.8e+26) {
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 <= 2.8d+26) 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 <= 2.8e+26) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.8e+26: tmp = (b * -0.6666666666666666) / a else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.8e+26) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * 0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.8e+26) tmp = (b * -0.6666666666666666) / a; else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.8e+26], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.8 \cdot 10^{+26}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 2.8e26Initial program 62.7%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.7
Applied rewrites48.7%
if 2.8e26 < b Initial program 14.3%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f642.4
Applied rewrites2.4%
Taylor expanded in c around inf
Applied rewrites27.7%
(FPCore (a b c) :precision binary64 (if (<= b 2.8e+26) (* -0.6666666666666666 (/ b a)) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.8e+26) {
tmp = -0.6666666666666666 * (b / 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 <= 2.8d+26) then
tmp = (-0.6666666666666666d0) * (b / 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 <= 2.8e+26) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.8e+26: tmp = -0.6666666666666666 * (b / a) else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.8e+26) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c * 0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.8e+26) tmp = -0.6666666666666666 * (b / a); else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.8e+26], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.8 \cdot 10^{+26}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 2.8e26Initial program 62.7%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.7
Applied rewrites48.7%
Applied rewrites48.7%
if 2.8e26 < b Initial program 14.3%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f642.4
Applied rewrites2.4%
Taylor expanded in c around inf
Applied rewrites27.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(Float64(c * 0.5) / b) end
function tmp = code(a, b, c) tmp = (c * 0.5) / b; end
code[a_, b_, c_] := N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot 0.5}{b}
\end{array}
Initial program 50.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.f6436.3
Applied rewrites36.3%
Taylor expanded in c around inf
Applied rewrites9.1%
(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.8%
Applied rewrites33.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f642.6
Applied rewrites2.6%
Applied rewrites2.6%
herbie shell --seed 2024234
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))