
(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 -8.5e+143)
(/ (/ (- (- b) b) a) 3.0)
(if (<= b 6e-73)
(/ (- (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 <= -8.5e+143) {
tmp = ((-b - b) / a) / 3.0;
} else if (b <= 6e-73) {
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 <= -8.5e+143) tmp = Float64(Float64(Float64(Float64(-b) - b) / a) / 3.0); elseif (b <= 6e-73) 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, -8.5e+143], N[(N[(N[((-b) - b), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 6e-73], 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 -8.5 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{\left(-b\right) - b}{a}}{3}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;\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 < -8.4999999999999998e143Initial program 47.0%
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-eval47.1
Applied rewrites47.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites47.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6497.3
Applied rewrites97.3%
if -8.4999999999999998e143 < b < 6e-73Initial program 79.1%
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-eval79.1
Applied rewrites79.1%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e+143)
(/ (/ (- (- b) b) a) 3.0)
(if (<= b 6e-73)
(/ (* (- (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 <= -8.5e+143) {
tmp = ((-b - b) / a) / 3.0;
} else if (b <= 6e-73) {
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 <= -8.5e+143) tmp = Float64(Float64(Float64(Float64(-b) - b) / a) / 3.0); elseif (b <= 6e-73) 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, -8.5e+143], N[(N[(N[((-b) - b), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 6e-73], 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 -8.5 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{\left(-b\right) - b}{a}}{3}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;\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 < -8.4999999999999998e143Initial program 47.0%
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-eval47.1
Applied rewrites47.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites47.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6497.3
Applied rewrites97.3%
if -8.4999999999999998e143 < b < 6e-73Initial program 79.1%
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-eval79.1
Applied rewrites79.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites78.1%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f6478.9
Applied rewrites78.9%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e+143)
(/ (/ (- (- b) b) a) 3.0)
(if (<= b 6e-73)
(/ (* 0.3333333333333333 (- (sqrt (fma b b (* a (* -3.0 c)))) b)) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+143) {
tmp = ((-b - b) / a) / 3.0;
} else if (b <= 6e-73) {
tmp = (0.3333333333333333 * (sqrt(fma(b, b, (a * (-3.0 * c)))) - b)) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+143) tmp = Float64(Float64(Float64(Float64(-b) - b) / a) / 3.0); elseif (b <= 6e-73) tmp = Float64(Float64(0.3333333333333333 * Float64(sqrt(fma(b, b, Float64(a * Float64(-3.0 * c)))) - b)) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+143], N[(N[(N[((-b) - b), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 6e-73], N[(N[(0.3333333333333333 * N[(N[Sqrt[N[(b * b + N[(a * N[(-3.0 * c), $MachinePrecision]), $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 -3.6 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{\left(-b\right) - b}{a}}{3}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.5999999999999999e143Initial program 47.0%
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-eval47.1
Applied rewrites47.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites47.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6497.3
Applied rewrites97.3%
if -3.5999999999999999e143 < b < 6e-73Initial program 79.1%
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-eval79.1
Applied rewrites79.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites78.1%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -3.05e+143)
(/ (/ (- (- b) b) a) 3.0)
(if (<= b 6e-73)
(* (/ -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 <= -3.05e+143) {
tmp = ((-b - b) / a) / 3.0;
} else if (b <= 6e-73) {
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 <= -3.05e+143) tmp = Float64(Float64(Float64(Float64(-b) - b) / a) / 3.0); elseif (b <= 6e-73) 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, -3.05e+143], N[(N[(N[((-b) - b), $MachinePrecision] / a), $MachinePrecision] / 3.0), $MachinePrecision], If[LessEqual[b, 6e-73], 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 -3.05 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{\left(-b\right) - b}{a}}{3}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;\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 < -3.0500000000000002e143Initial program 47.0%
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-eval47.1
Applied rewrites47.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites47.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6497.3
Applied rewrites97.3%
if -3.0500000000000002e143 < b < 6e-73Initial program 79.1%
Applied rewrites78.1%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2)
(* (- b) (fma c (/ -0.5 (* b b)) (/ 0.6666666666666666 a)))
(if (<= b 6e-73)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2) {
tmp = -b * fma(c, (-0.5 / (b * b)), (0.6666666666666666 / a));
} else if (b <= 6e-73) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.2) tmp = Float64(Float64(-b) * fma(c, Float64(-0.5 / Float64(b * b)), Float64(0.6666666666666666 / a))); elseif (b <= 6e-73) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * 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, -5.2], N[((-b) * N[(c * N[(-0.5 / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6e-73], N[(N[(N[Sqrt[N[(-3.0 * N[(a * 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 -5.2:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(c, \frac{-0.5}{b \cdot b}, \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.20000000000000018Initial program 71.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-/.f6492.6
Applied rewrites92.6%
if -5.20000000000000018 < b < 6e-73Initial program 71.6%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6464.0
Applied rewrites64.0%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2)
(* (- b) (fma c (/ -0.5 (* b b)) (/ 0.6666666666666666 a)))
(if (<= b 6e-73)
(/ (* 0.3333333333333333 (- (sqrt (* a (* -3.0 c))) b)) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2) {
tmp = -b * fma(c, (-0.5 / (b * b)), (0.6666666666666666 / a));
} else if (b <= 6e-73) {
tmp = (0.3333333333333333 * (sqrt((a * (-3.0 * c))) - b)) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.2) tmp = Float64(Float64(-b) * fma(c, Float64(-0.5 / Float64(b * b)), Float64(0.6666666666666666 / a))); elseif (b <= 6e-73) tmp = Float64(Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(-3.0 * c))) - b)) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.2], N[((-b) * N[(c * N[(-0.5 / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6e-73], N[(N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(-3.0 * 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 -5.2:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(c, \frac{-0.5}{b \cdot b}, \frac{0.6666666666666666}{a}\right)\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \left(\sqrt{a \cdot \left(-3 \cdot c\right)} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.20000000000000018Initial program 71.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-/.f6492.6
Applied rewrites92.6%
if -5.20000000000000018 < b < 6e-73Initial program 71.6%
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-eval71.6
Applied rewrites71.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites71.3%
Taylor expanded in c around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6463.8
Applied rewrites63.8%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
Final simplification81.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2)
(/ 1.0 (/ a (* b -0.6666666666666666)))
(if (<= b 6e-73)
(/ (* 0.3333333333333333 (- (sqrt (* a (* -3.0 c))) b)) a)
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2) {
tmp = 1.0 / (a / (b * -0.6666666666666666));
} else if (b <= 6e-73) {
tmp = (0.3333333333333333 * (sqrt((a * (-3.0 * c))) - 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 <= (-5.2d0)) then
tmp = 1.0d0 / (a / (b * (-0.6666666666666666d0)))
else if (b <= 6d-73) then
tmp = (0.3333333333333333d0 * (sqrt((a * ((-3.0d0) * c))) - 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 <= -5.2) {
tmp = 1.0 / (a / (b * -0.6666666666666666));
} else if (b <= 6e-73) {
tmp = (0.3333333333333333 * (Math.sqrt((a * (-3.0 * c))) - b)) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2: tmp = 1.0 / (a / (b * -0.6666666666666666)) elif b <= 6e-73: tmp = (0.3333333333333333 * (math.sqrt((a * (-3.0 * c))) - b)) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2) tmp = Float64(1.0 / Float64(a / Float64(b * -0.6666666666666666))); elseif (b <= 6e-73) tmp = Float64(Float64(0.3333333333333333 * Float64(sqrt(Float64(a * Float64(-3.0 * c))) - 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 <= -5.2) tmp = 1.0 / (a / (b * -0.6666666666666666)); elseif (b <= 6e-73) tmp = (0.3333333333333333 * (sqrt((a * (-3.0 * c))) - b)) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2], N[(1.0 / N[(a / N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6e-73], N[(N[(0.3333333333333333 * N[(N[Sqrt[N[(a * N[(-3.0 * 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 -5.2:\\
\;\;\;\;\frac{1}{\frac{a}{b \cdot -0.6666666666666666}}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot \left(\sqrt{a \cdot \left(-3 \cdot c\right)} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.20000000000000018Initial program 71.6%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6492.0
Applied rewrites92.0%
Applied rewrites91.8%
Applied rewrites92.0%
if -5.20000000000000018 < b < 6e-73Initial program 71.6%
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-eval71.6
Applied rewrites71.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites71.3%
Taylor expanded in c around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6463.8
Applied rewrites63.8%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
Final simplification81.8%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2)
(/ 1.0 (/ a (* b -0.6666666666666666)))
(if (<= b 6e-73)
(* 0.3333333333333333 (/ (+ b (sqrt (* -3.0 (* a c)))) a))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2) {
tmp = 1.0 / (a / (b * -0.6666666666666666));
} else if (b <= 6e-73) {
tmp = 0.3333333333333333 * ((b + sqrt((-3.0 * (a * c)))) / 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 <= (-5.2d0)) then
tmp = 1.0d0 / (a / (b * (-0.6666666666666666d0)))
else if (b <= 6d-73) then
tmp = 0.3333333333333333d0 * ((b + sqrt(((-3.0d0) * (a * c)))) / 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 <= -5.2) {
tmp = 1.0 / (a / (b * -0.6666666666666666));
} else if (b <= 6e-73) {
tmp = 0.3333333333333333 * ((b + Math.sqrt((-3.0 * (a * c)))) / a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2: tmp = 1.0 / (a / (b * -0.6666666666666666)) elif b <= 6e-73: tmp = 0.3333333333333333 * ((b + math.sqrt((-3.0 * (a * c)))) / a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2) tmp = Float64(1.0 / Float64(a / Float64(b * -0.6666666666666666))); elseif (b <= 6e-73) tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(-3.0 * Float64(a * c)))) / 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 <= -5.2) tmp = 1.0 / (a / (b * -0.6666666666666666)); elseif (b <= 6e-73) tmp = 0.3333333333333333 * ((b + sqrt((-3.0 * (a * c)))) / a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2], N[(1.0 / N[(a / N[(b * -0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6e-73], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(-3.0 * N[(a * c), $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 -5.2:\\
\;\;\;\;\frac{1}{\frac{a}{b \cdot -0.6666666666666666}}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{-3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.20000000000000018Initial program 71.6%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6492.0
Applied rewrites92.0%
Applied rewrites91.8%
Applied rewrites92.0%
if -5.20000000000000018 < b < 6e-73Initial program 71.6%
Applied rewrites61.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.1
Applied rewrites61.1%
if 6e-73 < b Initial program 15.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
Final simplification81.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -2.0) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -2.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 <= (-5d-310)) then
tmp = (b * (-2.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 <= -5e-310) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -2.0) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * -2.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 <= -5e-310) tmp = (b * -2.0) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * -2.0), $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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 73.9%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6466.1
Applied rewrites66.1%
if -4.999999999999985e-310 < b Initial program 25.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6472.6
Applied rewrites72.6%
Final simplification69.4%
(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 73.9%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6466.1
Applied rewrites66.1%
if -4.999999999999985e-310 < b Initial program 25.5%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6472.6
Applied rewrites72.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.05e-18) (/ (* b -0.6666666666666666) a) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.05e-18) {
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 <= 1.05d-18) 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 <= 1.05e-18) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.05e-18: tmp = (b * -0.6666666666666666) / a else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.05e-18) 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 <= 1.05e-18) tmp = (b * -0.6666666666666666) / a; else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.05e-18], 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 1.05 \cdot 10^{-18}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 1.05e-18Initial program 67.5%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if 1.05e-18 < b Initial program 16.8%
Applied rewrites7.5%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.5
Applied rewrites39.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.05e-18) (* b (/ -0.6666666666666666 a)) (/ (* c 0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.05e-18) {
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 <= 1.05d-18) 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 <= 1.05e-18) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = (c * 0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.05e-18: tmp = b * (-0.6666666666666666 / a) else: tmp = (c * 0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.05e-18) tmp = Float64(b * Float64(-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 <= 1.05e-18) tmp = b * (-0.6666666666666666 / a); else tmp = (c * 0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.05e-18], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{-18}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 0.5}{b}\\
\end{array}
\end{array}
if b < 1.05e-18Initial program 67.5%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
Applied rewrites51.6%
if 1.05e-18 < b Initial program 16.8%
Applied rewrites7.5%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.5
Applied rewrites39.5%
Final simplification47.3%
(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 49.5%
Applied rewrites28.8%
Taylor expanded in b around -inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6416.1
Applied rewrites16.1%
(FPCore (a b c) :precision binary64 (* 0.6666666666666666 (/ b a)))
double code(double a, double b, double c) {
return 0.6666666666666666 * (b / 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.6666666666666666d0 * (b / a)
end function
public static double code(double a, double b, double c) {
return 0.6666666666666666 * (b / a);
}
def code(a, b, c): return 0.6666666666666666 * (b / a)
function code(a, b, c) return Float64(0.6666666666666666 * Float64(b / a)) end
function tmp = code(a, b, c) tmp = 0.6666666666666666 * (b / a); end
code[a_, b_, c_] := N[(0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.6666666666666666 \cdot \frac{b}{a}
\end{array}
Initial program 49.5%
Applied rewrites28.8%
Taylor expanded in c around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f642.3
Applied rewrites2.3%
Applied rewrites2.3%
Final simplification2.3%
herbie shell --seed 2024228
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))