
(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 13 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
(/
(+
(* -0.5 c)
(*
a
(+
(* -0.375 (/ (* c c) (pow b 2.0)))
(*
a
(+
(* -1.0546875 (/ (* a (pow c 4.0)) (pow b 6.0)))
(* -0.5625 (/ (pow c 3.0) (pow b 4.0))))))))
b))
double code(double a, double b, double c) {
return ((-0.5 * c) + (a * ((-0.375 * ((c * c) / pow(b, 2.0))) + (a * ((-1.0546875 * ((a * pow(c, 4.0)) / pow(b, 6.0))) + (-0.5625 * (pow(c, 3.0) / pow(b, 4.0)))))))) / b;
}
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) * c) + (a * (((-0.375d0) * ((c * c) / (b ** 2.0d0))) + (a * (((-1.0546875d0) * ((a * (c ** 4.0d0)) / (b ** 6.0d0))) + ((-0.5625d0) * ((c ** 3.0d0) / (b ** 4.0d0)))))))) / b
end function
public static double code(double a, double b, double c) {
return ((-0.5 * c) + (a * ((-0.375 * ((c * c) / Math.pow(b, 2.0))) + (a * ((-1.0546875 * ((a * Math.pow(c, 4.0)) / Math.pow(b, 6.0))) + (-0.5625 * (Math.pow(c, 3.0) / Math.pow(b, 4.0)))))))) / b;
}
def code(a, b, c): return ((-0.5 * c) + (a * ((-0.375 * ((c * c) / math.pow(b, 2.0))) + (a * ((-1.0546875 * ((a * math.pow(c, 4.0)) / math.pow(b, 6.0))) + (-0.5625 * (math.pow(c, 3.0) / math.pow(b, 4.0)))))))) / b
function code(a, b, c) return Float64(Float64(Float64(-0.5 * c) + Float64(a * Float64(Float64(-0.375 * Float64(Float64(c * c) / (b ^ 2.0))) + Float64(a * Float64(Float64(-1.0546875 * Float64(Float64(a * (c ^ 4.0)) / (b ^ 6.0))) + Float64(-0.5625 * Float64((c ^ 3.0) / (b ^ 4.0)))))))) / b) end
function tmp = code(a, b, c) tmp = ((-0.5 * c) + (a * ((-0.375 * ((c * c) / (b ^ 2.0))) + (a * ((-1.0546875 * ((a * (c ^ 4.0)) / (b ^ 6.0))) + (-0.5625 * ((c ^ 3.0) / (b ^ 4.0)))))))) / b; end
code[a_, b_, c_] := N[(N[(N[(-0.5 * c), $MachinePrecision] + N[(a * N[(N[(-0.375 * N[(N[(c * c), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(-1.0546875 * N[(N[(a * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5625 * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5 \cdot c + a \cdot \left(-0.375 \cdot \frac{c \cdot c}{{b}^{2}} + a \cdot \left(-1.0546875 \cdot \frac{a \cdot {c}^{4}}{{b}^{6}} + -0.5625 \cdot \frac{{c}^{3}}{{b}^{4}}\right)\right)}{b}
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in b around inf 94.2%
+-commutative94.2%
*-un-lft-identity94.2%
fma-define94.2%
Applied egg-rr94.2%
fma-undefine94.2%
*-lft-identity94.2%
unpow294.2%
unpow294.2%
times-frac94.2%
unpow194.2%
pow-plus94.2%
metadata-eval94.2%
associate-*r/94.2%
*-commutative94.2%
times-frac94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in a around 0 94.2%
unpow294.2%
Applied egg-rr94.2%
(FPCore (a b c)
:precision binary64
(/
(*
c
(-
(*
c
(+
(* -0.375 (/ a (pow b 2.0)))
(*
c
(*
(pow a 3.0)
(- (/ (* c -1.0546875) (pow b 6.0)) (/ 0.5625 (* a (pow b 4.0))))))))
0.5))
b))
double code(double a, double b, double c) {
return (c * ((c * ((-0.375 * (a / pow(b, 2.0))) + (c * (pow(a, 3.0) * (((c * -1.0546875) / pow(b, 6.0)) - (0.5625 / (a * pow(b, 4.0)))))))) - 0.5)) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c * ((c * (((-0.375d0) * (a / (b ** 2.0d0))) + (c * ((a ** 3.0d0) * (((c * (-1.0546875d0)) / (b ** 6.0d0)) - (0.5625d0 / (a * (b ** 4.0d0)))))))) - 0.5d0)) / b
end function
public static double code(double a, double b, double c) {
return (c * ((c * ((-0.375 * (a / Math.pow(b, 2.0))) + (c * (Math.pow(a, 3.0) * (((c * -1.0546875) / Math.pow(b, 6.0)) - (0.5625 / (a * Math.pow(b, 4.0)))))))) - 0.5)) / b;
}
def code(a, b, c): return (c * ((c * ((-0.375 * (a / math.pow(b, 2.0))) + (c * (math.pow(a, 3.0) * (((c * -1.0546875) / math.pow(b, 6.0)) - (0.5625 / (a * math.pow(b, 4.0)))))))) - 0.5)) / b
function code(a, b, c) return Float64(Float64(c * Float64(Float64(c * Float64(Float64(-0.375 * Float64(a / (b ^ 2.0))) + Float64(c * Float64((a ^ 3.0) * Float64(Float64(Float64(c * -1.0546875) / (b ^ 6.0)) - Float64(0.5625 / Float64(a * (b ^ 4.0)))))))) - 0.5)) / b) end
function tmp = code(a, b, c) tmp = (c * ((c * ((-0.375 * (a / (b ^ 2.0))) + (c * ((a ^ 3.0) * (((c * -1.0546875) / (b ^ 6.0)) - (0.5625 / (a * (b ^ 4.0)))))))) - 0.5)) / b; end
code[a_, b_, c_] := N[(N[(c * N[(N[(c * N[(N[(-0.375 * N[(a / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * N[(N[Power[a, 3.0], $MachinePrecision] * N[(N[(N[(c * -1.0546875), $MachinePrecision] / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] - N[(0.5625 / N[(a * N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot \left(c \cdot \left(-0.375 \cdot \frac{a}{{b}^{2}} + c \cdot \left({a}^{3} \cdot \left(\frac{c \cdot -1.0546875}{{b}^{6}} - \frac{0.5625}{a \cdot {b}^{4}}\right)\right)\right) - 0.5\right)}{b}
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in b around inf 94.2%
+-commutative94.2%
*-un-lft-identity94.2%
fma-define94.2%
Applied egg-rr94.2%
fma-undefine94.2%
*-lft-identity94.2%
unpow294.2%
unpow294.2%
times-frac94.2%
unpow194.2%
pow-plus94.2%
metadata-eval94.2%
associate-*r/94.2%
*-commutative94.2%
times-frac94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in c around 0 94.1%
Taylor expanded in a around inf 94.1%
associate-*r/94.1%
associate-*r/94.1%
metadata-eval94.1%
Simplified94.1%
Final simplification94.1%
(FPCore (a b c) :precision binary64 (/ (+ (* -0.5625 (/ (* (pow c 3.0) (pow a 2.0)) (pow b 4.0))) (+ (* -0.5 c) (* -0.375 (* a (pow (/ c b) 2.0))))) b))
double code(double a, double b, double c) {
return ((-0.5625 * ((pow(c, 3.0) * pow(a, 2.0)) / pow(b, 4.0))) + ((-0.5 * c) + (-0.375 * (a * pow((c / b), 2.0))))) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (((-0.5625d0) * (((c ** 3.0d0) * (a ** 2.0d0)) / (b ** 4.0d0))) + (((-0.5d0) * c) + ((-0.375d0) * (a * ((c / b) ** 2.0d0))))) / b
end function
public static double code(double a, double b, double c) {
return ((-0.5625 * ((Math.pow(c, 3.0) * Math.pow(a, 2.0)) / Math.pow(b, 4.0))) + ((-0.5 * c) + (-0.375 * (a * Math.pow((c / b), 2.0))))) / b;
}
def code(a, b, c): return ((-0.5625 * ((math.pow(c, 3.0) * math.pow(a, 2.0)) / math.pow(b, 4.0))) + ((-0.5 * c) + (-0.375 * (a * math.pow((c / b), 2.0))))) / b
function code(a, b, c) return Float64(Float64(Float64(-0.5625 * Float64(Float64((c ^ 3.0) * (a ^ 2.0)) / (b ^ 4.0))) + Float64(Float64(-0.5 * c) + Float64(-0.375 * Float64(a * (Float64(c / b) ^ 2.0))))) / b) end
function tmp = code(a, b, c) tmp = ((-0.5625 * (((c ^ 3.0) * (a ^ 2.0)) / (b ^ 4.0))) + ((-0.5 * c) + (-0.375 * (a * ((c / b) ^ 2.0))))) / b; end
code[a_, b_, c_] := N[(N[(N[(-0.5625 * N[(N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * c), $MachinePrecision] + N[(-0.375 * N[(a * N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{4}} + \left(-0.5 \cdot c + -0.375 \cdot \left(a \cdot {\left(\frac{c}{b}\right)}^{2}\right)\right)}{b}
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in b around inf 94.2%
+-commutative94.2%
*-un-lft-identity94.2%
fma-define94.2%
Applied egg-rr94.2%
fma-undefine94.2%
*-lft-identity94.2%
unpow294.2%
unpow294.2%
times-frac94.2%
unpow194.2%
pow-plus94.2%
metadata-eval94.2%
associate-*r/94.2%
*-commutative94.2%
times-frac94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in a around 0 91.6%
associate-/l*91.6%
unpow291.6%
unpow291.6%
times-frac91.6%
unpow291.6%
Simplified91.6%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(+
(* -0.5 (/ c b))
(*
a
(*
(pow c 2.0)
(- (* -0.5625 (/ (* c a) (pow b 5.0))) (/ 0.375 (pow b 3.0)))))))
double code(double a, double b, double c) {
return (-0.5 * (c / b)) + (a * (pow(c, 2.0) * ((-0.5625 * ((c * a) / pow(b, 5.0))) - (0.375 / pow(b, 3.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.5d0) * (c / b)) + (a * ((c ** 2.0d0) * (((-0.5625d0) * ((c * a) / (b ** 5.0d0))) - (0.375d0 / (b ** 3.0d0)))))
end function
public static double code(double a, double b, double c) {
return (-0.5 * (c / b)) + (a * (Math.pow(c, 2.0) * ((-0.5625 * ((c * a) / Math.pow(b, 5.0))) - (0.375 / Math.pow(b, 3.0)))));
}
def code(a, b, c): return (-0.5 * (c / b)) + (a * (math.pow(c, 2.0) * ((-0.5625 * ((c * a) / math.pow(b, 5.0))) - (0.375 / math.pow(b, 3.0)))))
function code(a, b, c) return Float64(Float64(-0.5 * Float64(c / b)) + Float64(a * Float64((c ^ 2.0) * Float64(Float64(-0.5625 * Float64(Float64(c * a) / (b ^ 5.0))) - Float64(0.375 / (b ^ 3.0)))))) end
function tmp = code(a, b, c) tmp = (-0.5 * (c / b)) + (a * ((c ^ 2.0) * ((-0.5625 * ((c * a) / (b ^ 5.0))) - (0.375 / (b ^ 3.0))))); end
code[a_, b_, c_] := N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(-0.5625 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.375 / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b} + a \cdot \left({c}^{2} \cdot \left(-0.5625 \cdot \frac{c \cdot a}{{b}^{5}} - \frac{0.375}{{b}^{3}}\right)\right)
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in a around 0 91.6%
Taylor expanded in c around 0 91.6%
*-commutative91.6%
associate-*r/91.6%
metadata-eval91.6%
Simplified91.6%
(FPCore (a b c)
:precision binary64
(/
(*
c
(-
(*
c
(*
a
(+ (* -0.5625 (/ (* c a) (pow b 4.0))) (* 0.375 (/ -1.0 (pow b 2.0))))))
0.5))
b))
double code(double a, double b, double c) {
return (c * ((c * (a * ((-0.5625 * ((c * a) / pow(b, 4.0))) + (0.375 * (-1.0 / pow(b, 2.0)))))) - 0.5)) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c * ((c * (a * (((-0.5625d0) * ((c * a) / (b ** 4.0d0))) + (0.375d0 * ((-1.0d0) / (b ** 2.0d0)))))) - 0.5d0)) / b
end function
public static double code(double a, double b, double c) {
return (c * ((c * (a * ((-0.5625 * ((c * a) / Math.pow(b, 4.0))) + (0.375 * (-1.0 / Math.pow(b, 2.0)))))) - 0.5)) / b;
}
def code(a, b, c): return (c * ((c * (a * ((-0.5625 * ((c * a) / math.pow(b, 4.0))) + (0.375 * (-1.0 / math.pow(b, 2.0)))))) - 0.5)) / b
function code(a, b, c) return Float64(Float64(c * Float64(Float64(c * Float64(a * Float64(Float64(-0.5625 * Float64(Float64(c * a) / (b ^ 4.0))) + Float64(0.375 * Float64(-1.0 / (b ^ 2.0)))))) - 0.5)) / b) end
function tmp = code(a, b, c) tmp = (c * ((c * (a * ((-0.5625 * ((c * a) / (b ^ 4.0))) + (0.375 * (-1.0 / (b ^ 2.0)))))) - 0.5)) / b; end
code[a_, b_, c_] := N[(N[(c * N[(N[(c * N[(a * N[(N[(-0.5625 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.375 * N[(-1.0 / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot \left(c \cdot \left(a \cdot \left(-0.5625 \cdot \frac{c \cdot a}{{b}^{4}} + 0.375 \cdot \frac{-1}{{b}^{2}}\right)\right) - 0.5\right)}{b}
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in b around inf 94.2%
+-commutative94.2%
*-un-lft-identity94.2%
fma-define94.2%
Applied egg-rr94.2%
fma-undefine94.2%
*-lft-identity94.2%
unpow294.2%
unpow294.2%
times-frac94.2%
unpow194.2%
pow-plus94.2%
metadata-eval94.2%
associate-*r/94.2%
*-commutative94.2%
times-frac94.2%
*-commutative94.2%
Simplified94.2%
Taylor expanded in c around 0 94.1%
Taylor expanded in a around 0 91.5%
Final simplification91.5%
(FPCore (a b c) :precision binary64 (if (<= b 0.84) (* (fma -1.0 b (sqrt (- (* b b) (* c (* a 3.0))))) (/ 1.0 (* a 3.0))) (/ (fma -0.5 c (* -0.375 (* a (pow (/ c b) 2.0)))) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.84) {
tmp = fma(-1.0, b, sqrt(((b * b) - (c * (a * 3.0))))) * (1.0 / (a * 3.0));
} else {
tmp = fma(-0.5, c, (-0.375 * (a * pow((c / b), 2.0)))) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 0.84) tmp = Float64(fma(-1.0, b, sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0))))) * Float64(1.0 / Float64(a * 3.0))); else tmp = Float64(fma(-0.5, c, Float64(-0.375 * Float64(a * (Float64(c / b) ^ 2.0)))) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 0.84], N[(N[(-1.0 * b + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c + N[(-0.375 * N[(a * N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.84:\\
\;\;\;\;\mathsf{fma}\left(-1, b, \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right) \cdot \frac{1}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.5, c, -0.375 \cdot \left(a \cdot {\left(\frac{c}{b}\right)}^{2}\right)\right)}{b}\\
\end{array}
\end{array}
if b < 0.839999999999999969Initial program 82.7%
add-cube-cbrt82.4%
pow382.5%
Applied egg-rr82.5%
rem-cube-cbrt82.7%
div-inv82.7%
neg-mul-182.7%
fma-define82.7%
pow282.7%
*-commutative82.7%
*-commutative82.7%
*-commutative82.7%
Applied egg-rr82.7%
pow282.7%
Applied egg-rr82.7%
if 0.839999999999999969 < b Initial program 44.4%
Simplified44.6%
Taylor expanded in b around inf 96.3%
Taylor expanded in b around inf 89.5%
fma-define89.5%
associate-*r/89.5%
unpow289.5%
unpow289.5%
times-frac89.5%
unpow189.5%
pow-plus89.5%
metadata-eval89.5%
Simplified89.5%
(FPCore (a b c) :precision binary64 (if (<= b 0.8) (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) (/ (fma -0.5 c (* -0.375 (* a (pow (/ c b) 2.0)))) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.8) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = fma(-0.5, c, (-0.375 * (a * pow((c / b), 2.0)))) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 0.8) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(fma(-0.5, c, Float64(-0.375 * Float64(a * (Float64(c / b) ^ 2.0)))) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 0.8], 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], N[(N[(-0.5 * c + N[(-0.375 * N[(a * N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.8:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.5, c, -0.375 \cdot \left(a \cdot {\left(\frac{c}{b}\right)}^{2}\right)\right)}{b}\\
\end{array}
\end{array}
if b < 0.80000000000000004Initial program 82.7%
if 0.80000000000000004 < b Initial program 44.4%
Simplified44.6%
Taylor expanded in b around inf 96.3%
Taylor expanded in b around inf 89.5%
fma-define89.5%
associate-*r/89.5%
unpow289.5%
unpow289.5%
times-frac89.5%
unpow189.5%
pow-plus89.5%
metadata-eval89.5%
Simplified89.5%
Final simplification88.6%
(FPCore (a b c) :precision binary64 (if (<= b 0.78) (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) (/ (* c (- (* -0.375 (/ (* c a) (pow b 2.0))) 0.5)) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.78) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * ((-0.375 * ((c * a) / pow(b, 2.0))) - 0.5)) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 0.78d0) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (c * (((-0.375d0) * ((c * a) / (b ** 2.0d0))) - 0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 0.78) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * ((-0.375 * ((c * a) / Math.pow(b, 2.0))) - 0.5)) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 0.78: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (c * ((-0.375 * ((c * a) / math.pow(b, 2.0))) - 0.5)) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 0.78) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * Float64(Float64(-0.375 * Float64(Float64(c * a) / (b ^ 2.0))) - 0.5)) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 0.78) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c * ((-0.375 * ((c * a) / (b ^ 2.0))) - 0.5)) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 0.78], 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], N[(N[(c * N[(N[(-0.375 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.78:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \left(-0.375 \cdot \frac{c \cdot a}{{b}^{2}} - 0.5\right)}{b}\\
\end{array}
\end{array}
if b < 0.78000000000000003Initial program 82.7%
if 0.78000000000000003 < b Initial program 44.4%
Simplified44.6%
Taylor expanded in b around inf 96.3%
Taylor expanded in c around 0 89.4%
Final simplification88.6%
(FPCore (a b c) :precision binary64 (if (<= b 0.84) (/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) (* a 3.0)) (/ (* c (- (* -0.375 (/ (* c a) (pow b 2.0))) 0.5)) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.84) {
tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = (c * ((-0.375 * ((c * a) / pow(b, 2.0))) - 0.5)) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 0.84d0) then
tmp = (sqrt(((b * b) - (3.0d0 * (c * a)))) - b) / (a * 3.0d0)
else
tmp = (c * (((-0.375d0) * ((c * a) / (b ** 2.0d0))) - 0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 0.84) {
tmp = (Math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = (c * ((-0.375 * ((c * a) / Math.pow(b, 2.0))) - 0.5)) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 0.84: tmp = (math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0) else: tmp = (c * ((-0.375 * ((c * a) / math.pow(b, 2.0))) - 0.5)) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 0.84) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(c * a)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * Float64(Float64(-0.375 * Float64(Float64(c * a) / (b ^ 2.0))) - 0.5)) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 0.84) tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0); else tmp = (c * ((-0.375 * ((c * a) / (b ^ 2.0))) - 0.5)) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 0.84], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * N[(N[(-0.375 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.84:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \left(-0.375 \cdot \frac{c \cdot a}{{b}^{2}} - 0.5\right)}{b}\\
\end{array}
\end{array}
if b < 0.839999999999999969Initial program 82.7%
sqr-neg82.7%
sqr-neg82.7%
associate-*l*82.7%
Simplified82.7%
if 0.839999999999999969 < b Initial program 44.4%
Simplified44.6%
Taylor expanded in b around inf 96.3%
Taylor expanded in c around 0 89.4%
Final simplification88.6%
(FPCore (a b c) :precision binary64 (/ (* c (- (* -0.375 (/ (* c a) (pow b 2.0))) 0.5)) b))
double code(double a, double b, double c) {
return (c * ((-0.375 * ((c * a) / pow(b, 2.0))) - 0.5)) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c * (((-0.375d0) * ((c * a) / (b ** 2.0d0))) - 0.5d0)) / b
end function
public static double code(double a, double b, double c) {
return (c * ((-0.375 * ((c * a) / Math.pow(b, 2.0))) - 0.5)) / b;
}
def code(a, b, c): return (c * ((-0.375 * ((c * a) / math.pow(b, 2.0))) - 0.5)) / b
function code(a, b, c) return Float64(Float64(c * Float64(Float64(-0.375 * Float64(Float64(c * a) / (b ^ 2.0))) - 0.5)) / b) end
function tmp = code(a, b, c) tmp = (c * ((-0.375 * ((c * a) / (b ^ 2.0))) - 0.5)) / b; end
code[a_, b_, c_] := N[(N[(c * N[(N[(-0.375 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot \left(-0.375 \cdot \frac{c \cdot a}{{b}^{2}} - 0.5\right)}{b}
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in b around inf 94.2%
Taylor expanded in c around 0 85.7%
Final simplification85.7%
(FPCore (a b c) :precision binary64 (* c (- (* -0.375 (* a (/ c (pow b 3.0)))) (/ 0.5 b))))
double code(double a, double b, double c) {
return c * ((-0.375 * (a * (c / pow(b, 3.0)))) - (0.5 / b));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * (((-0.375d0) * (a * (c / (b ** 3.0d0)))) - (0.5d0 / b))
end function
public static double code(double a, double b, double c) {
return c * ((-0.375 * (a * (c / Math.pow(b, 3.0)))) - (0.5 / b));
}
def code(a, b, c): return c * ((-0.375 * (a * (c / math.pow(b, 3.0)))) - (0.5 / b))
function code(a, b, c) return Float64(c * Float64(Float64(-0.375 * Float64(a * Float64(c / (b ^ 3.0)))) - Float64(0.5 / b))) end
function tmp = code(a, b, c) tmp = c * ((-0.375 * (a * (c / (b ^ 3.0)))) - (0.5 / b)); end
code[a_, b_, c_] := N[(c * N[(N[(-0.375 * N[(a * N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \left(-0.375 \cdot \left(a \cdot \frac{c}{{b}^{3}}\right) - \frac{0.5}{b}\right)
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in c around 0 85.6%
associate-/l*85.6%
associate-*r/85.6%
metadata-eval85.6%
Simplified85.6%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
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) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 49.2%
Simplified49.4%
Taylor expanded in b around inf 69.4%
(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 49.2%
neg-sub049.2%
flip--49.2%
metadata-eval49.2%
pow249.2%
add-sqr-sqrt48.7%
sqrt-prod49.2%
sqr-neg49.2%
sqrt-unprod0.0%
add-sqr-sqrt1.6%
sub-neg1.6%
neg-sub01.6%
add-sqr-sqrt0.0%
sqrt-unprod49.2%
sqr-neg49.2%
sqrt-prod48.7%
add-sqr-sqrt49.2%
Applied egg-rr49.2%
neg-sub049.2%
Simplified49.2%
Taylor expanded in a around 0 3.2%
associate-*r/3.2%
distribute-rgt1-in3.2%
metadata-eval3.2%
mul0-lft3.2%
metadata-eval3.2%
Simplified3.2%
Taylor expanded in a around 0 3.2%
herbie shell --seed 2024130
(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)))