
(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 11 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 (* a (* c 4.0))))
(if (<= b -2.1e+76)
(- (/ c b) (/ b a))
(if (<= b 2.5e-98)
(/ 1.0 (/ a (* (- b (sqrt (fma a (* c -4.0) (* b b)))) -0.5)))
(if (<= b 7e+36)
(/
(* -0.5 (/ (+ (- (* b b) (* b b)) t_0) (+ b (sqrt (- (* b b) t_0)))))
a)
(/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double tmp;
if (b <= -2.1e+76) {
tmp = (c / b) - (b / a);
} else if (b <= 2.5e-98) {
tmp = 1.0 / (a / ((b - sqrt(fma(a, (c * -4.0), (b * b)))) * -0.5));
} else if (b <= 7e+36) {
tmp = (-0.5 * ((((b * b) - (b * b)) + t_0) / (b + sqrt(((b * b) - t_0))))) / a;
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(a * Float64(c * 4.0)) tmp = 0.0 if (b <= -2.1e+76) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.5e-98) tmp = Float64(1.0 / Float64(a / Float64(Float64(b - sqrt(fma(a, Float64(c * -4.0), Float64(b * b)))) * -0.5))); elseif (b <= 7e+36) tmp = Float64(Float64(-0.5 * Float64(Float64(Float64(Float64(b * b) - Float64(b * b)) + t_0) / Float64(b + sqrt(Float64(Float64(b * b) - t_0))))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.1e+76], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-98], N[(1.0 / N[(a / N[(N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7e+36], N[(N[(-0.5 * N[(N[(N[(N[(b * b), $MachinePrecision] - N[(b * b), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot 4\right)\\
\mathbf{if}\;b \leq -2.1 \cdot 10^{+76}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right) \cdot -0.5}}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{+36}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\left(b \cdot b - b \cdot b\right) + t_0}{b + \sqrt{b \cdot b - t_0}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.10000000000000007e76Initial program 76.7%
neg-sub076.7%
associate-+l-76.7%
sub0-neg76.7%
neg-mul-176.7%
associate-*l/76.6%
*-commutative76.6%
associate-/r*76.6%
/-rgt-identity76.6%
metadata-eval76.6%
Simplified76.6%
Taylor expanded in b around -inf 94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -2.10000000000000007e76 < b < 2.50000000000000009e-98Initial program 83.4%
neg-sub083.4%
associate-+l-83.4%
sub0-neg83.4%
neg-mul-183.4%
associate-*l/83.2%
*-commutative83.2%
associate-/r*83.2%
/-rgt-identity83.2%
metadata-eval83.2%
Simplified83.2%
associate-*r/83.4%
clear-num83.4%
Applied egg-rr83.4%
if 2.50000000000000009e-98 < b < 6.9999999999999996e36Initial program 55.1%
neg-sub055.1%
associate-+l-55.1%
sub0-neg55.1%
neg-mul-155.1%
associate-*l/55.0%
*-commutative55.0%
associate-/r*55.0%
/-rgt-identity55.0%
metadata-eval55.0%
Simplified55.0%
fma-udef55.0%
*-commutative55.0%
associate-*r*55.0%
metadata-eval55.0%
distribute-rgt-neg-in55.0%
*-commutative55.0%
distribute-lft-neg-in55.0%
+-commutative55.0%
sub-neg55.0%
*-commutative55.0%
associate-*l*55.0%
Applied egg-rr55.0%
*-commutative55.0%
Simplified55.0%
associate-*r/55.1%
Applied egg-rr55.1%
flip--54.8%
add-sqr-sqrt54.8%
Applied egg-rr54.8%
associate-+l-89.1%
Simplified89.1%
if 6.9999999999999996e36 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
associate-*l/16.7%
*-commutative16.7%
associate-/r*16.7%
/-rgt-identity16.7%
metadata-eval16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
mul-1-neg94.1%
distribute-neg-frac94.1%
Simplified94.1%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* a (* c 4.0))) (t_1 (sqrt (- (* b b) t_0))))
(if (<= b -1e+118)
(- (/ c b) (/ b a))
(if (<= b 9e-156)
(/ (* -0.5 (- b t_1)) a)
(if (<= b 1.1e+37)
(* (/ (+ (- (* b b) (* b b)) t_0) (+ b t_1)) (/ -0.5 a))
(/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = sqrt(((b * b) - t_0));
double tmp;
if (b <= -1e+118) {
tmp = (c / b) - (b / a);
} else if (b <= 9e-156) {
tmp = (-0.5 * (b - t_1)) / a;
} else if (b <= 1.1e+37) {
tmp = ((((b * b) - (b * b)) + t_0) / (b + t_1)) * (-0.5 / a);
} else {
tmp = -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 = a * (c * 4.0d0)
t_1 = sqrt(((b * b) - t_0))
if (b <= (-1d+118)) then
tmp = (c / b) - (b / a)
else if (b <= 9d-156) then
tmp = ((-0.5d0) * (b - t_1)) / a
else if (b <= 1.1d+37) then
tmp = ((((b * b) - (b * b)) + t_0) / (b + t_1)) * ((-0.5d0) / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = Math.sqrt(((b * b) - t_0));
double tmp;
if (b <= -1e+118) {
tmp = (c / b) - (b / a);
} else if (b <= 9e-156) {
tmp = (-0.5 * (b - t_1)) / a;
} else if (b <= 1.1e+37) {
tmp = ((((b * b) - (b * b)) + t_0) / (b + t_1)) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = a * (c * 4.0) t_1 = math.sqrt(((b * b) - t_0)) tmp = 0 if b <= -1e+118: tmp = (c / b) - (b / a) elif b <= 9e-156: tmp = (-0.5 * (b - t_1)) / a elif b <= 1.1e+37: tmp = ((((b * b) - (b * b)) + t_0) / (b + t_1)) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(a * Float64(c * 4.0)) t_1 = sqrt(Float64(Float64(b * b) - t_0)) tmp = 0.0 if (b <= -1e+118) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 9e-156) tmp = Float64(Float64(-0.5 * Float64(b - t_1)) / a); elseif (b <= 1.1e+37) tmp = Float64(Float64(Float64(Float64(Float64(b * b) - Float64(b * b)) + t_0) / Float64(b + t_1)) * Float64(-0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = a * (c * 4.0); t_1 = sqrt(((b * b) - t_0)); tmp = 0.0; if (b <= -1e+118) tmp = (c / b) - (b / a); elseif (b <= 9e-156) tmp = (-0.5 * (b - t_1)) / a; elseif (b <= 1.1e+37) tmp = ((((b * b) - (b * b)) + t_0) / (b + t_1)) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1e+118], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-156], N[(N[(-0.5 * N[(b - t$95$1), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.1e+37], N[(N[(N[(N[(N[(b * b), $MachinePrecision] - N[(b * b), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot 4\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+118}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-156}:\\
\;\;\;\;\frac{-0.5 \cdot \left(b - t_1\right)}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+37}:\\
\;\;\;\;\frac{\left(b \cdot b - b \cdot b\right) + t_0}{b + t_1} \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -9.99999999999999967e117Initial program 71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
associate-*l/71.1%
*-commutative71.1%
associate-/r*71.1%
/-rgt-identity71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in b around -inf 92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -9.99999999999999967e117 < b < 8.99999999999999971e-156Initial program 86.1%
neg-sub086.1%
associate-+l-86.1%
sub0-neg86.1%
neg-mul-186.1%
associate-*l/85.9%
*-commutative85.9%
associate-/r*85.9%
/-rgt-identity85.9%
metadata-eval85.9%
Simplified85.9%
fma-udef85.9%
*-commutative85.9%
associate-*r*85.9%
metadata-eval85.9%
distribute-rgt-neg-in85.9%
*-commutative85.9%
distribute-lft-neg-in85.9%
+-commutative85.9%
sub-neg85.9%
*-commutative85.9%
associate-*l*85.9%
Applied egg-rr85.9%
*-commutative85.9%
Simplified85.9%
associate-*r/86.1%
Applied egg-rr86.1%
if 8.99999999999999971e-156 < b < 1.1e37Initial program 60.2%
neg-sub060.2%
associate-+l-60.2%
sub0-neg60.2%
neg-mul-160.2%
associate-*l/60.0%
*-commutative60.0%
associate-/r*60.0%
/-rgt-identity60.0%
metadata-eval60.0%
Simplified60.0%
fma-udef60.0%
*-commutative60.0%
associate-*r*60.0%
metadata-eval60.0%
distribute-rgt-neg-in60.0%
*-commutative60.0%
distribute-lft-neg-in60.0%
+-commutative60.0%
sub-neg60.0%
*-commutative60.0%
associate-*l*60.0%
Applied egg-rr60.0%
*-commutative60.0%
Simplified60.0%
flip--59.9%
add-sqr-sqrt59.9%
Applied egg-rr59.9%
associate-+l-85.7%
Simplified85.6%
if 1.1e37 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
associate-*l/16.7%
*-commutative16.7%
associate-/r*16.7%
/-rgt-identity16.7%
metadata-eval16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
mul-1-neg94.1%
distribute-neg-frac94.1%
Simplified94.1%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* a (* c 4.0))) (t_1 (sqrt (- (* b b) t_0))))
(if (<= b -2e+119)
(- (/ c b) (/ b a))
(if (<= b 2.5e-98)
(/ (* -0.5 (- b t_1)) a)
(if (<= b 9.2e+33)
(/ (* -0.5 (/ (+ (- (* b b) (* b b)) t_0) (+ b t_1))) a)
(/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = sqrt(((b * b) - t_0));
double tmp;
if (b <= -2e+119) {
tmp = (c / b) - (b / a);
} else if (b <= 2.5e-98) {
tmp = (-0.5 * (b - t_1)) / a;
} else if (b <= 9.2e+33) {
tmp = (-0.5 * ((((b * b) - (b * b)) + t_0) / (b + t_1))) / a;
} else {
tmp = -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 = a * (c * 4.0d0)
t_1 = sqrt(((b * b) - t_0))
if (b <= (-2d+119)) then
tmp = (c / b) - (b / a)
else if (b <= 2.5d-98) then
tmp = ((-0.5d0) * (b - t_1)) / a
else if (b <= 9.2d+33) then
tmp = ((-0.5d0) * ((((b * b) - (b * b)) + t_0) / (b + t_1))) / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = Math.sqrt(((b * b) - t_0));
double tmp;
if (b <= -2e+119) {
tmp = (c / b) - (b / a);
} else if (b <= 2.5e-98) {
tmp = (-0.5 * (b - t_1)) / a;
} else if (b <= 9.2e+33) {
tmp = (-0.5 * ((((b * b) - (b * b)) + t_0) / (b + t_1))) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = a * (c * 4.0) t_1 = math.sqrt(((b * b) - t_0)) tmp = 0 if b <= -2e+119: tmp = (c / b) - (b / a) elif b <= 2.5e-98: tmp = (-0.5 * (b - t_1)) / a elif b <= 9.2e+33: tmp = (-0.5 * ((((b * b) - (b * b)) + t_0) / (b + t_1))) / a else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(a * Float64(c * 4.0)) t_1 = sqrt(Float64(Float64(b * b) - t_0)) tmp = 0.0 if (b <= -2e+119) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.5e-98) tmp = Float64(Float64(-0.5 * Float64(b - t_1)) / a); elseif (b <= 9.2e+33) tmp = Float64(Float64(-0.5 * Float64(Float64(Float64(Float64(b * b) - Float64(b * b)) + t_0) / Float64(b + t_1))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = a * (c * 4.0); t_1 = sqrt(((b * b) - t_0)); tmp = 0.0; if (b <= -2e+119) tmp = (c / b) - (b / a); elseif (b <= 2.5e-98) tmp = (-0.5 * (b - t_1)) / a; elseif (b <= 9.2e+33) tmp = (-0.5 * ((((b * b) - (b * b)) + t_0) / (b + t_1))) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2e+119], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-98], N[(N[(-0.5 * N[(b - t$95$1), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 9.2e+33], N[(N[(-0.5 * N[(N[(N[(N[(b * b), $MachinePrecision] - N[(b * b), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot 4\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+119}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{-0.5 \cdot \left(b - t_1\right)}{a}\\
\mathbf{elif}\;b \leq 9.2 \cdot 10^{+33}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{\left(b \cdot b - b \cdot b\right) + t_0}{b + t_1}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.99999999999999989e119Initial program 71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
associate-*l/71.1%
*-commutative71.1%
associate-/r*71.1%
/-rgt-identity71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in b around -inf 92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -1.99999999999999989e119 < b < 2.50000000000000009e-98Initial program 85.3%
neg-sub085.3%
associate-+l-85.3%
sub0-neg85.3%
neg-mul-185.3%
associate-*l/85.0%
*-commutative85.0%
associate-/r*85.0%
/-rgt-identity85.0%
metadata-eval85.0%
Simplified85.0%
fma-udef85.0%
*-commutative85.0%
associate-*r*85.0%
metadata-eval85.0%
distribute-rgt-neg-in85.0%
*-commutative85.0%
distribute-lft-neg-in85.0%
+-commutative85.0%
sub-neg85.0%
*-commutative85.0%
associate-*l*85.0%
Applied egg-rr85.0%
*-commutative85.0%
Simplified85.0%
associate-*r/85.3%
Applied egg-rr85.3%
if 2.50000000000000009e-98 < b < 9.20000000000000042e33Initial program 55.1%
neg-sub055.1%
associate-+l-55.1%
sub0-neg55.1%
neg-mul-155.1%
associate-*l/55.0%
*-commutative55.0%
associate-/r*55.0%
/-rgt-identity55.0%
metadata-eval55.0%
Simplified55.0%
fma-udef55.0%
*-commutative55.0%
associate-*r*55.0%
metadata-eval55.0%
distribute-rgt-neg-in55.0%
*-commutative55.0%
distribute-lft-neg-in55.0%
+-commutative55.0%
sub-neg55.0%
*-commutative55.0%
associate-*l*55.0%
Applied egg-rr55.0%
*-commutative55.0%
Simplified55.0%
associate-*r/55.1%
Applied egg-rr55.1%
flip--54.8%
add-sqr-sqrt54.8%
Applied egg-rr54.8%
associate-+l-89.1%
Simplified89.1%
if 9.20000000000000042e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
associate-*l/16.7%
*-commutative16.7%
associate-/r*16.7%
/-rgt-identity16.7%
metadata-eval16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
mul-1-neg94.1%
distribute-neg-frac94.1%
Simplified94.1%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))))
(if (<= b -7.8e-103)
(- (/ c b) (/ b a))
(if (<= b 1.45e-101)
t_0
(if (<= b 3.2e-34)
(/ 1.0 (- (/ a b) (/ b c)))
(if (<= b 1.8e+33) t_0 (/ (- c) b)))))))
double code(double a, double b, double c) {
double t_0 = (-0.5 / a) * (b - sqrt((a * (c * -4.0))));
double tmp;
if (b <= -7.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.45e-101) {
tmp = t_0;
} else if (b <= 3.2e-34) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 1.8e+33) {
tmp = t_0;
} else {
tmp = -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 = ((-0.5d0) / a) * (b - sqrt((a * (c * (-4.0d0)))))
if (b <= (-7.8d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 1.45d-101) then
tmp = t_0
else if (b <= 3.2d-34) then
tmp = 1.0d0 / ((a / b) - (b / c))
else if (b <= 1.8d+33) then
tmp = t_0
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (-0.5 / a) * (b - Math.sqrt((a * (c * -4.0))));
double tmp;
if (b <= -7.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.45e-101) {
tmp = t_0;
} else if (b <= 3.2e-34) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 1.8e+33) {
tmp = t_0;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = (-0.5 / a) * (b - math.sqrt((a * (c * -4.0)))) tmp = 0 if b <= -7.8e-103: tmp = (c / b) - (b / a) elif b <= 1.45e-101: tmp = t_0 elif b <= 3.2e-34: tmp = 1.0 / ((a / b) - (b / c)) elif b <= 1.8e+33: tmp = t_0 else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))) tmp = 0.0 if (b <= -7.8e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.45e-101) tmp = t_0; elseif (b <= 3.2e-34) tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); elseif (b <= 1.8e+33) tmp = t_0; else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (-0.5 / a) * (b - sqrt((a * (c * -4.0)))); tmp = 0.0; if (b <= -7.8e-103) tmp = (c / b) - (b / a); elseif (b <= 1.45e-101) tmp = t_0; elseif (b <= 3.2e-34) tmp = 1.0 / ((a / b) - (b / c)); elseif (b <= 1.8e+33) tmp = t_0; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -7.8e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.45e-101], t$95$0, If[LessEqual[b, 3.2e-34], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+33], t$95$0, N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{if}\;b \leq -7.8 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-101}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -7.8000000000000004e-103Initial program 83.7%
neg-sub083.7%
associate-+l-83.7%
sub0-neg83.7%
neg-mul-183.7%
associate-*l/83.5%
*-commutative83.5%
associate-/r*83.5%
/-rgt-identity83.5%
metadata-eval83.5%
Simplified83.5%
Taylor expanded in b around -inf 86.5%
mul-1-neg86.5%
unsub-neg86.5%
Simplified86.5%
if -7.8000000000000004e-103 < b < 1.45e-101 or 3.20000000000000003e-34 < b < 1.8000000000000001e33Initial program 75.6%
neg-sub075.6%
associate-+l-75.6%
sub0-neg75.6%
neg-mul-175.6%
associate-*l/75.5%
*-commutative75.5%
associate-/r*75.5%
/-rgt-identity75.5%
metadata-eval75.5%
Simplified75.5%
Taylor expanded in a around inf 74.3%
*-commutative74.3%
*-commutative74.3%
associate-*r*74.3%
Simplified74.3%
if 1.45e-101 < b < 3.20000000000000003e-34Initial program 37.5%
neg-sub037.5%
associate-+l-37.5%
sub0-neg37.5%
neg-mul-137.5%
associate-*l/37.3%
*-commutative37.3%
associate-/r*37.3%
/-rgt-identity37.3%
metadata-eval37.3%
Simplified37.3%
associate-*r/37.5%
clear-num37.3%
Applied egg-rr37.3%
Taylor expanded in a around 0 71.2%
mul-1-neg71.2%
unsub-neg71.2%
Simplified71.2%
if 1.8000000000000001e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
associate-*l/16.7%
*-commutative16.7%
associate-/r*16.7%
/-rgt-identity16.7%
metadata-eval16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
mul-1-neg94.1%
distribute-neg-frac94.1%
Simplified94.1%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* -0.5 (- b (sqrt (* a (* c -4.0))))) a)))
(if (<= b -8.8e-103)
(- (/ c b) (/ b a))
(if (<= b 5.5e-100)
t_0
(if (<= b 5e-36)
(/ 1.0 (- (/ a b) (/ b c)))
(if (<= b 1.8e+33) t_0 (/ (- c) b)))))))
double code(double a, double b, double c) {
double t_0 = (-0.5 * (b - sqrt((a * (c * -4.0))))) / a;
double tmp;
if (b <= -8.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 5.5e-100) {
tmp = t_0;
} else if (b <= 5e-36) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 1.8e+33) {
tmp = t_0;
} else {
tmp = -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 = ((-0.5d0) * (b - sqrt((a * (c * (-4.0d0)))))) / a
if (b <= (-8.8d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 5.5d-100) then
tmp = t_0
else if (b <= 5d-36) then
tmp = 1.0d0 / ((a / b) - (b / c))
else if (b <= 1.8d+33) then
tmp = t_0
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (-0.5 * (b - Math.sqrt((a * (c * -4.0))))) / a;
double tmp;
if (b <= -8.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 5.5e-100) {
tmp = t_0;
} else if (b <= 5e-36) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 1.8e+33) {
tmp = t_0;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = (-0.5 * (b - math.sqrt((a * (c * -4.0))))) / a tmp = 0 if b <= -8.8e-103: tmp = (c / b) - (b / a) elif b <= 5.5e-100: tmp = t_0 elif b <= 5e-36: tmp = 1.0 / ((a / b) - (b / c)) elif b <= 1.8e+33: tmp = t_0 else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(Float64(-0.5 * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))) / a) tmp = 0.0 if (b <= -8.8e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.5e-100) tmp = t_0; elseif (b <= 5e-36) tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); elseif (b <= 1.8e+33) tmp = t_0; else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (-0.5 * (b - sqrt((a * (c * -4.0))))) / a; tmp = 0.0; if (b <= -8.8e-103) tmp = (c / b) - (b / a); elseif (b <= 5.5e-100) tmp = t_0; elseif (b <= 5e-36) tmp = 1.0 / ((a / b) - (b / c)); elseif (b <= 1.8e+33) tmp = t_0; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-0.5 * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[b, -8.8e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.5e-100], t$95$0, If[LessEqual[b, 5e-36], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+33], t$95$0, N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.5 \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)}{a}\\
\mathbf{if}\;b \leq -8.8 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-36}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -8.7999999999999997e-103Initial program 83.7%
neg-sub083.7%
associate-+l-83.7%
sub0-neg83.7%
neg-mul-183.7%
associate-*l/83.5%
*-commutative83.5%
associate-/r*83.5%
/-rgt-identity83.5%
metadata-eval83.5%
Simplified83.5%
Taylor expanded in b around -inf 86.5%
mul-1-neg86.5%
unsub-neg86.5%
Simplified86.5%
if -8.7999999999999997e-103 < b < 5.50000000000000011e-100 or 5.00000000000000004e-36 < b < 1.8000000000000001e33Initial program 75.6%
neg-sub075.6%
associate-+l-75.6%
sub0-neg75.6%
neg-mul-175.6%
associate-*l/75.5%
*-commutative75.5%
associate-/r*75.5%
/-rgt-identity75.5%
metadata-eval75.5%
Simplified75.5%
Taylor expanded in a around inf 74.3%
*-commutative74.3%
*-commutative74.3%
associate-*r*74.3%
Simplified74.3%
associate-*r/74.4%
Applied egg-rr74.4%
if 5.50000000000000011e-100 < b < 5.00000000000000004e-36Initial program 37.5%
neg-sub037.5%
associate-+l-37.5%
sub0-neg37.5%
neg-mul-137.5%
associate-*l/37.3%
*-commutative37.3%
associate-/r*37.3%
/-rgt-identity37.3%
metadata-eval37.3%
Simplified37.3%
associate-*r/37.5%
clear-num37.3%
Applied egg-rr37.3%
Taylor expanded in a around 0 71.2%
mul-1-neg71.2%
unsub-neg71.2%
Simplified71.2%
if 1.8000000000000001e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
associate-*l/16.7%
*-commutative16.7%
associate-/r*16.7%
/-rgt-identity16.7%
metadata-eval16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
mul-1-neg94.1%
distribute-neg-frac94.1%
Simplified94.1%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e+83)
(- (/ c b) (/ b a))
(if (<= b 1.8e+33)
(* (- b (sqrt (- (* b b) (* a (* c 4.0))))) (/ -0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+83) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e+33) {
tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
} else {
tmp = -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) :: tmp
if (b <= (-6.5d+83)) then
tmp = (c / b) - (b / a)
else if (b <= 1.8d+33) then
tmp = (b - sqrt(((b * b) - (a * (c * 4.0d0))))) * ((-0.5d0) / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e+83) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e+33) {
tmp = (b - Math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e+83: tmp = (c / b) - (b / a) elif b <= 1.8e+33: tmp = (b - math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e+83) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.8e+33) tmp = Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) * Float64(-0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e+83) tmp = (c / b) - (b / a); elseif (b <= 1.8e+33) tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e+83], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+33], N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{+83}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+33}:\\
\;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -6.5000000000000003e83Initial program 75.9%
neg-sub075.9%
associate-+l-75.9%
sub0-neg75.9%
neg-mul-175.9%
associate-*l/75.8%
*-commutative75.8%
associate-/r*75.8%
/-rgt-identity75.8%
metadata-eval75.8%
Simplified75.8%
Taylor expanded in b around -inf 93.8%
mul-1-neg93.8%
unsub-neg93.8%
Simplified93.8%
if -6.5000000000000003e83 < b < 1.8000000000000001e33Initial program 78.0%
neg-sub078.0%
associate-+l-78.0%
sub0-neg78.0%
neg-mul-178.0%
associate-*l/77.8%
*-commutative77.8%
associate-/r*77.8%
/-rgt-identity77.8%
metadata-eval77.8%
Simplified77.8%
fma-udef77.8%
*-commutative77.8%
associate-*r*77.8%
metadata-eval77.8%
distribute-rgt-neg-in77.8%
*-commutative77.8%
distribute-lft-neg-in77.8%
+-commutative77.8%
sub-neg77.8%
*-commutative77.8%
associate-*l*77.8%
Applied egg-rr77.8%
*-commutative77.8%
Simplified77.8%
if 1.8000000000000001e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
associate-*l/16.7%
*-commutative16.7%
associate-/r*16.7%
/-rgt-identity16.7%
metadata-eval16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
mul-1-neg94.1%
distribute-neg-frac94.1%
Simplified94.1%
Final simplification86.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+119)
(- (/ c b) (/ b a))
(if (<= b 1.8e+33)
(/ (* -0.5 (- b (sqrt (- (* b b) (* a (* c 4.0)))))) a)
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e+33) {
tmp = (-0.5 * (b - sqrt(((b * b) - (a * (c * 4.0)))))) / a;
} else {
tmp = -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) :: tmp
if (b <= (-2d+119)) then
tmp = (c / b) - (b / a)
else if (b <= 1.8d+33) then
tmp = ((-0.5d0) * (b - sqrt(((b * b) - (a * (c * 4.0d0)))))) / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e+119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e+33) {
tmp = (-0.5 * (b - Math.sqrt(((b * b) - (a * (c * 4.0)))))) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e+119: tmp = (c / b) - (b / a) elif b <= 1.8e+33: tmp = (-0.5 * (b - math.sqrt(((b * b) - (a * (c * 4.0)))))) / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e+119) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.8e+33) tmp = Float64(Float64(-0.5 * Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0)))))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e+119) tmp = (c / b) - (b / a); elseif (b <= 1.8e+33) tmp = (-0.5 * (b - sqrt(((b * b) - (a * (c * 4.0)))))) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e+119], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+33], N[(N[(-0.5 * N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+119}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+33}:\\
\;\;\;\;\frac{-0.5 \cdot \left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.99999999999999989e119Initial program 71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
associate-*l/71.1%
*-commutative71.1%
associate-/r*71.1%
/-rgt-identity71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in b around -inf 92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -1.99999999999999989e119 < b < 1.8000000000000001e33Initial program 79.7%
neg-sub079.7%
associate-+l-79.7%
sub0-neg79.7%
neg-mul-179.7%
associate-*l/79.4%
*-commutative79.4%
associate-/r*79.4%
/-rgt-identity79.4%
metadata-eval79.4%
Simplified79.4%
fma-udef79.4%
*-commutative79.4%
associate-*r*79.4%
metadata-eval79.4%
distribute-rgt-neg-in79.4%
*-commutative79.4%
distribute-lft-neg-in79.4%
+-commutative79.4%
sub-neg79.4%
*-commutative79.4%
associate-*l*79.4%
Applied egg-rr79.4%
*-commutative79.4%
Simplified79.4%
associate-*r/79.7%
Applied egg-rr79.7%
if 1.8000000000000001e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
associate-*l/16.7%
*-commutative16.7%
associate-/r*16.7%
/-rgt-identity16.7%
metadata-eval16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
mul-1-neg94.1%
distribute-neg-frac94.1%
Simplified94.1%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -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) :: tmp
if (b <= (-2d-310)) then
tmp = (c / b) - (b / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 82.4%
neg-sub082.4%
associate-+l-82.4%
sub0-neg82.4%
neg-mul-182.4%
associate-*l/82.2%
*-commutative82.2%
associate-/r*82.2%
/-rgt-identity82.2%
metadata-eval82.2%
Simplified82.2%
Taylor expanded in b around -inf 67.0%
mul-1-neg67.0%
unsub-neg67.0%
Simplified67.0%
if -1.999999999999994e-310 < b Initial program 38.5%
neg-sub038.5%
associate-+l-38.5%
sub0-neg38.5%
neg-mul-138.5%
associate-*l/38.4%
*-commutative38.4%
associate-/r*38.4%
/-rgt-identity38.4%
metadata-eval38.4%
Simplified38.5%
Taylor expanded in b around inf 66.2%
mul-1-neg66.2%
distribute-neg-frac66.2%
Simplified66.2%
Final simplification66.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- b) a) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = 0.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 <= (-2d-310)) then
tmp = -b / a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -b / a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-b) / a); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -b / a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-b) / a), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 82.4%
neg-sub082.4%
associate-+l-82.4%
sub0-neg82.4%
neg-mul-182.4%
associate-*l/82.2%
*-commutative82.2%
associate-/r*82.2%
/-rgt-identity82.2%
metadata-eval82.2%
Simplified82.2%
Taylor expanded in b around -inf 66.7%
associate-*r/66.7%
mul-1-neg66.7%
Simplified66.7%
if -1.999999999999994e-310 < b Initial program 38.5%
neg-sub038.5%
associate-+l-38.5%
sub0-neg38.5%
neg-mul-138.5%
associate-*l/38.4%
*-commutative38.4%
associate-/r*38.4%
/-rgt-identity38.4%
metadata-eval38.4%
Simplified38.5%
Taylor expanded in a around 0 9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in b around 0 22.5%
Final simplification43.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = -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) :: tmp
if (b <= (-2d-310)) then
tmp = -b / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 82.4%
neg-sub082.4%
associate-+l-82.4%
sub0-neg82.4%
neg-mul-182.4%
associate-*l/82.2%
*-commutative82.2%
associate-/r*82.2%
/-rgt-identity82.2%
metadata-eval82.2%
Simplified82.2%
Taylor expanded in b around -inf 66.7%
associate-*r/66.7%
mul-1-neg66.7%
Simplified66.7%
if -1.999999999999994e-310 < b Initial program 38.5%
neg-sub038.5%
associate-+l-38.5%
sub0-neg38.5%
neg-mul-138.5%
associate-*l/38.4%
*-commutative38.4%
associate-/r*38.4%
/-rgt-identity38.4%
metadata-eval38.4%
Simplified38.5%
Taylor expanded in b around inf 66.2%
mul-1-neg66.2%
distribute-neg-frac66.2%
Simplified66.2%
Final simplification66.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 59.1%
neg-sub059.1%
associate-+l-59.1%
sub0-neg59.1%
neg-mul-159.1%
associate-*l/58.9%
*-commutative58.9%
associate-/r*58.9%
/-rgt-identity58.9%
metadata-eval58.9%
Simplified59.0%
Taylor expanded in a around 0 31.8%
unpow231.8%
Simplified31.8%
Taylor expanded in b around 0 13.2%
Final simplification13.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
(if (< b 0.0)
(/ (+ (- b) t_0) (* 2.0 a))
(/ c (* a (/ (- (- b) t_0) (* 2.0 a)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b < 0.0) {
tmp = (-b + t_0) / (2.0 * a);
} else {
tmp = c / (a * ((-b - t_0) / (2.0 * a)));
}
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) - ((4.0d0 * a) * c)))
if (b < 0.0d0) then
tmp = (-b + t_0) / (2.0d0 * a)
else
tmp = c / (a * ((-b - t_0) / (2.0d0 * a)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b < 0.0) {
tmp = (-b + t_0) / (2.0 * a);
} else {
tmp = c / (a * ((-b - t_0) / (2.0 * a)));
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b < 0.0: tmp = (-b + t_0) / (2.0 * a) else: tmp = c / (a * ((-b - t_0) / (2.0 * a))) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b < 0.0) tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); else tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b < 0.0) tmp = (-b + t_0) / (2.0 * a); else tmp = c / (a * ((-b - t_0) / (2.0 * a))); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(c / N[(a * N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{\left(-b\right) + t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - t_0}{2 \cdot a}}\\
\end{array}
\end{array}
herbie shell --seed 2023258
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))