
(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
(let* ((t_0 (fma (* -3.0 c) a (* b b))) (t_1 (+ (sqrt t_0) b)))
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -10.0)
(/ 0.3333333333333333 (/ a (- (/ t_0 t_1) (/ (* b b) t_1))))
(/
0.3333333333333333
(/
(fma
(*
(fma
a
(/ (fma 0.5625 (/ (* (* c c) a) (* b b)) (* 0.375 c)) (* (* b b) b))
(/ 0.5 b))
a)
c
(* -0.6666666666666666 b))
c)))))
double code(double a, double b, double c) {
double t_0 = fma((-3.0 * c), a, (b * b));
double t_1 = sqrt(t_0) + b;
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -10.0) {
tmp = 0.3333333333333333 / (a / ((t_0 / t_1) - ((b * b) / t_1)));
} else {
tmp = 0.3333333333333333 / (fma((fma(a, (fma(0.5625, (((c * c) * a) / (b * b)), (0.375 * c)) / ((b * b) * b)), (0.5 / b)) * a), c, (-0.6666666666666666 * b)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-3.0 * c), a, Float64(b * b)) t_1 = Float64(sqrt(t_0) + b) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -10.0) tmp = Float64(0.3333333333333333 / Float64(a / Float64(Float64(t_0 / t_1) - Float64(Float64(b * b) / t_1)))); else tmp = Float64(0.3333333333333333 / Float64(fma(Float64(fma(a, Float64(fma(0.5625, Float64(Float64(Float64(c * c) * a) / Float64(b * b)), Float64(0.375 * c)) / Float64(Float64(b * b) * b)), Float64(0.5 / b)) * a), c, Float64(-0.6666666666666666 * b)) / c)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -10.0], N[(0.3333333333333333 / N[(a / N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[(N[(b * b), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(N[(N[(N[(a * N[(N[(0.5625 * N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.375 * c), $MachinePrecision]), $MachinePrecision] / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] + N[(0.5 / b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * c + N[(-0.6666666666666666 * b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)\\
t_1 := \sqrt{t\_0} + b\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\
\;\;\;\;\frac{0.3333333333333333}{\frac{a}{\frac{t\_0}{t\_1} - \frac{b \cdot b}{t\_1}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(a, \frac{\mathsf{fma}\left(0.5625, \frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, 0.375 \cdot c\right)}{\left(b \cdot b\right) \cdot b}, \frac{0.5}{b}\right) \cdot a, c, -0.6666666666666666 \cdot b\right)}{c}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -10Initial program 88.5%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6488.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6488.6
Applied rewrites88.7%
lift--.f64N/A
flip--N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites89.9%
if -10 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 52.4%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6452.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6452.4
Applied rewrites52.4%
Taylor expanded in c around 0
Applied rewrites94.3%
Taylor expanded in a around 0
Applied rewrites94.3%
Taylor expanded in b around inf
Applied rewrites94.3%
Final simplification93.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* -3.0 c) a (* b b))))
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -10.0)
(/ (* (- t_0 (* b b)) (/ 0.3333333333333333 a)) (+ (sqrt t_0) b))
(/
0.3333333333333333
(/
(fma
(*
(fma
a
(/ (fma 0.5625 (/ (* (* c c) a) (* b b)) (* 0.375 c)) (* (* b b) b))
(/ 0.5 b))
a)
c
(* -0.6666666666666666 b))
c)))))
double code(double a, double b, double c) {
double t_0 = fma((-3.0 * c), a, (b * b));
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -10.0) {
tmp = ((t_0 - (b * b)) * (0.3333333333333333 / a)) / (sqrt(t_0) + b);
} else {
tmp = 0.3333333333333333 / (fma((fma(a, (fma(0.5625, (((c * c) * a) / (b * b)), (0.375 * c)) / ((b * b) * b)), (0.5 / b)) * a), c, (-0.6666666666666666 * b)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-3.0 * c), a, Float64(b * b)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -10.0) tmp = Float64(Float64(Float64(t_0 - Float64(b * b)) * Float64(0.3333333333333333 / a)) / Float64(sqrt(t_0) + b)); else tmp = Float64(0.3333333333333333 / Float64(fma(Float64(fma(a, Float64(fma(0.5625, Float64(Float64(Float64(c * c) * a) / Float64(b * b)), Float64(0.375 * c)) / Float64(Float64(b * b) * b)), Float64(0.5 / b)) * a), c, Float64(-0.6666666666666666 * b)) / c)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -10.0], N[(N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(N[(N[(N[(a * N[(N[(0.5625 * N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.375 * c), $MachinePrecision]), $MachinePrecision] / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] + N[(0.5 / b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * c + N[(-0.6666666666666666 * b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\
\;\;\;\;\frac{\left(t\_0 - b \cdot b\right) \cdot \frac{0.3333333333333333}{a}}{\sqrt{t\_0} + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(a, \frac{\mathsf{fma}\left(0.5625, \frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, 0.375 \cdot c\right)}{\left(b \cdot b\right) \cdot b}, \frac{0.5}{b}\right) \cdot a, c, -0.6666666666666666 \cdot b\right)}{c}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -10Initial program 88.5%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6488.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6488.6
Applied rewrites88.7%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift--.f64N/A
flip--N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites89.8%
if -10 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 52.4%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6452.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6452.4
Applied rewrites52.4%
Taylor expanded in c around 0
Applied rewrites94.3%
Taylor expanded in a around 0
Applied rewrites94.3%
Taylor expanded in b around inf
Applied rewrites94.3%
Final simplification93.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* -3.0 c) a (* b b))))
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -10.0)
(/ (* (- t_0 (* b b)) (/ 0.3333333333333333 a)) (+ (sqrt t_0) b))
(/
0.3333333333333333
(fma
-0.6666666666666666
(/ b c)
(* (/ (fma 0.375 (* (/ c (* b b)) a) 0.5) b) a))))))
double code(double a, double b, double c) {
double t_0 = fma((-3.0 * c), a, (b * b));
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -10.0) {
tmp = ((t_0 - (b * b)) * (0.3333333333333333 / a)) / (sqrt(t_0) + b);
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((fma(0.375, ((c / (b * b)) * a), 0.5) / b) * a));
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-3.0 * c), a, Float64(b * b)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -10.0) tmp = Float64(Float64(Float64(t_0 - Float64(b * b)) * Float64(0.3333333333333333 / a)) / Float64(sqrt(t_0) + b)); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(fma(0.375, Float64(Float64(c / Float64(b * b)) * a), 0.5) / b) * a))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -10.0], N[(N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(N[(0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + 0.5), $MachinePrecision] / b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\
\;\;\;\;\frac{\left(t\_0 - b \cdot b\right) \cdot \frac{0.3333333333333333}{a}}{\sqrt{t\_0} + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{\mathsf{fma}\left(0.375, \frac{c}{b \cdot b} \cdot a, 0.5\right)}{b} \cdot a\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -10Initial program 88.5%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6488.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6488.6
Applied rewrites88.7%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift--.f64N/A
flip--N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites89.8%
if -10 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 52.4%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6452.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6452.4
Applied rewrites52.4%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6486.2
Applied rewrites86.2%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites91.8%
Taylor expanded in b around inf
Applied rewrites91.8%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* -3.0 c) a (* b b))))
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -1.62)
(/ (- t_0 (* b b)) (* (+ (sqrt t_0) b) (* a 3.0)))
(/
0.3333333333333333
(fma
-0.6666666666666666
(/ b c)
(* (/ (fma 0.375 (* (/ c (* b b)) a) 0.5) b) a))))))
double code(double a, double b, double c) {
double t_0 = fma((-3.0 * c), a, (b * b));
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -1.62) {
tmp = (t_0 - (b * b)) / ((sqrt(t_0) + b) * (a * 3.0));
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((fma(0.375, ((c / (b * b)) * a), 0.5) / b) * a));
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-3.0 * c), a, Float64(b * b)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -1.62) tmp = Float64(Float64(t_0 - Float64(b * b)) / Float64(Float64(sqrt(t_0) + b) * Float64(a * 3.0))); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(fma(0.375, Float64(Float64(c / Float64(b * b)) * a), 0.5) / b) * a))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -1.62], N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(N[(0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + 0.5), $MachinePrecision] / b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1.62:\\
\;\;\;\;\frac{t\_0 - b \cdot b}{\left(\sqrt{t\_0} + b\right) \cdot \left(a \cdot 3\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{\mathsf{fma}\left(0.375, \frac{c}{b \cdot b} \cdot a, 0.5\right)}{b} \cdot a\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -1.6200000000000001Initial program 85.4%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6485.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6485.4
Applied rewrites85.5%
Applied rewrites86.7%
if -1.6200000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 51.7%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6451.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6451.7
Applied rewrites51.7%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6486.7
Applied rewrites86.7%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites92.3%
Taylor expanded in b around inf
Applied rewrites92.3%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* -3.0 c) a (* b b))))
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -1.62)
(/ (* (- t_0 (* b b)) 0.3333333333333333) (* (+ (sqrt t_0) b) a))
(/
0.3333333333333333
(fma
-0.6666666666666666
(/ b c)
(* (/ (fma 0.375 (* (/ c (* b b)) a) 0.5) b) a))))))
double code(double a, double b, double c) {
double t_0 = fma((-3.0 * c), a, (b * b));
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -1.62) {
tmp = ((t_0 - (b * b)) * 0.3333333333333333) / ((sqrt(t_0) + b) * a);
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((fma(0.375, ((c / (b * b)) * a), 0.5) / b) * a));
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-3.0 * c), a, Float64(b * b)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -1.62) tmp = Float64(Float64(Float64(t_0 - Float64(b * b)) * 0.3333333333333333) / Float64(Float64(sqrt(t_0) + b) * a)); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(fma(0.375, Float64(Float64(c / Float64(b * b)) * a), 0.5) / b) * a))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -1.62], N[(N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(N[(0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + 0.5), $MachinePrecision] / b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1.62:\\
\;\;\;\;\frac{\left(t\_0 - b \cdot b\right) \cdot 0.3333333333333333}{\left(\sqrt{t\_0} + b\right) \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{\mathsf{fma}\left(0.375, \frac{c}{b \cdot b} \cdot a, 0.5\right)}{b} \cdot a\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -1.6200000000000001Initial program 85.4%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6485.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6485.4
Applied rewrites85.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift--.f64N/A
flip--N/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites86.6%
if -1.6200000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 51.7%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6451.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6451.7
Applied rewrites51.7%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6486.7
Applied rewrites86.7%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites92.3%
Taylor expanded in b around inf
Applied rewrites92.3%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -10.0)
(/ 0.3333333333333333 (/ a (- (sqrt (fma (* c a) -3.0 (* b b))) b)))
(/
0.3333333333333333
(fma
-0.6666666666666666
(/ b c)
(* (/ (fma 0.375 (* (/ c (* b b)) a) 0.5) b) a)))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -10.0) {
tmp = 0.3333333333333333 / (a / (sqrt(fma((c * a), -3.0, (b * b))) - b));
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((fma(0.375, ((c / (b * b)) * a), 0.5) / b) * a));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -10.0) tmp = Float64(0.3333333333333333 / Float64(a / Float64(sqrt(fma(Float64(c * a), -3.0, Float64(b * b))) - b))); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(fma(0.375, Float64(Float64(c / Float64(b * b)) * a), 0.5) / b) * a))); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -10.0], N[(0.3333333333333333 / N[(a / N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(N[(0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + 0.5), $MachinePrecision] / b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -10:\\
\;\;\;\;\frac{0.3333333333333333}{\frac{a}{\sqrt{\mathsf{fma}\left(c \cdot a, -3, b \cdot b\right)} - b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{\mathsf{fma}\left(0.375, \frac{c}{b \cdot b} \cdot a, 0.5\right)}{b} \cdot a\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -10Initial program 88.5%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6488.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6488.6
Applied rewrites88.7%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6488.8
Applied rewrites88.8%
if -10 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 52.4%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6452.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6452.4
Applied rewrites52.4%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6486.2
Applied rewrites86.2%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites91.8%
Taylor expanded in b around inf
Applied rewrites91.8%
Final simplification91.5%
(FPCore (a b c)
:precision binary64
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -1.15)
(fma
(/ 0.3333333333333333 a)
(sqrt (fma (* -3.0 c) a (* b b)))
(* (/ 0.3333333333333333 a) (- b)))
(/ 0.3333333333333333 (fma -0.6666666666666666 (/ b c) (* (/ a b) 0.5)))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -1.15) {
tmp = fma((0.3333333333333333 / a), sqrt(fma((-3.0 * c), a, (b * b))), ((0.3333333333333333 / a) * -b));
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((a / b) * 0.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -1.15) tmp = fma(Float64(0.3333333333333333 / a), sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))), Float64(Float64(0.3333333333333333 / a) * Float64(-b))); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(a / b) * 0.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -1.15], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(0.3333333333333333 / a), $MachinePrecision] * (-b)), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1.15:\\
\;\;\;\;\mathsf{fma}\left(\frac{0.3333333333333333}{a}, \sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)}, \frac{0.3333333333333333}{a} \cdot \left(-b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{a}{b} \cdot 0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -1.1499999999999999Initial program 84.2%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6484.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6484.2
Applied rewrites84.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f6484.8
Applied rewrites84.8%
if -1.1499999999999999 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 51.2%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6451.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6451.2
Applied rewrites51.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6487.1
Applied rewrites87.1%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.2
Applied rewrites87.2%
Final simplification86.8%
(FPCore (a b c) :precision binary64 (if (<= b 6.7) (/ 0.3333333333333333 (/ a (- (sqrt (fma b b (* (* -3.0 c) a))) b))) (/ 0.3333333333333333 (fma -0.6666666666666666 (/ b c) (* (/ a b) 0.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.7) {
tmp = 0.3333333333333333 / (a / (sqrt(fma(b, b, ((-3.0 * c) * a))) - b));
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((a / b) * 0.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 6.7) tmp = Float64(0.3333333333333333 / Float64(a / Float64(sqrt(fma(b, b, Float64(Float64(-3.0 * c) * a))) - b))); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(a / b) * 0.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 6.7], N[(0.3333333333333333 / N[(a / N[(N[Sqrt[N[(b * b + N[(N[(-3.0 * c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.7:\\
\;\;\;\;\frac{0.3333333333333333}{\frac{a}{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} - b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{a}{b} \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.70000000000000018Initial program 80.9%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6480.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6480.9
Applied rewrites80.9%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6481.0
Applied rewrites81.0%
if 6.70000000000000018 < b Initial program 49.0%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6449.0
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6449.0
Applied rewrites49.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6488.4
Applied rewrites88.4%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6488.4
Applied rewrites88.4%
Final simplification86.8%
(FPCore (a b c) :precision binary64 (if (<= b 6.7) (/ (- (sqrt (fma b b (* (* -3.0 a) c))) b) (* a 3.0)) (/ 0.3333333333333333 (fma -0.6666666666666666 (/ b c) (* (/ a b) 0.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.7) {
tmp = (sqrt(fma(b, b, ((-3.0 * a) * c))) - b) / (a * 3.0);
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((a / b) * 0.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 6.7) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(a / b) * 0.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 6.7], N[(N[(N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.7:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{a}{b} \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.70000000000000018Initial program 80.9%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval81.0
Applied rewrites81.0%
if 6.70000000000000018 < b Initial program 49.0%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6449.0
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6449.0
Applied rewrites49.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6488.4
Applied rewrites88.4%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6488.4
Applied rewrites88.4%
Final simplification86.8%
(FPCore (a b c) :precision binary64 (if (<= b 6.7) (* (- (sqrt (fma (* -3.0 c) a (* b b))) b) (/ 0.3333333333333333 a)) (/ 0.3333333333333333 (fma -0.6666666666666666 (/ b c) (* (/ a b) 0.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.7) {
tmp = (sqrt(fma((-3.0 * c), a, (b * b))) - b) * (0.3333333333333333 / a);
} else {
tmp = 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((a / b) * 0.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 6.7) tmp = Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(a / b) * 0.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 6.7], N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.7:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{a}{b} \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.70000000000000018Initial program 80.9%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval80.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6480.9
Applied rewrites80.9%
if 6.70000000000000018 < b Initial program 49.0%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6449.0
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6449.0
Applied rewrites49.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6488.4
Applied rewrites88.4%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6488.4
Applied rewrites88.4%
Final simplification86.8%
(FPCore (a b c) :precision binary64 (/ 0.3333333333333333 (fma -0.6666666666666666 (/ b c) (* (/ a b) 0.5))))
double code(double a, double b, double c) {
return 0.3333333333333333 / fma(-0.6666666666666666, (b / c), ((a / b) * 0.5));
}
function code(a, b, c) return Float64(0.3333333333333333 / fma(-0.6666666666666666, Float64(b / c), Float64(Float64(a / b) * 0.5))) end
code[a_, b_, c_] := N[(0.3333333333333333 / N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, \frac{a}{b} \cdot 0.5\right)}
\end{array}
Initial program 55.9%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
lower-/.f6456.0
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6456.0
Applied rewrites56.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6482.5
Applied rewrites82.5%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6482.6
Applied rewrites82.6%
Final simplification82.6%
(FPCore (a b c) :precision binary64 (/ (* (fma (* (/ c (* b b)) a) -0.375 -0.5) c) b))
double code(double a, double b, double c) {
return (fma(((c / (b * b)) * a), -0.375, -0.5) * c) / b;
}
function code(a, b, c) return Float64(Float64(fma(Float64(Float64(c / Float64(b * b)) * a), -0.375, -0.5) * c) / b) end
code[a_, b_, c_] := N[(N[(N[(N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * -0.375 + -0.5), $MachinePrecision] * c), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\frac{c}{b \cdot b} \cdot a, -0.375, -0.5\right) \cdot c}{b}
\end{array}
Initial program 55.9%
Taylor expanded in b around inf
lower-/.f64N/A
Applied rewrites88.0%
Taylor expanded in c around 0
Applied rewrites81.8%
Final simplification81.8%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 55.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6464.1
Applied rewrites64.1%
(FPCore (a b c) :precision binary64 (* (/ -0.5 b) c))
double code(double a, double b, double c) {
return (-0.5 / b) * c;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((-0.5d0) / b) * c
end function
public static double code(double a, double b, double c) {
return (-0.5 / b) * c;
}
def code(a, b, c): return (-0.5 / b) * c
function code(a, b, c) return Float64(Float64(-0.5 / b) * c) end
function tmp = code(a, b, c) tmp = (-0.5 / b) * c; end
code[a_, b_, c_] := N[(N[(-0.5 / b), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{b} \cdot c
\end{array}
Initial program 55.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6464.1
Applied rewrites64.1%
Applied rewrites64.0%
Final simplification64.0%
herbie shell --seed 2024235
(FPCore (a b c)
:name "Cubic critical, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))