
(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 7 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
(let* ((t_0 (pow (* a c) 4.0)))
(+
(* -2.0 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
(-
(-
(* -0.25 (/ (+ (* 16.0 t_0) (* 4.0 t_0)) (* a (pow b 7.0))))
(/ (* a (pow c 2.0)) (pow b 3.0)))
(/ c b)))))
double code(double a, double b, double c) {
double t_0 = pow((a * c), 4.0);
return (-2.0 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + (((-0.25 * (((16.0 * t_0) + (4.0 * t_0)) / (a * pow(b, 7.0)))) - ((a * pow(c, 2.0)) / 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
real(8) :: t_0
t_0 = (a * c) ** 4.0d0
code = ((-2.0d0) * (((a ** 2.0d0) * (c ** 3.0d0)) / (b ** 5.0d0))) + ((((-0.25d0) * (((16.0d0 * t_0) + (4.0d0 * t_0)) / (a * (b ** 7.0d0)))) - ((a * (c ** 2.0d0)) / (b ** 3.0d0))) - (c / b))
end function
public static double code(double a, double b, double c) {
double t_0 = Math.pow((a * c), 4.0);
return (-2.0 * ((Math.pow(a, 2.0) * Math.pow(c, 3.0)) / Math.pow(b, 5.0))) + (((-0.25 * (((16.0 * t_0) + (4.0 * t_0)) / (a * Math.pow(b, 7.0)))) - ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0))) - (c / b));
}
def code(a, b, c): t_0 = math.pow((a * c), 4.0) return (-2.0 * ((math.pow(a, 2.0) * math.pow(c, 3.0)) / math.pow(b, 5.0))) + (((-0.25 * (((16.0 * t_0) + (4.0 * t_0)) / (a * math.pow(b, 7.0)))) - ((a * math.pow(c, 2.0)) / math.pow(b, 3.0))) - (c / b))
function code(a, b, c) t_0 = Float64(a * c) ^ 4.0 return Float64(Float64(-2.0 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(Float64(-0.25 * Float64(Float64(Float64(16.0 * t_0) + Float64(4.0 * t_0)) / Float64(a * (b ^ 7.0)))) - Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) - Float64(c / b))) end
function tmp = code(a, b, c) t_0 = (a * c) ^ 4.0; tmp = (-2.0 * (((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + (((-0.25 * (((16.0 * t_0) + (4.0 * t_0)) / (a * (b ^ 7.0)))) - ((a * (c ^ 2.0)) / (b ^ 3.0))) - (c / b)); end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(a * c), $MachinePrecision], 4.0], $MachinePrecision]}, N[(N[(-2.0 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-0.25 * N[(N[(N[(16.0 * t$95$0), $MachinePrecision] + N[(4.0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot c\right)}^{4}\\
-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(\left(-0.25 \cdot \frac{16 \cdot t\_0 + 4 \cdot t\_0}{a \cdot {b}^{7}} - \frac{a \cdot {c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\right)
\end{array}
\end{array}
Initial program 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 91.0%
*-commutative91.0%
unpow-prod-down91.0%
pow-prod-down91.0%
pow-pow91.0%
metadata-eval91.0%
metadata-eval91.0%
Applied egg-rr91.0%
pow-prod-down91.0%
metadata-eval91.0%
pow-pow91.0%
Applied egg-rr91.0%
unpow291.0%
pow-sqr91.0%
metadata-eval91.0%
Simplified91.0%
Final simplification91.0%
(FPCore (a b c) :precision binary64 (- (* -2.0 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0))) (+ (/ c b) (/ (* a (pow c 2.0)) (pow b 3.0)))))
double code(double a, double b, double c) {
return (-2.0 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) - ((c / b) + ((a * pow(c, 2.0)) / 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 = ((-2.0d0) * (((a ** 2.0d0) * (c ** 3.0d0)) / (b ** 5.0d0))) - ((c / b) + ((a * (c ** 2.0d0)) / (b ** 3.0d0)))
end function
public static double code(double a, double b, double c) {
return (-2.0 * ((Math.pow(a, 2.0) * Math.pow(c, 3.0)) / Math.pow(b, 5.0))) - ((c / b) + ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0)));
}
def code(a, b, c): return (-2.0 * ((math.pow(a, 2.0) * math.pow(c, 3.0)) / math.pow(b, 5.0))) - ((c / b) + ((a * math.pow(c, 2.0)) / math.pow(b, 3.0)))
function code(a, b, c) return Float64(Float64(-2.0 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) - Float64(Float64(c / b) + Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0)))) end
function tmp = code(a, b, c) tmp = (-2.0 * (((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) - ((c / b) + ((a * (c ^ 2.0)) / (b ^ 3.0))); end
code[a_, b_, c_] := N[(N[(-2.0 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c / b), $MachinePrecision] + N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} - \left(\frac{c}{b} + \frac{a \cdot {c}^{2}}{{b}^{3}}\right)
\end{array}
Initial program 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 87.9%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* a c) b)))
(/
(+
(* -4.0 (/ (* (pow c 3.0) (pow a 3.0)) (pow b 5.0)))
(+ (* -2.0 t_0) (* -2.0 (* t_0 (/ (* a c) (pow b 2.0))))))
(* a 2.0))))
double code(double a, double b, double c) {
double t_0 = (a * c) / b;
return ((-4.0 * ((pow(c, 3.0) * pow(a, 3.0)) / pow(b, 5.0))) + ((-2.0 * t_0) + (-2.0 * (t_0 * ((a * c) / pow(b, 2.0)))))) / (a * 2.0);
}
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
t_0 = (a * c) / b
code = (((-4.0d0) * (((c ** 3.0d0) * (a ** 3.0d0)) / (b ** 5.0d0))) + (((-2.0d0) * t_0) + ((-2.0d0) * (t_0 * ((a * c) / (b ** 2.0d0)))))) / (a * 2.0d0)
end function
public static double code(double a, double b, double c) {
double t_0 = (a * c) / b;
return ((-4.0 * ((Math.pow(c, 3.0) * Math.pow(a, 3.0)) / Math.pow(b, 5.0))) + ((-2.0 * t_0) + (-2.0 * (t_0 * ((a * c) / Math.pow(b, 2.0)))))) / (a * 2.0);
}
def code(a, b, c): t_0 = (a * c) / b return ((-4.0 * ((math.pow(c, 3.0) * math.pow(a, 3.0)) / math.pow(b, 5.0))) + ((-2.0 * t_0) + (-2.0 * (t_0 * ((a * c) / math.pow(b, 2.0)))))) / (a * 2.0)
function code(a, b, c) t_0 = Float64(Float64(a * c) / b) return Float64(Float64(Float64(-4.0 * Float64(Float64((c ^ 3.0) * (a ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-2.0 * t_0) + Float64(-2.0 * Float64(t_0 * Float64(Float64(a * c) / (b ^ 2.0)))))) / Float64(a * 2.0)) end
function tmp = code(a, b, c) t_0 = (a * c) / b; tmp = ((-4.0 * (((c ^ 3.0) * (a ^ 3.0)) / (b ^ 5.0))) + ((-2.0 * t_0) + (-2.0 * (t_0 * ((a * c) / (b ^ 2.0)))))) / (a * 2.0); end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] / b), $MachinePrecision]}, N[(N[(N[(-4.0 * N[(N[(N[Power[c, 3.0], $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 * t$95$0), $MachinePrecision] + N[(-2.0 * N[(t$95$0 * N[(N[(a * c), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c}{b}\\
\frac{-4 \cdot \frac{{c}^{3} \cdot {a}^{3}}{{b}^{5}} + \left(-2 \cdot t\_0 + -2 \cdot \left(t\_0 \cdot \frac{a \cdot c}{{b}^{2}}\right)\right)}{a \cdot 2}
\end{array}
\end{array}
Initial program 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 87.7%
add-sqr-sqrt87.7%
sqrt-div87.7%
sqrt-prod87.7%
sqrt-pow187.7%
metadata-eval87.7%
pow187.7%
sqrt-pow187.7%
metadata-eval87.7%
pow187.7%
rem-cbrt-cube87.7%
rem-cbrt-cube87.7%
cbrt-prod87.7%
sqrt-pow187.7%
sqrt-div87.7%
Applied egg-rr87.7%
Final simplification87.7%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)) -0.00075) (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0)) (- (* a (/ (* (/ c (pow b 2.0)) (- c)) b)) (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0)) <= -0.00075) {
tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
} else {
tmp = (a * (((c / pow(b, 2.0)) * -c) / b)) - (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)) <= -0.00075) tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(a * Float64(Float64(Float64(c / (b ^ 2.0)) * Float64(-c)) / b)) - Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], -0.00075], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] * (-c)), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2} \leq -0.00075:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{\frac{c}{{b}^{2}} \cdot \left(-c\right)}{b} - \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < -7.5000000000000002e-4Initial program 76.8%
*-commutative76.8%
+-commutative76.8%
sqr-neg76.8%
unsub-neg76.8%
sqr-neg76.8%
fma-neg76.9%
distribute-lft-neg-in76.9%
*-commutative76.9%
*-commutative76.9%
distribute-rgt-neg-in76.9%
metadata-eval76.9%
Simplified76.9%
if -7.5000000000000002e-4 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) Initial program 39.6%
*-commutative39.6%
Simplified39.6%
Taylor expanded in b around inf 93.4%
distribute-lft-out93.4%
associate-/l*93.4%
Simplified93.4%
unpow293.4%
cube-mult93.4%
times-frac93.4%
pow293.4%
Applied egg-rr93.4%
associate-*l/93.4%
Simplified93.4%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))))
(if (<= t_0 -0.00075)
t_0
(- (* a (/ (* (/ c (pow b 2.0)) (- c)) b)) (/ c b)))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
double tmp;
if (t_0 <= -0.00075) {
tmp = t_0;
} else {
tmp = (a * (((c / pow(b, 2.0)) * -c) / b)) - (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 * 4.0d0)))) - b) / (a * 2.0d0)
if (t_0 <= (-0.00075d0)) then
tmp = t_0
else
tmp = (a * (((c / (b ** 2.0d0)) * -c) / b)) - (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 * 4.0)))) - b) / (a * 2.0);
double tmp;
if (t_0 <= -0.00075) {
tmp = t_0;
} else {
tmp = (a * (((c / Math.pow(b, 2.0)) * -c) / b)) - (c / b);
}
return tmp;
}
def code(a, b, c): t_0 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp = 0 if t_0 <= -0.00075: tmp = t_0 else: tmp = (a * (((c / math.pow(b, 2.0)) * -c) / b)) - (c / b) return tmp
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)) tmp = 0.0 if (t_0 <= -0.00075) tmp = t_0; else tmp = Float64(Float64(a * Float64(Float64(Float64(c / (b ^ 2.0)) * Float64(-c)) / b)) - Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); tmp = 0.0; if (t_0 <= -0.00075) tmp = t_0; else tmp = (a * (((c / (b ^ 2.0)) * -c) / b)) - (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 * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.00075], t$95$0, N[(N[(a * N[(N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] * (-c)), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{if}\;t\_0 \leq -0.00075:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{\frac{c}{{b}^{2}} \cdot \left(-c\right)}{b} - \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < -7.5000000000000002e-4Initial program 76.8%
if -7.5000000000000002e-4 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) Initial program 39.6%
*-commutative39.6%
Simplified39.6%
Taylor expanded in b around inf 93.4%
distribute-lft-out93.4%
associate-/l*93.4%
Simplified93.4%
unpow293.4%
cube-mult93.4%
times-frac93.4%
pow293.4%
Applied egg-rr93.4%
associate-*l/93.4%
Simplified93.4%
Final simplification86.3%
(FPCore (a b c) :precision binary64 (- (* a (/ (* (/ c (pow b 2.0)) (- c)) b)) (/ c b)))
double code(double a, double b, double c) {
return (a * (((c / pow(b, 2.0)) * -c) / b)) - (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 = (a * (((c / (b ** 2.0d0)) * -c) / b)) - (c / b)
end function
public static double code(double a, double b, double c) {
return (a * (((c / Math.pow(b, 2.0)) * -c) / b)) - (c / b);
}
def code(a, b, c): return (a * (((c / math.pow(b, 2.0)) * -c) / b)) - (c / b)
function code(a, b, c) return Float64(Float64(a * Float64(Float64(Float64(c / (b ^ 2.0)) * Float64(-c)) / b)) - Float64(c / b)) end
function tmp = code(a, b, c) tmp = (a * (((c / (b ^ 2.0)) * -c) / b)) - (c / b); end
code[a_, b_, c_] := N[(N[(a * N[(N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] * (-c)), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \frac{\frac{c}{{b}^{2}} \cdot \left(-c\right)}{b} - \frac{c}{b}
\end{array}
Initial program 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 82.0%
distribute-lft-out82.0%
associate-/l*82.0%
Simplified82.0%
unpow282.0%
cube-mult82.0%
times-frac82.0%
pow282.0%
Applied egg-rr82.0%
associate-*l/82.0%
Simplified82.0%
Final simplification82.0%
(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 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 64.6%
mul-1-neg64.6%
distribute-neg-frac64.6%
Simplified64.6%
Final simplification64.6%
herbie shell --seed 2024050
(FPCore (a b c)
:name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))