
(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 (/ -1.0 (/ (* 3.0 a) (/ 1.0 (/ (+ (sqrt (fma (* c -3.0) a (* b b))) b) (* (* 3.0 a) c))))))
double code(double a, double b, double c) {
return -1.0 / ((3.0 * a) / (1.0 / ((sqrt(fma((c * -3.0), a, (b * b))) + b) / ((3.0 * a) * c))));
}
function code(a, b, c) return Float64(-1.0 / Float64(Float64(3.0 * a) / Float64(1.0 / Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) + b) / Float64(Float64(3.0 * a) * c))))) end
code[a_, b_, c_] := N[(-1.0 / N[(N[(3.0 * a), $MachinePrecision] / N[(1.0 / N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision] / N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{\frac{3 \cdot a}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} + b}{\left(3 \cdot a\right) \cdot c}}}}
\end{array}
Initial program 56.7%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6456.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6456.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6456.7
Applied rewrites56.7%
Applied rewrites58.0%
Taylor expanded in c around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (a b c)
:precision binary64
(if (<= b 90.0)
(/
(* (/ 0.3333333333333333 a) (fma (* c 3.0) a (fma (- b) b (* b b))))
(- (- b) (sqrt (fma (* c -3.0) a (* b b)))))
(/ 1.0 (/ (fma -2.0 b (* (/ (* c a) b) 1.5)) c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 90.0) {
tmp = ((0.3333333333333333 / a) * fma((c * 3.0), a, fma(-b, b, (b * b)))) / (-b - sqrt(fma((c * -3.0), a, (b * b))));
} else {
tmp = 1.0 / (fma(-2.0, b, (((c * a) / b) * 1.5)) / c);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 90.0) tmp = Float64(Float64(Float64(0.3333333333333333 / a) * fma(Float64(c * 3.0), a, fma(Float64(-b), b, Float64(b * b)))) / Float64(Float64(-b) - sqrt(fma(Float64(c * -3.0), a, Float64(b * b))))); else tmp = Float64(1.0 / Float64(fma(-2.0, b, Float64(Float64(Float64(c * a) / b) * 1.5)) / c)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 90.0], N[(N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[(c * 3.0), $MachinePrecision] * a + N[((-b) * b + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(-2.0 * b + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 90:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{a} \cdot \mathsf{fma}\left(c \cdot 3, a, \mathsf{fma}\left(-b, b, b \cdot b\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(-2, b, \frac{c \cdot a}{b} \cdot 1.5\right)}{c}}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
div-subN/A
lower--.f64N/A
Applied rewrites79.5%
Applied rewrites81.8%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6490.6
Applied rewrites90.6%
Final simplification87.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 90.0)
(/ (* (- t_0 (* b b)) (/ 0.3333333333333333 a)) (+ (sqrt t_0) b))
(/ 1.0 (/ (fma -2.0 b (* (/ (* c a) b) 1.5)) c)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 90.0) {
tmp = ((t_0 - (b * b)) * (0.3333333333333333 / a)) / (sqrt(t_0) + b);
} else {
tmp = 1.0 / (fma(-2.0, b, (((c * a) / b) * 1.5)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 90.0) tmp = Float64(Float64(Float64(t_0 - Float64(b * b)) * Float64(0.3333333333333333 / a)) / Float64(sqrt(t_0) + b)); else tmp = Float64(1.0 / Float64(fma(-2.0, b, Float64(Float64(Float64(c * a) / b) * 1.5)) / 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, 90.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[(1.0 / N[(N[(-2.0 * b + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 1.5), $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 90:\\
\;\;\;\;\frac{\left(t\_0 - b \cdot b\right) \cdot \frac{0.3333333333333333}{a}}{\sqrt{t\_0} + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(-2, b, \frac{c \cdot a}{b} \cdot 1.5\right)}{c}}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
div-subN/A
lower--.f64N/A
Applied rewrites79.5%
lift--.f64N/A
lift-/.f64N/A
div-invN/A
cancel-sign-sub-invN/A
lift-/.f64N/A
div-invN/A
lift-neg.f64N/A
distribute-rgt-inN/A
flip-+N/A
associate-*r/N/A
Applied rewrites81.7%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6490.6
Applied rewrites90.6%
Final simplification87.8%
(FPCore (a b c)
:precision binary64
(if (<= b 90.0)
(/
(fma b b (fma (* -3.0 a) c (* (- b) b)))
(* (* 3.0 a) (+ (sqrt (fma (* c -3.0) a (* b b))) b)))
(/ 1.0 (/ (fma -2.0 b (* (/ (* c a) b) 1.5)) c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 90.0) {
tmp = fma(b, b, fma((-3.0 * a), c, (-b * b))) / ((3.0 * a) * (sqrt(fma((c * -3.0), a, (b * b))) + b));
} else {
tmp = 1.0 / (fma(-2.0, b, (((c * a) / b) * 1.5)) / c);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 90.0) tmp = Float64(fma(b, b, fma(Float64(-3.0 * a), c, Float64(Float64(-b) * b))) / Float64(Float64(3.0 * a) * Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) + b))); else tmp = Float64(1.0 / Float64(fma(-2.0, b, Float64(Float64(Float64(c * a) / b) * 1.5)) / c)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 90.0], N[(N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c + N[((-b) * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(3.0 * a), $MachinePrecision] * N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(-2.0 * b + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 90:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, b, \mathsf{fma}\left(-3 \cdot a, c, \left(-b\right) \cdot b\right)\right)}{\left(3 \cdot a\right) \cdot \left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(-2, b, \frac{c \cdot a}{b} \cdot 1.5\right)}{c}}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6480.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6480.4
Applied rewrites80.5%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
clear-numN/A
lift--.f64N/A
flip--N/A
lift-+.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites81.7%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6490.6
Applied rewrites90.6%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 90.0)
(* (/ (- t_0 (* b b)) (* (+ (sqrt t_0) b) a)) 0.3333333333333333)
(/ 1.0 (/ (fma -2.0 b (* (/ (* c a) b) 1.5)) c)))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 90.0) {
tmp = ((t_0 - (b * b)) / ((sqrt(t_0) + b) * a)) * 0.3333333333333333;
} else {
tmp = 1.0 / (fma(-2.0, b, (((c * a) / b) * 1.5)) / c);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 90.0) 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(-2.0, b, Float64(Float64(Float64(c * a) / b) * 1.5)) / 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, 90.0], 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[(-2.0 * b + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 1.5), $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 90:\\
\;\;\;\;\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(-2, b, \frac{c \cdot a}{b} \cdot 1.5\right)}{c}}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
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 rewrites80.5%
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 rewrites81.6%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6490.6
Applied rewrites90.6%
Final simplification87.7%
(FPCore (a b c) :precision binary64 (if (<= b 90.0) (/ 0.3333333333333333 (/ a (- (sqrt (fma (* c -3.0) a (* b b))) b))) (/ 1.0 (/ (fma -2.0 b (* (/ (* c a) b) 1.5)) c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 90.0) {
tmp = 0.3333333333333333 / (a / (sqrt(fma((c * -3.0), a, (b * b))) - b));
} else {
tmp = 1.0 / (fma(-2.0, b, (((c * a) / b) * 1.5)) / c);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 90.0) tmp = Float64(0.3333333333333333 / Float64(a / Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b))); else tmp = Float64(1.0 / Float64(fma(-2.0, b, Float64(Float64(Float64(c * a) / b) * 1.5)) / c)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 90.0], N[(0.3333333333333333 / N[(a / N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(-2.0 * b + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 90:\\
\;\;\;\;\frac{0.3333333333333333}{\frac{a}{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(-2, b, \frac{c \cdot a}{b} \cdot 1.5\right)}{c}}\\
\end{array}
\end{array}
if b < 90Initial program 80.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-/.f6480.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6480.5
Applied rewrites80.5%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6490.6
Applied rewrites90.6%
Final simplification87.4%
(FPCore (a b c) :precision binary64 (if (<= b 90.0) (/ (* (- (sqrt (fma (* c -3.0) a (* b b))) b) 0.3333333333333333) a) (/ 1.0 (/ (fma -2.0 b (* (/ (* c a) b) 1.5)) c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 90.0) {
tmp = ((sqrt(fma((c * -3.0), a, (b * b))) - b) * 0.3333333333333333) / a;
} else {
tmp = 1.0 / (fma(-2.0, b, (((c * a) / b) * 1.5)) / c);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 90.0) tmp = Float64(Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) * 0.3333333333333333) / a); else tmp = Float64(1.0 / Float64(fma(-2.0, b, Float64(Float64(Float64(c * a) / b) * 1.5)) / c)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 90.0], N[(N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(1.0 / N[(N[(-2.0 * b + N[(N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 90:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b\right) \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(-2, b, \frac{c \cdot a}{b} \cdot 1.5\right)}{c}}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.5%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6490.6
Applied rewrites90.6%
Final simplification87.4%
(FPCore (a b c) :precision binary64 (if (<= b 90.0) (/ (* (- (sqrt (fma (* c -3.0) a (* b b))) b) 0.3333333333333333) a) (/ 1.0 (fma -2.0 (/ b c) (* (/ a b) 1.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 90.0) {
tmp = ((sqrt(fma((c * -3.0), a, (b * b))) - b) * 0.3333333333333333) / a;
} else {
tmp = 1.0 / fma(-2.0, (b / c), ((a / b) * 1.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 90.0) tmp = Float64(Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) * 0.3333333333333333) / a); else tmp = Float64(1.0 / fma(-2.0, Float64(b / c), Float64(Float64(a / b) * 1.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 90.0], N[(N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(1.0 / N[(-2.0 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 90:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b\right) \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \frac{a}{b} \cdot 1.5\right)}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.5%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
Final simplification87.3%
(FPCore (a b c) :precision binary64 (if (<= b 90.0) (* (/ (- (sqrt (fma (* c -3.0) a (* b b))) b) a) 0.3333333333333333) (/ 1.0 (fma -2.0 (/ b c) (* (/ a b) 1.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 90.0) {
tmp = ((sqrt(fma((c * -3.0), a, (b * b))) - b) / a) * 0.3333333333333333;
} else {
tmp = 1.0 / fma(-2.0, (b / c), ((a / b) * 1.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 90.0) tmp = Float64(Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) / a) * 0.3333333333333333); else tmp = Float64(1.0 / fma(-2.0, Float64(b / c), Float64(Float64(a / b) * 1.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 90.0], N[(N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(1.0 / N[(-2.0 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 90:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \frac{a}{b} \cdot 1.5\right)}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
lower-*.f64N/A
Applied rewrites80.5%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
Final simplification87.3%
(FPCore (a b c) :precision binary64 (if (<= b 90.0) (* (- (sqrt (fma (* c -3.0) a (* b b))) b) (/ 0.3333333333333333 a)) (/ 1.0 (fma -2.0 (/ b c) (* (/ a b) 1.5)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 90.0) {
tmp = (sqrt(fma((c * -3.0), a, (b * b))) - b) * (0.3333333333333333 / a);
} else {
tmp = 1.0 / fma(-2.0, (b / c), ((a / b) * 1.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 90.0) tmp = Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(1.0 / fma(-2.0, Float64(b / c), Float64(Float64(a / b) * 1.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 90.0], 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[(-2.0 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 90:\\
\;\;\;\;\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(-2, \frac{b}{c}, \frac{a}{b} \cdot 1.5\right)}\\
\end{array}
\end{array}
if b < 90Initial program 80.5%
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.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6480.5
Applied rewrites80.5%
if 90 < b Initial program 45.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6445.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.3
Applied rewrites45.3%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
Final simplification87.3%
(FPCore (a b c) :precision binary64 (/ 1.0 (fma -2.0 (/ b c) (* (/ a b) 1.5))))
double code(double a, double b, double c) {
return 1.0 / fma(-2.0, (b / c), ((a / b) * 1.5));
}
function code(a, b, c) return Float64(1.0 / fma(-2.0, Float64(b / c), Float64(Float64(a / b) * 1.5))) end
code[a_, b_, c_] := N[(1.0 / N[(-2.0 * N[(b / c), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \frac{a}{b} \cdot 1.5\right)}
\end{array}
Initial program 56.7%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6456.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6456.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6456.7
Applied rewrites56.7%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6481.4
Applied rewrites81.4%
Final simplification81.4%
(FPCore (a b c) :precision binary64 (* (/ (fma -0.375 (/ (* c a) (* b b)) -0.5) b) c))
double code(double a, double b, double c) {
return (fma(-0.375, ((c * a) / (b * b)), -0.5) / b) * c;
}
function code(a, b, c) return Float64(Float64(fma(-0.375, Float64(Float64(c * a) / Float64(b * b)), -0.5) / b) * c) end
code[a_, b_, c_] := N[(N[(N[(-0.375 * N[(N[(c * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(-0.375, \frac{c \cdot a}{b \cdot b}, -0.5\right)}{b} \cdot c
\end{array}
Initial program 56.7%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.6%
Taylor expanded in c around 0
Applied rewrites63.4%
Taylor expanded in b around inf
Applied rewrites80.7%
Final simplification80.7%
(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 56.7%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6463.5
Applied rewrites63.5%
(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 56.7%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.6%
Taylor expanded in c around 0
Applied rewrites63.4%
herbie shell --seed 2024276
(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)))