
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(-
(*
(pow c 4.0)
(-
(* -5.0 (/ (pow a 3.0) (pow b 7.0)))
(/ (+ (* 2.0 (/ (pow a 2.0) (pow b 5.0))) (/ a (* c (pow b 3.0)))) c)))
(/ c b)))
double code(double a, double b, double c) {
return (pow(c, 4.0) * ((-5.0 * (pow(a, 3.0) / pow(b, 7.0))) - (((2.0 * (pow(a, 2.0) / pow(b, 5.0))) + (a / (c * pow(b, 3.0)))) / c))) - (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 = ((c ** 4.0d0) * (((-5.0d0) * ((a ** 3.0d0) / (b ** 7.0d0))) - (((2.0d0 * ((a ** 2.0d0) / (b ** 5.0d0))) + (a / (c * (b ** 3.0d0)))) / c))) - (c / b)
end function
public static double code(double a, double b, double c) {
return (Math.pow(c, 4.0) * ((-5.0 * (Math.pow(a, 3.0) / Math.pow(b, 7.0))) - (((2.0 * (Math.pow(a, 2.0) / Math.pow(b, 5.0))) + (a / (c * Math.pow(b, 3.0)))) / c))) - (c / b);
}
def code(a, b, c): return (math.pow(c, 4.0) * ((-5.0 * (math.pow(a, 3.0) / math.pow(b, 7.0))) - (((2.0 * (math.pow(a, 2.0) / math.pow(b, 5.0))) + (a / (c * math.pow(b, 3.0)))) / c))) - (c / b)
function code(a, b, c) return Float64(Float64((c ^ 4.0) * Float64(Float64(-5.0 * Float64((a ^ 3.0) / (b ^ 7.0))) - Float64(Float64(Float64(2.0 * Float64((a ^ 2.0) / (b ^ 5.0))) + Float64(a / Float64(c * (b ^ 3.0)))) / c))) - Float64(c / b)) end
function tmp = code(a, b, c) tmp = ((c ^ 4.0) * ((-5.0 * ((a ^ 3.0) / (b ^ 7.0))) - (((2.0 * ((a ^ 2.0) / (b ^ 5.0))) + (a / (c * (b ^ 3.0)))) / c))) - (c / b); end
code[a_, b_, c_] := N[(N[(N[Power[c, 4.0], $MachinePrecision] * N[(N[(-5.0 * N[(N[Power[a, 3.0], $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(2.0 * N[(N[Power[a, 2.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a / N[(c * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{c}^{4} \cdot \left(-5 \cdot \frac{{a}^{3}}{{b}^{7}} - \frac{2 \cdot \frac{{a}^{2}}{{b}^{5}} + \frac{a}{c \cdot {b}^{3}}}{c}\right) - \frac{c}{b}
\end{array}
Initial program 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in a around 0 94.5%
Taylor expanded in c around -inf 94.5%
mul-1-neg94.5%
distribute-frac-neg94.5%
Applied egg-rr94.5%
Final simplification94.5%
(FPCore (a b c) :precision binary64 (- (* (pow c 2.0) (- (/ (* -2.0 (* c (pow a 2.0))) (pow b 5.0)) (/ a (pow b 3.0)))) (/ c b)))
double code(double a, double b, double c) {
return (pow(c, 2.0) * (((-2.0 * (c * pow(a, 2.0))) / pow(b, 5.0)) - (a / pow(b, 3.0)))) - (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 = ((c ** 2.0d0) * ((((-2.0d0) * (c * (a ** 2.0d0))) / (b ** 5.0d0)) - (a / (b ** 3.0d0)))) - (c / b)
end function
public static double code(double a, double b, double c) {
return (Math.pow(c, 2.0) * (((-2.0 * (c * Math.pow(a, 2.0))) / Math.pow(b, 5.0)) - (a / Math.pow(b, 3.0)))) - (c / b);
}
def code(a, b, c): return (math.pow(c, 2.0) * (((-2.0 * (c * math.pow(a, 2.0))) / math.pow(b, 5.0)) - (a / math.pow(b, 3.0)))) - (c / b)
function code(a, b, c) return Float64(Float64((c ^ 2.0) * Float64(Float64(Float64(-2.0 * Float64(c * (a ^ 2.0))) / (b ^ 5.0)) - Float64(a / (b ^ 3.0)))) - Float64(c / b)) end
function tmp = code(a, b, c) tmp = ((c ^ 2.0) * (((-2.0 * (c * (a ^ 2.0))) / (b ^ 5.0)) - (a / (b ^ 3.0)))) - (c / b); end
code[a_, b_, c_] := N[(N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(N[(-2.0 * N[(c * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] - N[(a / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{c}^{2} \cdot \left(\frac{-2 \cdot \left(c \cdot {a}^{2}\right)}{{b}^{5}} - \frac{a}{{b}^{3}}\right) - \frac{c}{b}
\end{array}
Initial program 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in a around 0 94.5%
Taylor expanded in c around -inf 94.5%
mul-1-neg94.5%
distribute-frac-neg94.5%
Applied egg-rr94.5%
Taylor expanded in c around 0 93.1%
mul-1-neg93.1%
unsub-neg93.1%
associate-*r/93.1%
*-commutative93.1%
Simplified93.1%
Final simplification93.1%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0)))) (if (<= t_0 -350.0) t_0 (- (/ c (- b)) (* a (/ (pow c 2.0) (pow b 3.0)))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
double tmp;
if (t_0 <= -350.0) {
tmp = t_0;
} else {
tmp = (c / -b) - (a * (pow(c, 2.0) / pow(b, 3.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) :: t_0
real(8) :: tmp
t_0 = (sqrt(((b * b) - (c * (4.0d0 * a)))) - b) / (a * 2.0d0)
if (t_0 <= (-350.0d0)) then
tmp = t_0
else
tmp = (c / -b) - (a * ((c ** 2.0d0) / (b ** 3.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (Math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
double tmp;
if (t_0 <= -350.0) {
tmp = t_0;
} else {
tmp = (c / -b) - (a * (Math.pow(c, 2.0) / Math.pow(b, 3.0)));
}
return tmp;
}
def code(a, b, c): t_0 = (math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0) tmp = 0 if t_0 <= -350.0: tmp = t_0 else: tmp = (c / -b) - (a * (math.pow(c, 2.0) / math.pow(b, 3.0))) return tmp
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(a * 2.0)) tmp = 0.0 if (t_0 <= -350.0) tmp = t_0; else tmp = Float64(Float64(c / Float64(-b)) - Float64(a * Float64((c ^ 2.0) / (b ^ 3.0)))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0); tmp = 0.0; if (t_0 <= -350.0) tmp = t_0; else tmp = (c / -b) - (a * ((c ^ 2.0) / (b ^ 3.0))); 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[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -350.0], t$95$0, N[(N[(c / (-b)), $MachinePrecision] - N[(a * N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{if}\;t\_0 \leq -350:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b} - a \cdot \frac{{c}^{2}}{{b}^{3}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -350Initial program 82.6%
if -350 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 25.8%
*-commutative25.8%
Simplified25.8%
Taylor expanded in a around 0 93.0%
mul-1-neg93.0%
unsub-neg93.0%
mul-1-neg93.0%
distribute-neg-frac293.0%
associate-/l*93.0%
Simplified93.0%
Final simplification92.0%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0)))) (if (<= t_0 -350.0) t_0 (/ (fma a (pow (/ c b) 2.0) c) (- b)))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
double tmp;
if (t_0 <= -350.0) {
tmp = t_0;
} else {
tmp = fma(a, pow((c / b), 2.0), c) / -b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(a * 2.0)) tmp = 0.0 if (t_0 <= -350.0) tmp = t_0; else tmp = Float64(fma(a, (Float64(c / b) ^ 2.0), c) / Float64(-b)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -350.0], t$95$0, N[(N[(a * N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision] + c), $MachinePrecision] / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{if}\;t\_0 \leq -350:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, {\left(\frac{c}{b}\right)}^{2}, c\right)}{-b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -350Initial program 82.6%
if -350 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 25.8%
*-commutative25.8%
Simplified25.8%
Taylor expanded in c around 0 92.7%
associate-*r/92.7%
neg-mul-192.7%
distribute-lft-neg-in92.7%
Simplified92.7%
Taylor expanded in b around inf 93.0%
distribute-lft-out93.0%
mul-1-neg93.0%
distribute-neg-frac93.0%
distribute-neg-frac293.0%
+-commutative93.0%
associate-/l*93.0%
fma-define93.0%
unpow293.0%
unpow293.0%
times-frac93.0%
unpow293.0%
Simplified93.0%
Final simplification92.0%
(FPCore (a b c) :precision binary64 (* c (+ (/ (- (* (pow (* c a) 2.0) (/ -2.0 (pow b 2.0))) (* c a)) (pow b 3.0)) (/ -1.0 b))))
double code(double a, double b, double c) {
return c * ((((pow((c * a), 2.0) * (-2.0 / pow(b, 2.0))) - (c * a)) / pow(b, 3.0)) + (-1.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 = c * ((((((c * a) ** 2.0d0) * ((-2.0d0) / (b ** 2.0d0))) - (c * a)) / (b ** 3.0d0)) + ((-1.0d0) / b))
end function
public static double code(double a, double b, double c) {
return c * ((((Math.pow((c * a), 2.0) * (-2.0 / Math.pow(b, 2.0))) - (c * a)) / Math.pow(b, 3.0)) + (-1.0 / b));
}
def code(a, b, c): return c * ((((math.pow((c * a), 2.0) * (-2.0 / math.pow(b, 2.0))) - (c * a)) / math.pow(b, 3.0)) + (-1.0 / b))
function code(a, b, c) return Float64(c * Float64(Float64(Float64(Float64((Float64(c * a) ^ 2.0) * Float64(-2.0 / (b ^ 2.0))) - Float64(c * a)) / (b ^ 3.0)) + Float64(-1.0 / b))) end
function tmp = code(a, b, c) tmp = c * ((((((c * a) ^ 2.0) * (-2.0 / (b ^ 2.0))) - (c * a)) / (b ^ 3.0)) + (-1.0 / b)); end
code[a_, b_, c_] := N[(c * N[(N[(N[(N[(N[Power[N[(c * a), $MachinePrecision], 2.0], $MachinePrecision] * N[(-2.0 / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \left(\frac{{\left(c \cdot a\right)}^{2} \cdot \frac{-2}{{b}^{2}} - c \cdot a}{{b}^{3}} + \frac{-1}{b}\right)
\end{array}
Initial program 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in c around 0 92.8%
Taylor expanded in b around inf 92.8%
mul-1-neg92.8%
*-commutative92.8%
unsub-neg92.8%
associate-*r/92.8%
*-commutative92.8%
associate-/l*92.8%
*-commutative92.8%
unpow292.8%
unpow292.8%
swap-sqr92.8%
unpow192.8%
pow-plus92.8%
metadata-eval92.8%
Simplified92.8%
Final simplification92.8%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0)))) (if (<= t_0 -350.0) t_0 (* c (- (/ -1.0 b) (* (* c a) (pow b -3.0)))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
double tmp;
if (t_0 <= -350.0) {
tmp = t_0;
} else {
tmp = c * ((-1.0 / b) - ((c * a) * pow(b, -3.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) :: t_0
real(8) :: tmp
t_0 = (sqrt(((b * b) - (c * (4.0d0 * a)))) - b) / (a * 2.0d0)
if (t_0 <= (-350.0d0)) then
tmp = t_0
else
tmp = c * (((-1.0d0) / b) - ((c * a) * (b ** (-3.0d0))))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (Math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
double tmp;
if (t_0 <= -350.0) {
tmp = t_0;
} else {
tmp = c * ((-1.0 / b) - ((c * a) * Math.pow(b, -3.0)));
}
return tmp;
}
def code(a, b, c): t_0 = (math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0) tmp = 0 if t_0 <= -350.0: tmp = t_0 else: tmp = c * ((-1.0 / b) - ((c * a) * math.pow(b, -3.0))) return tmp
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(a * 2.0)) tmp = 0.0 if (t_0 <= -350.0) tmp = t_0; else tmp = Float64(c * Float64(Float64(-1.0 / b) - Float64(Float64(c * a) * (b ^ -3.0)))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0); tmp = 0.0; if (t_0 <= -350.0) tmp = t_0; else tmp = c * ((-1.0 / b) - ((c * a) * (b ^ -3.0))); 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[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -350.0], t$95$0, N[(c * N[(N[(-1.0 / b), $MachinePrecision] - N[(N[(c * a), $MachinePrecision] * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{if}\;t\_0 \leq -350:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(\frac{-1}{b} - \left(c \cdot a\right) \cdot {b}^{-3}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -350Initial program 82.6%
if -350 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) Initial program 25.8%
*-commutative25.8%
Simplified25.8%
Taylor expanded in c around 0 92.7%
associate-*r/92.7%
neg-mul-192.7%
distribute-lft-neg-in92.7%
Simplified92.7%
pow192.7%
associate-/l*92.7%
fmm-def92.7%
div-inv92.7%
pow-flip92.7%
metadata-eval92.7%
Applied egg-rr92.7%
unpow192.7%
fma-define92.7%
+-commutative92.7%
neg-mul-192.7%
fma-define92.7%
associate-*r*92.7%
distribute-lft-neg-in92.7%
distribute-lft-neg-out92.7%
fmm-undef92.7%
associate-*r/92.7%
metadata-eval92.7%
Simplified92.7%
Final simplification91.8%
(FPCore (a b c) :precision binary64 (* c (/ (- -1.0 (* a (/ c (pow b 2.0)))) b)))
double code(double a, double b, double c) {
return c * ((-1.0 - (a * (c / pow(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 = c * (((-1.0d0) - (a * (c / (b ** 2.0d0)))) / b)
end function
public static double code(double a, double b, double c) {
return c * ((-1.0 - (a * (c / Math.pow(b, 2.0)))) / b);
}
def code(a, b, c): return c * ((-1.0 - (a * (c / math.pow(b, 2.0)))) / b)
function code(a, b, c) return Float64(c * Float64(Float64(-1.0 - Float64(a * Float64(c / (b ^ 2.0)))) / b)) end
function tmp = code(a, b, c) tmp = c * ((-1.0 - (a * (c / (b ^ 2.0)))) / b); end
code[a_, b_, c_] := N[(c * N[(N[(-1.0 - N[(a * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-1 - a \cdot \frac{c}{{b}^{2}}}{b}
\end{array}
Initial program 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in c around 0 89.6%
associate-*r/89.6%
neg-mul-189.6%
distribute-lft-neg-in89.6%
Simplified89.6%
Taylor expanded in b around inf 89.6%
mul-1-neg89.6%
associate-/l*89.6%
Applied egg-rr89.6%
Final simplification89.6%
(FPCore (a b c) :precision binary64 (* c (- (/ -1.0 b) (* (* c a) (pow b -3.0)))))
double code(double a, double b, double c) {
return c * ((-1.0 / b) - ((c * a) * 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 = c * (((-1.0d0) / b) - ((c * a) * (b ** (-3.0d0))))
end function
public static double code(double a, double b, double c) {
return c * ((-1.0 / b) - ((c * a) * Math.pow(b, -3.0)));
}
def code(a, b, c): return c * ((-1.0 / b) - ((c * a) * math.pow(b, -3.0)))
function code(a, b, c) return Float64(c * Float64(Float64(-1.0 / b) - Float64(Float64(c * a) * (b ^ -3.0)))) end
function tmp = code(a, b, c) tmp = c * ((-1.0 / b) - ((c * a) * (b ^ -3.0))); end
code[a_, b_, c_] := N[(c * N[(N[(-1.0 / b), $MachinePrecision] - N[(N[(c * a), $MachinePrecision] * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \left(\frac{-1}{b} - \left(c \cdot a\right) \cdot {b}^{-3}\right)
\end{array}
Initial program 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in c around 0 89.6%
associate-*r/89.6%
neg-mul-189.6%
distribute-lft-neg-in89.6%
Simplified89.6%
pow189.6%
associate-/l*89.6%
fmm-def89.6%
div-inv89.6%
pow-flip89.6%
metadata-eval89.6%
Applied egg-rr89.6%
unpow189.6%
fma-define89.6%
+-commutative89.6%
neg-mul-189.6%
fma-define89.6%
associate-*r*89.6%
distribute-lft-neg-in89.6%
distribute-lft-neg-out89.6%
fmm-undef89.6%
associate-*r/89.6%
metadata-eval89.6%
Simplified89.6%
Final simplification89.6%
(FPCore (a b c) :precision binary64 (/ c (- b)))
double code(double a, double b, double c) {
return 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 = c / -b
end function
public static double code(double a, double b, double c) {
return c / -b;
}
def code(a, b, c): return c / -b
function code(a, b, c) return Float64(c / Float64(-b)) end
function tmp = code(a, b, c) tmp = c / -b; end
code[a_, b_, c_] := N[(c / (-b)), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{-b}
\end{array}
Initial program 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in b around inf 81.1%
associate-*r/81.1%
mul-1-neg81.1%
Simplified81.1%
Final simplification81.1%
(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 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in c around 0 89.6%
associate-*r/89.6%
neg-mul-189.6%
distribute-lft-neg-in89.6%
Simplified89.6%
Taylor expanded in a around 0 80.9%
expm1-log1p-u72.6%
expm1-undefine32.4%
Applied egg-rr32.4%
sub-neg32.4%
log1p-undefine32.4%
associate-*r/32.4%
*-commutative32.4%
neg-mul-132.4%
distribute-neg-frac32.4%
rem-exp-log40.7%
unsub-neg40.7%
metadata-eval40.7%
Simplified40.7%
Taylor expanded in c around 0 3.2%
Final simplification3.2%
herbie shell --seed 2024131
(FPCore (a b c)
:name "Quadratic roots, medium range"
:precision binary64
:pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))