
(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 7 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 (/ (* (/ c (- (- b) (sqrt (fma c (* a -3.0) (* b b))))) (* a 3.0)) (* a 3.0)))
double code(double a, double b, double c) {
return ((c / (-b - sqrt(fma(c, (a * -3.0), (b * b))))) * (a * 3.0)) / (a * 3.0);
}
function code(a, b, c) return Float64(Float64(Float64(c / Float64(Float64(-b) - sqrt(fma(c, Float64(a * -3.0), Float64(b * b))))) * Float64(a * 3.0)) / Float64(a * 3.0)) end
code[a_, b_, c_] := N[(N[(N[(c / N[((-b) - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * 3.0), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}} \cdot \left(a \cdot 3\right)}{a \cdot 3}
\end{array}
Initial program 18.4%
add-cbrt-cube18.4%
pow318.4%
*-commutative18.4%
*-commutative18.4%
Applied egg-rr18.4%
flip-+18.3%
add-sqr-sqrt18.7%
rem-cbrt-cube18.9%
rem-cbrt-cube18.9%
Applied egg-rr18.9%
sqr-neg18.9%
unpow218.9%
unpow218.9%
associate-+l-99.5%
+-inverses99.5%
+-commutative99.5%
unpow299.5%
sub-neg99.5%
+-commutative99.5%
distribute-rgt-neg-in99.5%
fma-def99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
div-inv99.3%
+-rgt-identity99.3%
Applied egg-rr99.3%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l*99.5%
associate-/r/99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (* a 3.0))) (t_1 (sqrt (- (* b b) t_0))))
(if (<= (/ (- t_1 b) (* a 3.0)) -1000000000.0)
(/ (/ (+ (* b b) (- t_0 (* b b))) (- (- b) t_1)) (* a 3.0))
(+ (* -0.375 (* a (/ (* c c) (pow b 3.0)))) (* -0.5 (/ c b))))))
double code(double a, double b, double c) {
double t_0 = c * (a * 3.0);
double t_1 = sqrt(((b * b) - t_0));
double tmp;
if (((t_1 - b) / (a * 3.0)) <= -1000000000.0) {
tmp = (((b * b) + (t_0 - (b * b))) / (-b - t_1)) / (a * 3.0);
} else {
tmp = (-0.375 * (a * ((c * c) / pow(b, 3.0)))) + (-0.5 * (c / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c * (a * 3.0d0)
t_1 = sqrt(((b * b) - t_0))
if (((t_1 - b) / (a * 3.0d0)) <= (-1000000000.0d0)) then
tmp = (((b * b) + (t_0 - (b * b))) / (-b - t_1)) / (a * 3.0d0)
else
tmp = ((-0.375d0) * (a * ((c * c) / (b ** 3.0d0)))) + ((-0.5d0) * (c / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = c * (a * 3.0);
double t_1 = Math.sqrt(((b * b) - t_0));
double tmp;
if (((t_1 - b) / (a * 3.0)) <= -1000000000.0) {
tmp = (((b * b) + (t_0 - (b * b))) / (-b - t_1)) / (a * 3.0);
} else {
tmp = (-0.375 * (a * ((c * c) / Math.pow(b, 3.0)))) + (-0.5 * (c / b));
}
return tmp;
}
def code(a, b, c): t_0 = c * (a * 3.0) t_1 = math.sqrt(((b * b) - t_0)) tmp = 0 if ((t_1 - b) / (a * 3.0)) <= -1000000000.0: tmp = (((b * b) + (t_0 - (b * b))) / (-b - t_1)) / (a * 3.0) else: tmp = (-0.375 * (a * ((c * c) / math.pow(b, 3.0)))) + (-0.5 * (c / b)) return tmp
function code(a, b, c) t_0 = Float64(c * Float64(a * 3.0)) t_1 = sqrt(Float64(Float64(b * b) - t_0)) tmp = 0.0 if (Float64(Float64(t_1 - b) / Float64(a * 3.0)) <= -1000000000.0) tmp = Float64(Float64(Float64(Float64(b * b) + Float64(t_0 - Float64(b * b))) / Float64(Float64(-b) - t_1)) / Float64(a * 3.0)); else tmp = Float64(Float64(-0.375 * Float64(a * Float64(Float64(c * c) / (b ^ 3.0)))) + Float64(-0.5 * Float64(c / b))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = c * (a * 3.0); t_1 = sqrt(((b * b) - t_0)); tmp = 0.0; if (((t_1 - b) / (a * 3.0)) <= -1000000000.0) tmp = (((b * b) + (t_0 - (b * b))) / (-b - t_1)) / (a * 3.0); else tmp = (-0.375 * (a * ((c * c) / (b ^ 3.0)))) + (-0.5 * (c / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -1000000000.0], N[(N[(N[(N[(b * b), $MachinePrecision] + N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * N[(a * N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot 3\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;\frac{t_1 - b}{a \cdot 3} \leq -1000000000:\\
\;\;\;\;\frac{\frac{b \cdot b + \left(t_0 - b \cdot b\right)}{\left(-b\right) - t_1}}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.375 \cdot \left(a \cdot \frac{c \cdot c}{{b}^{3}}\right) + -0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -1e9Initial program 87.5%
add-cbrt-cube87.3%
pow387.4%
*-commutative87.4%
*-commutative87.4%
Applied egg-rr87.4%
flip-+87.0%
add-sqr-sqrt87.8%
rem-cbrt-cube89.2%
rem-cbrt-cube89.2%
Applied egg-rr89.2%
if -1e9 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 14.7%
/-rgt-identity14.7%
metadata-eval14.7%
associate-/l*14.7%
associate-*r/14.7%
*-commutative14.7%
associate-*l/14.7%
associate-*r/14.7%
metadata-eval14.7%
metadata-eval14.7%
times-frac14.7%
neg-mul-114.7%
distribute-rgt-neg-in14.7%
times-frac14.7%
metadata-eval14.7%
neg-mul-114.7%
Simplified14.8%
Taylor expanded in b around inf 96.9%
+-commutative96.9%
fma-def96.9%
associate-/l*96.9%
unpow296.9%
Simplified96.9%
fma-udef96.9%
associate-/r/96.9%
Applied egg-rr96.9%
Final simplification96.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))))
(if (<= t_0 -1000000000.0)
t_0
(+ (* -0.375 (* a (/ (* c c) (pow b 3.0)))) (* -0.5 (/ c b))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
double tmp;
if (t_0 <= -1000000000.0) {
tmp = t_0;
} else {
tmp = (-0.375 * (a * ((c * c) / pow(b, 3.0)))) + (-0.5 * (c / 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) :: t_0
real(8) :: tmp
t_0 = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
if (t_0 <= (-1000000000.0d0)) then
tmp = t_0
else
tmp = ((-0.375d0) * (a * ((c * c) / (b ** 3.0d0)))) + ((-0.5d0) * (c / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
double tmp;
if (t_0 <= -1000000000.0) {
tmp = t_0;
} else {
tmp = (-0.375 * (a * ((c * c) / Math.pow(b, 3.0)))) + (-0.5 * (c / b));
}
return tmp;
}
def code(a, b, c): t_0 = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) tmp = 0 if t_0 <= -1000000000.0: tmp = t_0 else: tmp = (-0.375 * (a * ((c * c) / math.pow(b, 3.0)))) + (-0.5 * (c / b)) return tmp
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) tmp = 0.0 if (t_0 <= -1000000000.0) tmp = t_0; else tmp = Float64(Float64(-0.375 * Float64(a * Float64(Float64(c * c) / (b ^ 3.0)))) + Float64(-0.5 * Float64(c / b))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); tmp = 0.0; if (t_0 <= -1000000000.0) tmp = t_0; else tmp = (-0.375 * (a * ((c * c) / (b ^ 3.0)))) + (-0.5 * (c / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, -1000000000.0], t$95$0, N[(N[(-0.375 * N[(a * N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{if}\;t_0 \leq -1000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-0.375 \cdot \left(a \cdot \frac{c \cdot c}{{b}^{3}}\right) + -0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -1e9Initial program 87.5%
if -1e9 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 14.7%
/-rgt-identity14.7%
metadata-eval14.7%
associate-/l*14.7%
associate-*r/14.7%
*-commutative14.7%
associate-*l/14.7%
associate-*r/14.7%
metadata-eval14.7%
metadata-eval14.7%
times-frac14.7%
neg-mul-114.7%
distribute-rgt-neg-in14.7%
times-frac14.7%
metadata-eval14.7%
neg-mul-114.7%
Simplified14.8%
Taylor expanded in b around inf 96.9%
+-commutative96.9%
fma-def96.9%
associate-/l*96.9%
unpow296.9%
Simplified96.9%
fma-udef96.9%
associate-/r/96.9%
Applied egg-rr96.9%
Final simplification96.4%
(FPCore (a b c) :precision binary64 (* (/ 1.0 a) (/ c (/ (- (- b) (sqrt (fma c (* a -3.0) (* b b)))) a))))
double code(double a, double b, double c) {
return (1.0 / a) * (c / ((-b - sqrt(fma(c, (a * -3.0), (b * b)))) / a));
}
function code(a, b, c) return Float64(Float64(1.0 / a) * Float64(c / Float64(Float64(Float64(-b) - sqrt(fma(c, Float64(a * -3.0), Float64(b * b)))) / a))) end
code[a_, b_, c_] := N[(N[(1.0 / a), $MachinePrecision] * N[(c / N[(N[((-b) - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{a} \cdot \frac{c}{\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{a}}
\end{array}
Initial program 18.4%
add-cbrt-cube18.4%
pow318.4%
*-commutative18.4%
*-commutative18.4%
Applied egg-rr18.4%
flip-+18.3%
add-sqr-sqrt18.7%
rem-cbrt-cube18.9%
rem-cbrt-cube18.9%
Applied egg-rr18.9%
sqr-neg18.9%
unpow218.9%
unpow218.9%
associate-+l-99.5%
+-inverses99.5%
+-commutative99.5%
unpow299.5%
sub-neg99.5%
+-commutative99.5%
distribute-rgt-neg-in99.5%
fma-def99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
div-inv99.3%
+-rgt-identity99.3%
Applied egg-rr99.3%
associate-*r/99.5%
*-rgt-identity99.5%
associate-/l*99.5%
associate-/r/99.8%
Simplified99.8%
expm1-log1p-u83.0%
expm1-udef20.8%
times-frac20.8%
Applied egg-rr20.8%
expm1-def82.7%
expm1-log1p99.4%
*-commutative99.4%
associate-/l/99.3%
times-frac99.1%
*-commutative99.1%
associate-*r*99.2%
*-commutative99.2%
associate-*l*99.1%
times-frac99.2%
*-commutative99.2%
associate-/r*99.3%
metadata-eval99.3%
associate-/l*99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (a b c) :precision binary64 (/ (/ (* c a) a) (- (- b) (sqrt (fma c (* a -3.0) (* b b))))))
double code(double a, double b, double c) {
return ((c * a) / a) / (-b - sqrt(fma(c, (a * -3.0), (b * b))));
}
function code(a, b, c) return Float64(Float64(Float64(c * a) / a) / Float64(Float64(-b) - sqrt(fma(c, Float64(a * -3.0), Float64(b * b))))) end
code[a_, b_, c_] := N[(N[(N[(c * a), $MachinePrecision] / a), $MachinePrecision] / N[((-b) - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{c \cdot a}{a}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}
\end{array}
Initial program 18.4%
add-cbrt-cube18.4%
pow318.4%
*-commutative18.4%
*-commutative18.4%
Applied egg-rr18.4%
flip-+18.3%
add-sqr-sqrt18.7%
rem-cbrt-cube18.9%
rem-cbrt-cube18.9%
Applied egg-rr18.9%
sqr-neg18.9%
unpow218.9%
unpow218.9%
associate-+l-99.5%
+-inverses99.5%
+-commutative99.5%
unpow299.5%
sub-neg99.5%
+-commutative99.5%
distribute-rgt-neg-in99.5%
fma-def99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
div-inv99.4%
+-rgt-identity99.4%
*-commutative99.4%
Applied egg-rr99.4%
associate-*l/99.5%
associate-*r/99.8%
*-rgt-identity99.8%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
times-frac99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (a b c) :precision binary64 (+ (* -0.375 (* a (/ (* c c) (pow b 3.0)))) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
return (-0.375 * (a * ((c * c) / pow(b, 3.0)))) + (-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.375d0) * (a * ((c * c) / (b ** 3.0d0)))) + ((-0.5d0) * (c / b))
end function
public static double code(double a, double b, double c) {
return (-0.375 * (a * ((c * c) / Math.pow(b, 3.0)))) + (-0.5 * (c / b));
}
def code(a, b, c): return (-0.375 * (a * ((c * c) / math.pow(b, 3.0)))) + (-0.5 * (c / b))
function code(a, b, c) return Float64(Float64(-0.375 * Float64(a * Float64(Float64(c * c) / (b ^ 3.0)))) + Float64(-0.5 * Float64(c / b))) end
function tmp = code(a, b, c) tmp = (-0.375 * (a * ((c * c) / (b ^ 3.0)))) + (-0.5 * (c / b)); end
code[a_, b_, c_] := N[(N[(-0.375 * N[(a * N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.375 \cdot \left(a \cdot \frac{c \cdot c}{{b}^{3}}\right) + -0.5 \cdot \frac{c}{b}
\end{array}
Initial program 18.4%
/-rgt-identity18.4%
metadata-eval18.4%
associate-/l*18.4%
associate-*r/18.4%
*-commutative18.4%
associate-*l/18.4%
associate-*r/18.4%
metadata-eval18.4%
metadata-eval18.4%
times-frac18.4%
neg-mul-118.4%
distribute-rgt-neg-in18.4%
times-frac18.4%
metadata-eval18.4%
neg-mul-118.4%
Simplified18.5%
Taylor expanded in b around inf 94.5%
+-commutative94.5%
fma-def94.5%
associate-/l*94.5%
unpow294.5%
Simplified94.5%
fma-udef94.5%
associate-/r/94.5%
Applied egg-rr94.5%
Final simplification94.5%
(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 18.4%
/-rgt-identity18.4%
metadata-eval18.4%
associate-/l*18.4%
associate-*r/18.4%
*-commutative18.4%
associate-*l/18.4%
associate-*r/18.4%
metadata-eval18.4%
metadata-eval18.4%
times-frac18.4%
neg-mul-118.4%
distribute-rgt-neg-in18.4%
times-frac18.4%
metadata-eval18.4%
neg-mul-118.4%
Simplified18.5%
Taylor expanded in b around inf 89.7%
Final simplification89.7%
herbie shell --seed 2023230
(FPCore (a b c)
:name "Cubic critical, wide range"
:precision binary64
:pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))