
(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 15 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 (* (* b b) b))
(t_2 (+ (sqrt t_0) b)))
(if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -10.0)
(/ 0.3333333333333333 (/ a (- (/ t_0 t_2) (/ (* b b) t_2))))
(/
0.3333333333333333
(/
(fma
(fma
(fma
(- c)
(* -0.5625 (/ (* (* a a) a) (* t_1 (* b b))))
(/ (* 0.375 (* a a)) t_1))
c
(* 0.5 (/ a b)))
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 = (b * b) * b;
double t_2 = 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_2) - ((b * b) / t_2)));
} else {
tmp = 0.3333333333333333 / (fma(fma(fma(-c, (-0.5625 * (((a * a) * a) / (t_1 * (b * b)))), ((0.375 * (a * a)) / t_1)), c, (0.5 * (a / b))), 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(Float64(b * b) * b) t_2 = 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_2) - Float64(Float64(b * b) / t_2)))); else tmp = Float64(0.3333333333333333 / Float64(fma(fma(fma(Float64(-c), Float64(-0.5625 * Float64(Float64(Float64(a * a) * a) / Float64(t_1 * Float64(b * b)))), Float64(Float64(0.375 * Float64(a * a)) / t_1)), c, Float64(0.5 * Float64(a / b))), 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[(b * b), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = 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$2), $MachinePrecision] - N[(N[(b * b), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(N[(N[(N[((-c) * N[(-0.5625 * N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] / N[(t$95$1 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.375 * N[(a * a), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * c + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $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 := \left(b \cdot b\right) \cdot b\\
t_2 := \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\_2} - \frac{b \cdot b}{t\_2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-c, -0.5625 \cdot \frac{\left(a \cdot a\right) \cdot a}{t\_1 \cdot \left(b \cdot b\right)}, \frac{0.375 \cdot \left(a \cdot a\right)}{t\_1}\right), c, 0.5 \cdot \frac{a}{b}\right), 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%
Applied rewrites94.3%
Final simplification93.8%
(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)) -1.62)
(/ 0.3333333333333333 (/ a (- (/ t_0 t_1) (/ (* b b) t_1))))
(/
0.3333333333333333
(/
(fma
(/ (fma (* 0.375 (* a a)) (/ c (* b b)) (* 0.5 a)) b)
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)) <= -1.62) {
tmp = 0.3333333333333333 / (a / ((t_0 / t_1) - ((b * b) / t_1)));
} else {
tmp = 0.3333333333333333 / (fma((fma((0.375 * (a * a)), (c / (b * b)), (0.5 * a)) / b), 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)) <= -1.62) 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(Float64(0.375 * Float64(a * a)), Float64(c / Float64(b * b)), Float64(0.5 * a)) / b), 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], -1.62], 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[(N[(0.375 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * a), $MachinePrecision]), $MachinePrecision] / b), $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 -1.62:\\
\;\;\;\;\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(\frac{\mathsf{fma}\left(0.375 \cdot \left(a \cdot a\right), \frac{c}{b \cdot b}, 0.5 \cdot a\right)}{b}, 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)) < -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
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 rewrites86.8%
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 c around 0
Applied rewrites94.7%
Taylor expanded in a around 0
Applied rewrites94.7%
Taylor expanded in b around inf
Applied rewrites92.2%
Final simplification91.5%
(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 (* 0.375 (* a a)) (/ c (* b b)) (* 0.5 a)) b)
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((0.375 * (a * a)), (c / (b * b)), (0.5 * a)) / b), 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(Float64(0.375 * Float64(a * a)), Float64(c / Float64(b * b)), Float64(0.5 * a)) / b), 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[(N[(0.375 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(0.5 * a), $MachinePrecision]), $MachinePrecision] / b), $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(\frac{\mathsf{fma}\left(0.375 \cdot \left(a \cdot a\right), \frac{c}{b \cdot b}, 0.5 \cdot a\right)}{b}, 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 rewrites91.7%
Final simplification91.5%
(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 a)) (+ (sqrt t_0) b))
(/
0.3333333333333333
(fma
(fma (* (/ c (* (* b b) b)) 0.375) a (/ 0.5 b))
a
(* (/ b c) -0.6666666666666666))))))
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 / a)) / (sqrt(t_0) + b);
} else {
tmp = 0.3333333333333333 / fma(fma(((c / ((b * b) * b)) * 0.375), a, (0.5 / b)), a, ((b / c) * -0.6666666666666666));
}
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)) * Float64(0.3333333333333333 / a)) / Float64(sqrt(t_0) + b)); else tmp = Float64(0.3333333333333333 / fma(fma(Float64(Float64(c / Float64(Float64(b * b) * b)) * 0.375), a, Float64(0.5 / b)), a, Float64(Float64(b / c) * -0.6666666666666666))); 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] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(N[(N[(N[(c / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision] * a + N[(0.5 / b), $MachinePrecision]), $MachinePrecision] * a + N[(N[(b / c), $MachinePrecision] * -0.6666666666666666), $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 \frac{0.3333333333333333}{a}}{\sqrt{t\_0} + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{c}{\left(b \cdot b\right) \cdot b} \cdot 0.375, a, \frac{0.5}{b}\right), a, \frac{b}{c} \cdot -0.6666666666666666\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
associate-*r/N/A
lower-/.f64N/A
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 a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites92.2%
Final simplification91.5%
(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
(fma (* (/ c (* (* b b) b)) 0.375) a (/ 0.5 b))
a
(* (/ b c) -0.6666666666666666))))))
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(fma(((c / ((b * b) * b)) * 0.375), a, (0.5 / b)), a, ((b / c) * -0.6666666666666666));
}
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(fma(Float64(Float64(c / Float64(Float64(b * b) * b)) * 0.375), a, Float64(0.5 / b)), a, Float64(Float64(b / c) * -0.6666666666666666))); 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[(N[(N[(N[(c / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision] * a + N[(0.5 / b), $MachinePrecision]), $MachinePrecision] * a + N[(N[(b / c), $MachinePrecision] * -0.6666666666666666), $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(\mathsf{fma}\left(\frac{c}{\left(b \cdot b\right) \cdot b} \cdot 0.375, a, \frac{0.5}{b}\right), a, \frac{b}{c} \cdot -0.6666666666666666\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 a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites92.2%
Final simplification91.5%
(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
(fma (* (/ c (* (* b b) b)) 0.375) a (/ 0.5 b))
a
(* (/ b c) -0.6666666666666666))))))
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(fma(((c / ((b * b) * b)) * 0.375), a, (0.5 / b)), a, ((b / c) * -0.6666666666666666));
}
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(fma(Float64(Float64(c / Float64(Float64(b * b) * b)) * 0.375), a, Float64(0.5 / b)), a, Float64(Float64(b / c) * -0.6666666666666666))); 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[(N[(N[(N[(c / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.375), $MachinePrecision] * a + N[(0.5 / b), $MachinePrecision]), $MachinePrecision] * a + N[(N[(b / c), $MachinePrecision] * -0.6666666666666666), $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(\mathsf{fma}\left(\frac{c}{\left(b \cdot b\right) \cdot b} \cdot 0.375, a, \frac{0.5}{b}\right), a, \frac{b}{c} \cdot -0.6666666666666666\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 a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites92.2%
Final simplification91.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* -3.0 c) a (* b b))))
(if (<= b 6.7)
(/ (* (- t_0 (* b b)) 0.3333333333333333) (* (+ (sqrt t_0) b) a))
(/
0.3333333333333333
(fma (/ b c) -0.6666666666666666 (* 0.5 (/ a b)))))))
double code(double a, double b, double c) {
double t_0 = fma((-3.0 * c), a, (b * b));
double tmp;
if (b <= 6.7) {
tmp = ((t_0 - (b * b)) * 0.3333333333333333) / ((sqrt(t_0) + b) * a);
} else {
tmp = 0.3333333333333333 / fma((b / c), -0.6666666666666666, (0.5 * (a / b)));
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-3.0 * c), a, Float64(b * b)) tmp = 0.0 if (b <= 6.7) tmp = Float64(Float64(Float64(t_0 - Float64(b * b)) * 0.3333333333333333) / Float64(Float64(sqrt(t_0) + b) * a)); else tmp = Float64(0.3333333333333333 / fma(Float64(b / c), -0.6666666666666666, Float64(0.5 * Float64(a / b)))); 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[b, 6.7], 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[(N[(b / c), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 6.7:\\
\;\;\;\;\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(\frac{b}{c}, -0.6666666666666666, 0.5 \cdot \frac{a}{b}\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-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift--.f64N/A
flip--N/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites82.1%
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 c around 0
Applied rewrites94.9%
Taylor expanded in a around 0
Applied rewrites94.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6488.4
Applied rewrites88.4%
Final simplification87.1%
(FPCore (a b c) :precision binary64 (if (<= b 6.7) (/ (- (sqrt (fma b b (* (* c a) -3.0))) b) (* a 3.0)) (/ 0.3333333333333333 (fma (/ b c) -0.6666666666666666 (* 0.5 (/ a b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.7) {
tmp = (sqrt(fma(b, b, ((c * a) * -3.0))) - b) / (a * 3.0);
} else {
tmp = 0.3333333333333333 / fma((b / c), -0.6666666666666666, (0.5 * (a / b)));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 6.7) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(c * a) * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(0.3333333333333333 / fma(Float64(b / c), -0.6666666666666666, Float64(0.5 * Float64(a / b)))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 6.7], N[(N[(N[Sqrt[N[(b * b + N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 / N[(N[(b / c), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.7:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{\mathsf{fma}\left(\frac{b}{c}, -0.6666666666666666, 0.5 \cdot \frac{a}{b}\right)}\\
\end{array}
\end{array}
if b < 6.70000000000000018Initial program 80.9%
Taylor expanded in b around 0
cancel-sign-sub-invN/A
unpow2N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/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 c around 0
Applied rewrites94.9%
Taylor expanded in a around 0
Applied rewrites94.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/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 (/ b c) -0.6666666666666666 (* 0.5 (/ a b))))))
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((b / c), -0.6666666666666666, (0.5 * (a / b)));
}
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(Float64(b / c), -0.6666666666666666, Float64(0.5 * Float64(a / b)))); 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[(N[(b / c), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(a / b), $MachinePrecision]), $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(\frac{b}{c}, -0.6666666666666666, 0.5 \cdot \frac{a}{b}\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 c around 0
Applied rewrites94.9%
Taylor expanded in a around 0
Applied rewrites94.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6488.4
Applied rewrites88.4%
Final simplification86.8%
(FPCore (a b c) :precision binary64 (/ 0.3333333333333333 (fma (/ b c) -0.6666666666666666 (* 0.5 (/ a b)))))
double code(double a, double b, double c) {
return 0.3333333333333333 / fma((b / c), -0.6666666666666666, (0.5 * (a / b)));
}
function code(a, b, c) return Float64(0.3333333333333333 / fma(Float64(b / c), -0.6666666666666666, Float64(0.5 * Float64(a / b)))) end
code[a_, b_, c_] := N[(0.3333333333333333 / N[(N[(b / c), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.3333333333333333}{\mathsf{fma}\left(\frac{b}{c}, -0.6666666666666666, 0.5 \cdot \frac{a}{b}\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 c around 0
Applied rewrites91.4%
Taylor expanded in a around 0
Applied rewrites91.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.6
Applied rewrites82.6%
Final simplification82.6%
(FPCore (a b c) :precision binary64 (/ 0.3333333333333333 (fma (/ a b) 0.5 (* (/ b c) -0.6666666666666666))))
double code(double a, double b, double c) {
return 0.3333333333333333 / fma((a / b), 0.5, ((b / c) * -0.6666666666666666));
}
function code(a, b, c) return Float64(0.3333333333333333 / fma(Float64(a / b), 0.5, Float64(Float64(b / c) * -0.6666666666666666))) end
code[a_, b_, c_] := N[(0.3333333333333333 / N[(N[(a / b), $MachinePrecision] * 0.5 + N[(N[(b / c), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.3333333333333333}{\mathsf{fma}\left(\frac{a}{b}, 0.5, \frac{b}{c} \cdot -0.6666666666666666\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 a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.5
Applied rewrites82.5%
(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 b around inf
*-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 b around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6464.1
Applied rewrites64.1%
Applied rewrites64.0%
Final simplification64.0%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\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%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f6455.1
Applied rewrites55.1%
Taylor expanded in c around 0
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgt3.2
Applied rewrites3.2%
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)))