
(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 (* c -3.0) a (* b b))))
(if (<= b 0.028)
(/ 1.0 (/ (* 3.0 a) (* (pow (+ (sqrt t_0) b) -1.0) (- t_0 (* b b)))))
(/
1.0
(*
(fma
(/
(* (fma (* c c) 0.84375 (* -1.40625 (* c c))) (pow a 3.0))
(pow b 6.0))
-3.0
(fma
(/ (* (* (* a a) c) -0.375) (pow b 4.0))
-3.0
(fma (/ a (* b b)) 1.5 (/ -2.0 c))))
b)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 0.028) {
tmp = 1.0 / ((3.0 * a) / (pow((sqrt(t_0) + b), -1.0) * (t_0 - (b * b))));
} else {
tmp = 1.0 / (fma(((fma((c * c), 0.84375, (-1.40625 * (c * c))) * pow(a, 3.0)) / pow(b, 6.0)), -3.0, fma(((((a * a) * c) * -0.375) / pow(b, 4.0)), -3.0, fma((a / (b * b)), 1.5, (-2.0 / c)))) * b);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 0.028) tmp = Float64(1.0 / Float64(Float64(3.0 * a) / Float64((Float64(sqrt(t_0) + b) ^ -1.0) * Float64(t_0 - Float64(b * b))))); else tmp = Float64(1.0 / Float64(fma(Float64(Float64(fma(Float64(c * c), 0.84375, Float64(-1.40625 * Float64(c * c))) * (a ^ 3.0)) / (b ^ 6.0)), -3.0, fma(Float64(Float64(Float64(Float64(a * a) * c) * -0.375) / (b ^ 4.0)), -3.0, fma(Float64(a / Float64(b * b)), 1.5, Float64(-2.0 / c)))) * b)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.028], N[(1.0 / N[(N[(3.0 * a), $MachinePrecision] / N[(N[Power[N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision], -1.0], $MachinePrecision] * N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(N[(N[(c * c), $MachinePrecision] * 0.84375 + N[(-1.40625 * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] * -3.0 + N[(N[(N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] * -0.375), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] * -3.0 + N[(N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision] * 1.5 + N[(-2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 0.028:\\
\;\;\;\;\frac{1}{\frac{3 \cdot a}{{\left(\sqrt{t\_0} + b\right)}^{-1} \cdot \left(t\_0 - b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(c \cdot c, 0.84375, -1.40625 \cdot \left(c \cdot c\right)\right) \cdot {a}^{3}}{{b}^{6}}, -3, \mathsf{fma}\left(\frac{\left(\left(a \cdot a\right) \cdot c\right) \cdot -0.375}{{b}^{4}}, -3, \mathsf{fma}\left(\frac{a}{b \cdot b}, 1.5, \frac{-2}{c}\right)\right)\right) \cdot b}\\
\end{array}
\end{array}
if b < 0.0280000000000000006Initial program 90.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6490.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6490.5
Applied rewrites90.4%
lift--.f64N/A
flip--N/A
div-invN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-+.f6491.7
Applied rewrites91.7%
if 0.0280000000000000006 < b Initial program 51.1%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6451.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.1
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6451.1
Applied rewrites51.1%
Taylor expanded in b around inf
Applied rewrites92.4%
Taylor expanded in a around 0
Applied rewrites92.4%
Final simplification92.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 0.0295)
(/ 1.0 (/ (* 3.0 a) (* (pow (+ (sqrt t_0) b) -1.0) (- t_0 (* b b)))))
(fma
(/
(fma
(* (pow c 4.0) -1.0546875)
(* a a)
(* (* (fma (* c a) -0.5625 (* -0.375 (* b b))) (* c c)) (* b b)))
(pow b 7.0))
a
(* (/ c b) -0.5)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 0.0295) {
tmp = 1.0 / ((3.0 * a) / (pow((sqrt(t_0) + b), -1.0) * (t_0 - (b * b))));
} else {
tmp = fma((fma((pow(c, 4.0) * -1.0546875), (a * a), ((fma((c * a), -0.5625, (-0.375 * (b * b))) * (c * c)) * (b * b))) / pow(b, 7.0)), a, ((c / b) * -0.5));
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 0.0295) tmp = Float64(1.0 / Float64(Float64(3.0 * a) / Float64((Float64(sqrt(t_0) + b) ^ -1.0) * Float64(t_0 - Float64(b * b))))); else tmp = fma(Float64(fma(Float64((c ^ 4.0) * -1.0546875), Float64(a * a), Float64(Float64(fma(Float64(c * a), -0.5625, Float64(-0.375 * Float64(b * b))) * Float64(c * c)) * Float64(b * b))) / (b ^ 7.0)), a, Float64(Float64(c / b) * -0.5)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.0295], N[(1.0 / N[(N[(3.0 * a), $MachinePrecision] / N[(N[Power[N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision], -1.0], $MachinePrecision] * N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Power[c, 4.0], $MachinePrecision] * -1.0546875), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(N[(N[(N[(c * a), $MachinePrecision] * -0.5625 + N[(-0.375 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision] * a + N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 0.0295:\\
\;\;\;\;\frac{1}{\frac{3 \cdot a}{{\left(\sqrt{t\_0} + b\right)}^{-1} \cdot \left(t\_0 - b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left({c}^{4} \cdot -1.0546875, a \cdot a, \left(\mathsf{fma}\left(c \cdot a, -0.5625, -0.375 \cdot \left(b \cdot b\right)\right) \cdot \left(c \cdot c\right)\right) \cdot \left(b \cdot b\right)\right)}{{b}^{7}}, a, \frac{c}{b} \cdot -0.5\right)\\
\end{array}
\end{array}
if b < 0.029499999999999998Initial program 90.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6490.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6490.5
Applied rewrites90.4%
lift--.f64N/A
flip--N/A
div-invN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-+.f6491.7
Applied rewrites91.7%
if 0.029499999999999998 < b Initial program 51.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites92.4%
Taylor expanded in b around 0
Applied rewrites92.4%
Taylor expanded in c around 0
Applied rewrites92.4%
Final simplification92.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 0.04)
(/ 1.0 (/ (* 3.0 a) (* (pow (+ (sqrt t_0) b) -1.0) (- t_0 (* b b)))))
(/
1.0
(/
(fma
(fma (* c -3.0) (* (/ (* a a) (pow b 3.0)) -0.375) (* (/ a b) 1.5))
c
(* -2.0 b))
c)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 0.04) {
tmp = 1.0 / ((3.0 * a) / (pow((sqrt(t_0) + b), -1.0) * (t_0 - (b * b))));
} else {
tmp = 1.0 / (fma(fma((c * -3.0), (((a * a) / pow(b, 3.0)) * -0.375), ((a / b) * 1.5)), c, (-2.0 * b)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 0.04) tmp = Float64(1.0 / Float64(Float64(3.0 * a) / Float64((Float64(sqrt(t_0) + b) ^ -1.0) * Float64(t_0 - Float64(b * b))))); else tmp = Float64(1.0 / Float64(fma(fma(Float64(c * -3.0), Float64(Float64(Float64(a * a) / (b ^ 3.0)) * -0.375), Float64(Float64(a / b) * 1.5)), c, Float64(-2.0 * b)) / c)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.04], N[(1.0 / N[(N[(3.0 * a), $MachinePrecision] / N[(N[Power[N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision], -1.0], $MachinePrecision] * N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(c * -3.0), $MachinePrecision] * N[(N[(N[(a * a), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] * c + N[(-2.0 * b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 0.04:\\
\;\;\;\;\frac{1}{\frac{3 \cdot a}{{\left(\sqrt{t\_0} + b\right)}^{-1} \cdot \left(t\_0 - b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c \cdot -3, \frac{a \cdot a}{{b}^{3}} \cdot -0.375, \frac{a}{b} \cdot 1.5\right), c, -2 \cdot b\right)}{c}}\\
\end{array}
\end{array}
if b < 0.0400000000000000008Initial program 89.6%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6489.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6489.6
Applied rewrites89.5%
lift--.f64N/A
flip--N/A
div-invN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-+.f6490.9
Applied rewrites90.9%
if 0.0400000000000000008 < b Initial program 50.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6450.9
Applied rewrites50.9%
Taylor expanded in c around 0
lower-/.f64N/A
Applied rewrites90.7%
Final simplification90.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 0.04)
(/ 1.0 (/ (* 3.0 a) (/ 1.0 (/ (+ (sqrt t_0) b) (- t_0 (* b b))))))
(/
1.0
(/
(fma
(fma (* c -3.0) (* (/ (* a a) (pow b 3.0)) -0.375) (* (/ a b) 1.5))
c
(* -2.0 b))
c)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 0.04) {
tmp = 1.0 / ((3.0 * a) / (1.0 / ((sqrt(t_0) + b) / (t_0 - (b * b)))));
} else {
tmp = 1.0 / (fma(fma((c * -3.0), (((a * a) / pow(b, 3.0)) * -0.375), ((a / b) * 1.5)), c, (-2.0 * b)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 0.04) tmp = Float64(1.0 / Float64(Float64(3.0 * a) / Float64(1.0 / Float64(Float64(sqrt(t_0) + b) / Float64(t_0 - Float64(b * b)))))); else tmp = Float64(1.0 / Float64(fma(fma(Float64(c * -3.0), Float64(Float64(Float64(a * a) / (b ^ 3.0)) * -0.375), Float64(Float64(a / b) * 1.5)), c, Float64(-2.0 * b)) / c)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.04], N[(1.0 / N[(N[(3.0 * a), $MachinePrecision] / N[(1.0 / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] / N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(c * -3.0), $MachinePrecision] * N[(N[(N[(a * a), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] * c + N[(-2.0 * b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 0.04:\\
\;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{1}{\frac{\sqrt{t\_0} + b}{t\_0 - b \cdot b}}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(c \cdot -3, \frac{a \cdot a}{{b}^{3}} \cdot -0.375, \frac{a}{b} \cdot 1.5\right), c, -2 \cdot b\right)}{c}}\\
\end{array}
\end{array}
if b < 0.0400000000000000008Initial program 89.6%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6489.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6489.6
Applied rewrites89.5%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f6490.9
Applied rewrites90.9%
if 0.0400000000000000008 < b Initial program 50.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6450.9
Applied rewrites50.9%
Taylor expanded in c around 0
lower-/.f64N/A
Applied rewrites90.7%
Final simplification90.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 0.04)
(/ 1.0 (/ (* 3.0 a) (/ 1.0 (/ (+ (sqrt t_0) b) (- t_0 (* b b))))))
(/
1.0
(fma
(fma (* (* (/ c (pow b 3.0)) -0.375) a) -3.0 (/ 1.5 b))
a
(* (/ b c) -2.0))))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 0.04) {
tmp = 1.0 / ((3.0 * a) / (1.0 / ((sqrt(t_0) + b) / (t_0 - (b * b)))));
} else {
tmp = 1.0 / fma(fma((((c / pow(b, 3.0)) * -0.375) * a), -3.0, (1.5 / b)), a, ((b / c) * -2.0));
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 0.04) tmp = Float64(1.0 / Float64(Float64(3.0 * a) / Float64(1.0 / Float64(Float64(sqrt(t_0) + b) / Float64(t_0 - Float64(b * b)))))); else tmp = Float64(1.0 / fma(fma(Float64(Float64(Float64(c / (b ^ 3.0)) * -0.375) * a), -3.0, Float64(1.5 / b)), a, Float64(Float64(b / c) * -2.0))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.04], N[(1.0 / N[(N[(3.0 * a), $MachinePrecision] / N[(1.0 / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] / N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision] * a), $MachinePrecision] * -3.0 + N[(1.5 / b), $MachinePrecision]), $MachinePrecision] * a + N[(N[(b / c), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 0.04:\\
\;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{1}{\frac{\sqrt{t\_0} + b}{t\_0 - b \cdot b}}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\left(\frac{c}{{b}^{3}} \cdot -0.375\right) \cdot a, -3, \frac{1.5}{b}\right), a, \frac{b}{c} \cdot -2\right)}\\
\end{array}
\end{array}
if b < 0.0400000000000000008Initial program 89.6%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6489.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6489.6
Applied rewrites89.5%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f6490.9
Applied rewrites90.9%
if 0.0400000000000000008 < b Initial program 50.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6450.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6450.9
Applied rewrites50.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.7%
Final simplification90.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 0.0923)
(/ 1.0 (/ (* 3.0 a) (/ 1.0 (/ (+ (sqrt t_0) b) (- t_0 (* b b))))))
(*
(fma
(/ (fma (* (* b b) a) -0.375 (* -0.5625 (* (* a a) c))) (pow b 5.0))
c
(/ -0.5 b))
c))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 0.0923) {
tmp = 1.0 / ((3.0 * a) / (1.0 / ((sqrt(t_0) + b) / (t_0 - (b * b)))));
} else {
tmp = fma((fma(((b * b) * a), -0.375, (-0.5625 * ((a * a) * c))) / pow(b, 5.0)), c, (-0.5 / b)) * c;
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 0.0923) tmp = Float64(1.0 / Float64(Float64(3.0 * a) / Float64(1.0 / Float64(Float64(sqrt(t_0) + b) / Float64(t_0 - Float64(b * b)))))); else tmp = Float64(fma(Float64(fma(Float64(Float64(b * b) * a), -0.375, Float64(-0.5625 * Float64(Float64(a * a) * c))) / (b ^ 5.0)), c, Float64(-0.5 / b)) * c); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.0923], N[(1.0 / N[(N[(3.0 * a), $MachinePrecision] / N[(1.0 / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] / N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision] * -0.375 + N[(-0.5625 * N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] * c + N[(-0.5 / b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 0.0923:\\
\;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{1}{\frac{\sqrt{t\_0} + b}{t\_0 - b \cdot b}}}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\left(b \cdot b\right) \cdot a, -0.375, -0.5625 \cdot \left(\left(a \cdot a\right) \cdot c\right)\right)}{{b}^{5}}, c, \frac{-0.5}{b}\right) \cdot c\\
\end{array}
\end{array}
if b < 0.092299999999999993Initial program 87.1%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6487.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6487.1
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6487.1
Applied rewrites87.0%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f6488.7
Applied rewrites88.7%
if 0.092299999999999993 < b Initial program 50.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites92.6%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.5%
Taylor expanded in b around 0
Applied rewrites90.5%
Final simplification90.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0003)
(/ (- t_0 (* b b)) (* (* 3.0 a) (+ (sqrt t_0) b)))
(/ 1.0 (/ (fma (* (/ c b) a) 1.5 (* -2.0 b)) c)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0003) {
tmp = (t_0 - (b * b)) / ((3.0 * a) * (sqrt(t_0) + b));
} else {
tmp = 1.0 / (fma(((c / b) * a), 1.5, (-2.0 * b)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.0003) tmp = Float64(Float64(t_0 - Float64(b * b)) / Float64(Float64(3.0 * a) * Float64(sqrt(t_0) + b))); else tmp = Float64(1.0 / Float64(fma(Float64(Float64(c / b) * a), 1.5, Float64(-2.0 * b)) / c)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -0.0003], N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(3.0 * a), $MachinePrecision] * N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(c / b), $MachinePrecision] * a), $MachinePrecision] * 1.5 + N[(-2.0 * b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0003:\\
\;\;\;\;\frac{t\_0 - b \cdot b}{\left(3 \cdot a\right) \cdot \left(\sqrt{t\_0} + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\frac{c}{b} \cdot a, 1.5, -2 \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)) < -2.99999999999999974e-4Initial program 77.7%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6477.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6477.7
Applied rewrites77.7%
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
lift--.f64N/A
flip--N/A
associate-/l/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f64N/A
Applied rewrites79.6%
if -2.99999999999999974e-4 < (/.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 41.2%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6441.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6441.2
Applied rewrites41.2%
Taylor expanded in c around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6491.3
Applied rewrites91.3%
Final simplification87.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0003)
(* (/ (- t_0 (* b b)) (* (+ (sqrt t_0) b) a)) 0.3333333333333333)
(/ 1.0 (/ (fma (* (/ c b) a) 1.5 (* -2.0 b)) c)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0003) {
tmp = ((t_0 - (b * b)) / ((sqrt(t_0) + b) * a)) * 0.3333333333333333;
} else {
tmp = 1.0 / (fma(((c / b) * a), 1.5, (-2.0 * b)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.0003) tmp = Float64(Float64(Float64(t_0 - Float64(b * b)) / Float64(Float64(sqrt(t_0) + b) * a)) * 0.3333333333333333); else tmp = Float64(1.0 / Float64(fma(Float64(Float64(c / b) * a), 1.5, Float64(-2.0 * b)) / c)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -0.0003], N[(N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(c / b), $MachinePrecision] * a), $MachinePrecision] * 1.5 + N[(-2.0 * b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0003:\\
\;\;\;\;\frac{t\_0 - b \cdot b}{\left(\sqrt{t\_0} + b\right) \cdot a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\frac{c}{b} \cdot a, 1.5, -2 \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)) < -2.99999999999999974e-4Initial program 77.7%
lift-/.f64N/A
clear-numN/A
inv-powN/A
lift-*.f64N/A
associate-/l*N/A
unpow-prod-downN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-evalN/A
lower-pow.f64N/A
Applied rewrites77.7%
lift-pow.f64N/A
unpow-1N/A
lift-/.f64N/A
clear-numN/A
lift--.f64N/A
flip--N/A
associate-/l/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f64N/A
Applied rewrites79.5%
if -2.99999999999999974e-4 < (/.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 41.2%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6441.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6441.2
Applied rewrites41.2%
Taylor expanded in c around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6491.3
Applied rewrites91.3%
Final simplification87.1%
(FPCore (a b c) :precision binary64 (if (<= b 18.5) (/ (- (sqrt (fma b b (* (* -3.0 a) c))) b) (* 3.0 a)) (/ 1.0 (/ (fma (* (/ c b) a) 1.5 (* -2.0 b)) c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 18.5) {
tmp = (sqrt(fma(b, b, ((-3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = 1.0 / (fma(((c / b) * a), 1.5, (-2.0 * b)) / c);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 18.5) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(fma(Float64(Float64(c / b) * a), 1.5, Float64(-2.0 * b)) / c)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 18.5], N[(N[(N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(c / b), $MachinePrecision] * a), $MachinePrecision] * 1.5 + N[(-2.0 * b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 18.5:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\frac{c}{b} \cdot a, 1.5, -2 \cdot b\right)}{c}}\\
\end{array}
\end{array}
if b < 18.5Initial program 79.2%
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-eval79.4
Applied rewrites79.4%
if 18.5 < b Initial program 45.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.5
Applied rewrites45.5%
Taylor expanded in c around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6489.1
Applied rewrites89.1%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (if (<= b 18.5) (/ (- (sqrt (fma b b (* (* -3.0 a) c))) b) (* 3.0 a)) (/ 1.0 (fma (/ a b) 1.5 (* (/ b c) -2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 18.5) {
tmp = (sqrt(fma(b, b, ((-3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = 1.0 / fma((a / b), 1.5, ((b / c) * -2.0));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 18.5) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(1.0 / fma(Float64(a / b), 1.5, Float64(Float64(b / c) * -2.0))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 18.5], N[(N[(N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] * 1.5 + N[(N[(b / c), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 18.5:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{a}{b}, 1.5, \frac{b}{c} \cdot -2\right)}\\
\end{array}
\end{array}
if b < 18.5Initial program 79.2%
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-eval79.4
Applied rewrites79.4%
if 18.5 < b Initial program 45.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.5
Applied rewrites45.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.0
Applied rewrites89.0%
Final simplification86.5%
(FPCore (a b c) :precision binary64 (if (<= b 18.5) (* (/ (- (sqrt (fma (* -3.0 a) c (* b b))) b) a) 0.3333333333333333) (/ 1.0 (fma (/ a b) 1.5 (* (/ b c) -2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 18.5) {
tmp = ((sqrt(fma((-3.0 * a), c, (b * b))) - b) / a) * 0.3333333333333333;
} else {
tmp = 1.0 / fma((a / b), 1.5, ((b / c) * -2.0));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 18.5) tmp = Float64(Float64(Float64(sqrt(fma(Float64(-3.0 * a), c, Float64(b * b))) - b) / a) * 0.3333333333333333); else tmp = Float64(1.0 / fma(Float64(a / b), 1.5, Float64(Float64(b / c) * -2.0))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 18.5], N[(N[(N[(N[Sqrt[N[(N[(-3.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] * 1.5 + N[(N[(b / c), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 18.5:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{a}{b}, 1.5, \frac{b}{c} \cdot -2\right)}\\
\end{array}
\end{array}
if b < 18.5Initial program 79.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-*.f64N/A
associate-/l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites79.2%
lift-/.f64N/A
div-invN/A
lower-*.f64N/A
Applied rewrites79.2%
if 18.5 < b Initial program 45.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.5
Applied rewrites45.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.0
Applied rewrites89.0%
(FPCore (a b c) :precision binary64 (if (<= b 18.5) (* (- (sqrt (fma (* c -3.0) a (* b b))) b) (/ 0.3333333333333333 a)) (/ 1.0 (fma (/ a b) 1.5 (* (/ b c) -2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 18.5) {
tmp = (sqrt(fma((c * -3.0), a, (b * b))) - b) * (0.3333333333333333 / a);
} else {
tmp = 1.0 / fma((a / b), 1.5, ((b / c) * -2.0));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 18.5) tmp = Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(1.0 / fma(Float64(a / b), 1.5, Float64(Float64(b / c) * -2.0))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 18.5], N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] * 1.5 + N[(N[(b / c), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 18.5:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{a}{b}, 1.5, \frac{b}{c} \cdot -2\right)}\\
\end{array}
\end{array}
if b < 18.5Initial program 79.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval79.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6479.2
Applied rewrites79.2%
if 18.5 < b Initial program 45.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.5
Applied rewrites45.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.0
Applied rewrites89.0%
Final simplification86.5%
(FPCore (a b c) :precision binary64 (/ 1.0 (fma (/ a b) 1.5 (* (/ b c) -2.0))))
double code(double a, double b, double c) {
return 1.0 / fma((a / b), 1.5, ((b / c) * -2.0));
}
function code(a, b, c) return Float64(1.0 / fma(Float64(a / b), 1.5, Float64(Float64(b / c) * -2.0))) end
code[a_, b_, c_] := N[(1.0 / N[(N[(a / b), $MachinePrecision] * 1.5 + N[(N[(b / c), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\frac{a}{b}, 1.5, \frac{b}{c} \cdot -2\right)}
\end{array}
Initial program 54.2%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6454.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6454.2
Applied rewrites54.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
(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 54.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-/.f6465.4
Applied rewrites65.4%
Final simplification65.4%
herbie shell --seed 2024304
(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)))