
(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 9 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) (pow (fma b b (* -3.0 (* c a))) 0.5))))
double code(double a, double b, double c) {
return c / (-b - pow(fma(b, b, (-3.0 * (c * a))), 0.5));
}
function code(a, b, c) return Float64(c / Float64(Float64(-b) - (fma(b, b, Float64(-3.0 * Float64(c * a))) ^ 0.5))) end
code[a_, b_, c_] := N[(c / N[((-b) - N[Power[N[(b * b + N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{\left(-b\right) - {\left(\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right)}^{0.5}}
\end{array}
Initial program 57.5%
sqr-neg57.5%
sqr-neg57.5%
associate-*l*57.5%
Simplified57.5%
add-cbrt-cube57.5%
pow1/357.3%
pow357.3%
Applied egg-rr57.3%
flip-+57.3%
Applied egg-rr58.7%
associate--r-99.1%
associate-*l*99.1%
associate-*l*99.1%
Simplified99.1%
div-inv99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
times-frac99.1%
*-lft-identity99.1%
associate-/r*99.1%
fma-undefine99.1%
+-inverses99.1%
+-rgt-identity99.1%
Simplified99.2%
Taylor expanded in a around 0 99.6%
pow1/299.6%
Applied egg-rr99.6%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0)) -0.011) (/ (- (sqrt (- (* b b) (* a (* c 3.0)))) b) (* a 3.0)) (/ c (* b (- (* 1.5 (/ (* c a) (pow b 2.0))) 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -0.011) {
tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0);
} else {
tmp = c / (b * ((1.5 * ((c * a) / pow(b, 2.0))) - 2.0));
}
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 (((sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)) <= (-0.011d0)) then
tmp = (sqrt(((b * b) - (a * (c * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = c / (b * ((1.5d0 * ((c * a) / (b ** 2.0d0))) - 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (((Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -0.011) {
tmp = (Math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0);
} else {
tmp = c / (b * ((1.5 * ((c * a) / Math.pow(b, 2.0))) - 2.0));
}
return tmp;
}
def code(a, b, c): tmp = 0 if ((math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -0.011: tmp = (math.sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0) else: tmp = c / (b * ((1.5 * ((c * a) / math.pow(b, 2.0))) - 2.0)) return tmp
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) <= -0.011) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(c / Float64(b * Float64(Float64(1.5 * Float64(Float64(c * a) / (b ^ 2.0))) - 2.0))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (((sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)) <= -0.011) tmp = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0); else tmp = c / (b * ((1.5 * ((c * a) / (b ^ 2.0))) - 2.0)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -0.011], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(c / N[(b * N[(N[(1.5 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.011:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b \cdot \left(1.5 \cdot \frac{c \cdot a}{{b}^{2}} - 2\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.010999999999999999Initial program 78.9%
sqr-neg78.9%
sqr-neg78.9%
associate-*l*78.9%
Simplified78.9%
add-cbrt-cube78.9%
pow1/378.5%
pow378.5%
Applied egg-rr78.5%
Taylor expanded in a around 0 78.9%
*-commutative78.9%
associate-*l*78.9%
Simplified78.9%
if -0.010999999999999999 < (/.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 47.4%
sqr-neg47.4%
sqr-neg47.4%
associate-*l*47.4%
Simplified47.4%
add-cbrt-cube47.4%
pow1/347.3%
pow347.3%
Applied egg-rr47.3%
flip-+47.2%
Applied egg-rr48.4%
associate--r-99.1%
associate-*l*99.2%
associate-*l*99.2%
Simplified99.2%
div-inv99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
times-frac99.1%
*-lft-identity99.1%
associate-/r*99.2%
fma-undefine99.2%
+-inverses99.2%
+-rgt-identity99.2%
Simplified99.2%
Taylor expanded in a around 0 99.7%
Taylor expanded in b around inf 90.0%
Final simplification86.4%
(FPCore (a b c) :precision binary64 (/ c (- (- b) (sqrt (fma b b (* -3.0 (* c a)))))))
double code(double a, double b, double c) {
return c / (-b - sqrt(fma(b, b, (-3.0 * (c * a)))));
}
function code(a, b, c) return Float64(c / Float64(Float64(-b) - sqrt(fma(b, b, Float64(-3.0 * Float64(c * a)))))) end
code[a_, b_, c_] := N[(c / N[((-b) - N[Sqrt[N[(b * b + N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}
\end{array}
Initial program 57.5%
sqr-neg57.5%
sqr-neg57.5%
associate-*l*57.5%
Simplified57.5%
add-cbrt-cube57.5%
pow1/357.3%
pow357.3%
Applied egg-rr57.3%
flip-+57.3%
Applied egg-rr58.7%
associate--r-99.1%
associate-*l*99.1%
associate-*l*99.1%
Simplified99.1%
div-inv99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
times-frac99.1%
*-lft-identity99.1%
associate-/r*99.1%
fma-undefine99.1%
+-inverses99.1%
+-rgt-identity99.1%
Simplified99.2%
Taylor expanded in a around 0 99.6%
(FPCore (a b c) :precision binary64 (if (<= b 5.2) (/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) (* a 3.0)) (/ c (* b (- (* 1.5 (/ (* c a) (pow b 2.0))) 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.2) {
tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = c / (b * ((1.5 * ((c * a) / pow(b, 2.0))) - 2.0));
}
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 <= 5.2d0) then
tmp = (sqrt(((b * b) - (3.0d0 * (c * a)))) - b) / (a * 3.0d0)
else
tmp = c / (b * ((1.5d0 * ((c * a) / (b ** 2.0d0))) - 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5.2) {
tmp = (Math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = c / (b * ((1.5 * ((c * a) / Math.pow(b, 2.0))) - 2.0));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.2: tmp = (math.sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0) else: tmp = c / (b * ((1.5 * ((c * a) / math.pow(b, 2.0))) - 2.0)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.2) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(c * a)))) - b) / Float64(a * 3.0)); else tmp = Float64(c / Float64(b * Float64(Float64(1.5 * Float64(Float64(c * a) / (b ^ 2.0))) - 2.0))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5.2) tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0); else tmp = c / (b * ((1.5 * ((c * a) / (b ^ 2.0))) - 2.0)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.2], 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[(c / N[(b * N[(N[(1.5 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.2:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b \cdot \left(1.5 \cdot \frac{c \cdot a}{{b}^{2}} - 2\right)}\\
\end{array}
\end{array}
if b < 5.20000000000000018Initial program 80.6%
sqr-neg80.6%
sqr-neg80.6%
associate-*l*80.6%
Simplified80.6%
if 5.20000000000000018 < b Initial program 51.9%
sqr-neg51.9%
sqr-neg51.9%
associate-*l*51.9%
Simplified51.9%
add-cbrt-cube51.8%
pow1/351.8%
pow351.8%
Applied egg-rr51.8%
flip-+51.7%
Applied egg-rr53.0%
associate--r-99.1%
associate-*l*99.2%
associate-*l*99.2%
Simplified99.2%
div-inv99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
times-frac99.1%
*-lft-identity99.1%
associate-/r*99.2%
fma-undefine99.2%
+-inverses99.2%
+-rgt-identity99.2%
Simplified99.2%
Taylor expanded in a around 0 99.6%
Taylor expanded in b around inf 86.1%
Final simplification85.0%
(FPCore (a b c) :precision binary64 (/ c (* b (- (* 1.5 (/ (* c a) (pow b 2.0))) 2.0))))
double code(double a, double b, double c) {
return c / (b * ((1.5 * ((c * a) / pow(b, 2.0))) - 2.0));
}
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 * ((1.5d0 * ((c * a) / (b ** 2.0d0))) - 2.0d0))
end function
public static double code(double a, double b, double c) {
return c / (b * ((1.5 * ((c * a) / Math.pow(b, 2.0))) - 2.0));
}
def code(a, b, c): return c / (b * ((1.5 * ((c * a) / math.pow(b, 2.0))) - 2.0))
function code(a, b, c) return Float64(c / Float64(b * Float64(Float64(1.5 * Float64(Float64(c * a) / (b ^ 2.0))) - 2.0))) end
function tmp = code(a, b, c) tmp = c / (b * ((1.5 * ((c * a) / (b ^ 2.0))) - 2.0)); end
code[a_, b_, c_] := N[(c / N[(b * N[(N[(1.5 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b \cdot \left(1.5 \cdot \frac{c \cdot a}{{b}^{2}} - 2\right)}
\end{array}
Initial program 57.5%
sqr-neg57.5%
sqr-neg57.5%
associate-*l*57.5%
Simplified57.5%
add-cbrt-cube57.5%
pow1/357.3%
pow357.3%
Applied egg-rr57.3%
flip-+57.3%
Applied egg-rr58.7%
associate--r-99.1%
associate-*l*99.1%
associate-*l*99.1%
Simplified99.1%
div-inv99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
times-frac99.1%
*-lft-identity99.1%
associate-/r*99.1%
fma-undefine99.1%
+-inverses99.1%
+-rgt-identity99.1%
Simplified99.2%
Taylor expanded in a around 0 99.6%
Taylor expanded in b around inf 81.6%
Final simplification81.6%
(FPCore (a b c) :precision binary64 (/ c (- (* 1.5 (/ (* c a) b)) (* b 2.0))))
double code(double a, double b, double c) {
return c / ((1.5 * ((c * a) / b)) - (b * 2.0));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / ((1.5d0 * ((c * a) / b)) - (b * 2.0d0))
end function
public static double code(double a, double b, double c) {
return c / ((1.5 * ((c * a) / b)) - (b * 2.0));
}
def code(a, b, c): return c / ((1.5 * ((c * a) / b)) - (b * 2.0))
function code(a, b, c) return Float64(c / Float64(Float64(1.5 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))) end
function tmp = code(a, b, c) tmp = c / ((1.5 * ((c * a) / b)) - (b * 2.0)); end
code[a_, b_, c_] := N[(c / N[(N[(1.5 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{1.5 \cdot \frac{c \cdot a}{b} - b \cdot 2}
\end{array}
Initial program 57.5%
sqr-neg57.5%
sqr-neg57.5%
associate-*l*57.5%
Simplified57.5%
add-cbrt-cube57.5%
pow1/357.3%
pow357.3%
Applied egg-rr57.3%
flip-+57.3%
Applied egg-rr58.7%
associate--r-99.1%
associate-*l*99.1%
associate-*l*99.1%
Simplified99.1%
div-inv99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
times-frac99.1%
*-lft-identity99.1%
associate-/r*99.1%
fma-undefine99.1%
+-inverses99.1%
+-rgt-identity99.1%
Simplified99.2%
Taylor expanded in a around 0 99.6%
Taylor expanded in c around 0 81.6%
Final simplification81.6%
(FPCore (a b c) :precision binary64 (/ (* c -0.5) b))
double code(double a, double b, double c) {
return (c * -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.5d0)) / b
end function
public static double code(double a, double b, double c) {
return (c * -0.5) / b;
}
def code(a, b, c): return (c * -0.5) / b
function code(a, b, c) return Float64(Float64(c * -0.5) / b) end
function tmp = code(a, b, c) tmp = (c * -0.5) / b; end
code[a_, b_, c_] := N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot -0.5}{b}
\end{array}
Initial program 57.5%
sqr-neg57.5%
sqr-neg57.5%
associate-*l*57.5%
Simplified57.5%
Taylor expanded in b around inf 62.9%
associate-*r/62.9%
*-commutative62.9%
Simplified62.9%
(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(-0.5 / Float64(b / c)) end
function tmp = code(a, b, c) tmp = -0.5 / (b / c); end
code[a_, b_, c_] := N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{\frac{b}{c}}
\end{array}
Initial program 57.5%
sqr-neg57.5%
sqr-neg57.5%
associate-*l*57.5%
Simplified57.5%
Taylor expanded in b around inf 62.7%
associate-/l*62.7%
associate-/l*62.8%
*-commutative62.8%
Applied egg-rr62.8%
times-frac62.8%
*-inverses62.8%
associate-*r*62.8%
metadata-eval62.8%
Simplified62.8%
associate-*r/62.8%
Applied egg-rr62.8%
associate-/l*62.8%
Applied egg-rr62.8%
associate-/l/62.8%
Simplified62.8%
clear-num62.8%
un-div-inv62.8%
*-un-lft-identity62.8%
times-frac62.8%
metadata-eval62.8%
Applied egg-rr62.8%
associate-/r*62.8%
metadata-eval62.8%
Simplified62.8%
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
return c * (-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.5d0) / b)
end function
public static double code(double a, double b, double c) {
return c * (-0.5 / b);
}
def code(a, b, c): return c * (-0.5 / b)
function code(a, b, c) return Float64(c * Float64(-0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (-0.5 / b); end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-0.5}{b}
\end{array}
Initial program 57.5%
sqr-neg57.5%
sqr-neg57.5%
associate-*l*57.5%
Simplified57.5%
Taylor expanded in b around inf 62.7%
associate-/l*62.7%
associate-/l*62.8%
*-commutative62.8%
Applied egg-rr62.8%
times-frac62.8%
*-inverses62.8%
associate-*r*62.8%
metadata-eval62.8%
Simplified62.8%
associate-*r/62.8%
Applied egg-rr62.8%
associate-/l*62.8%
Applied egg-rr62.8%
associate-/l/62.8%
Simplified62.8%
clear-num62.8%
un-div-inv62.8%
*-un-lft-identity62.8%
times-frac62.8%
metadata-eval62.8%
Applied egg-rr62.8%
associate-/r*62.8%
metadata-eval62.8%
Simplified62.8%
associate-/r/62.8%
Applied egg-rr62.8%
Final simplification62.8%
herbie shell --seed 2024105
(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)))