
(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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma a (* c -4.0) (pow b 2.0))) (t_1 (/ c (- b))))
(if (<= b -1550000000000.0)
t_1
(if (<= b -1.35e-45)
(/ (- (- b) (sqrt (pow (cbrt t_0) 3.0))) (* a 2.0))
(if (<= b -1.25e-115)
t_1
(if (<= b 8.6e+32)
(fma (/ -0.5 a) b (* (/ -0.5 a) (sqrt t_0)))
(- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = fma(a, (c * -4.0), pow(b, 2.0));
double t_1 = c / -b;
double tmp;
if (b <= -1550000000000.0) {
tmp = t_1;
} else if (b <= -1.35e-45) {
tmp = (-b - sqrt(pow(cbrt(t_0), 3.0))) / (a * 2.0);
} else if (b <= -1.25e-115) {
tmp = t_1;
} else if (b <= 8.6e+32) {
tmp = fma((-0.5 / a), b, ((-0.5 / a) * sqrt(t_0)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
function code(a, b, c) t_0 = fma(a, Float64(c * -4.0), (b ^ 2.0)) t_1 = Float64(c / Float64(-b)) tmp = 0.0 if (b <= -1550000000000.0) tmp = t_1; elseif (b <= -1.35e-45) tmp = Float64(Float64(Float64(-b) - sqrt((cbrt(t_0) ^ 3.0))) / Float64(a * 2.0)); elseif (b <= -1.25e-115) tmp = t_1; elseif (b <= 8.6e+32) tmp = fma(Float64(-0.5 / a), b, Float64(Float64(-0.5 / a) * sqrt(t_0))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c / (-b)), $MachinePrecision]}, If[LessEqual[b, -1550000000000.0], t$95$1, If[LessEqual[b, -1.35e-45], N[(N[((-b) - N[Sqrt[N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -1.25e-115], t$95$1, If[LessEqual[b, 8.6e+32], N[(N[(-0.5 / a), $MachinePrecision] * b + N[(N[(-0.5 / a), $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)\\
t_1 := \frac{c}{-b}\\
\mathbf{if}\;b \leq -1550000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -1.35 \cdot 10^{-45}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{{\left(\sqrt[3]{t\_0}\right)}^{3}}}{a \cdot 2}\\
\mathbf{elif}\;b \leq -1.25 \cdot 10^{-115}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.5}{a}, b, \frac{-0.5}{a} \cdot \sqrt{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.55e12 or -1.34999999999999992e-45 < b < -1.2500000000000001e-115Initial program 11.7%
div-sub10.4%
sub-neg10.4%
neg-mul-110.4%
*-commutative10.4%
associate-/l*10.2%
distribute-neg-frac10.2%
neg-mul-110.2%
*-commutative10.2%
associate-/l*10.4%
distribute-rgt-out11.7%
associate-/r*11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
Simplified11.8%
Taylor expanded in b around -inf 89.9%
mul-1-neg89.9%
distribute-neg-frac289.9%
Simplified89.9%
if -1.55e12 < b < -1.34999999999999992e-45Initial program 75.0%
*-commutative75.0%
*-commutative75.0%
sqr-neg75.0%
*-commutative75.0%
sqr-neg75.0%
*-commutative75.0%
associate-*r*75.0%
Simplified75.0%
sub-neg75.0%
+-commutative75.0%
*-commutative75.0%
distribute-rgt-neg-in75.0%
distribute-lft-neg-in75.0%
metadata-eval75.0%
*-commutative75.0%
fma-undefine75.0%
add-cube-cbrt75.1%
pow375.3%
pow275.3%
Applied egg-rr75.3%
if -1.2500000000000001e-115 < b < 8.5999999999999994e32Initial program 84.7%
div-sub84.8%
sub-neg84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.8%
distribute-neg-frac84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.7%
distribute-rgt-out84.7%
associate-/r*84.7%
metadata-eval84.7%
sub-neg84.7%
+-commutative84.7%
Simplified84.7%
distribute-lft-in84.7%
fma-define84.8%
*-commutative84.8%
pow284.8%
Applied egg-rr84.8%
if 8.5999999999999994e32 < b Initial program 62.1%
div-sub62.1%
sub-neg62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.1%
distribute-neg-frac62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.0%
distribute-rgt-out62.0%
associate-/r*62.0%
metadata-eval62.0%
sub-neg62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in a around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma a (* c -4.0) (pow b 2.0)))) (t_1 (/ c (- b))))
(if (<= b -10800000000.0)
t_1
(if (<= b -4.2e-50)
(/ 1.0 (* a (/ -2.0 (+ b t_0))))
(if (<= b -8e-116)
t_1
(if (<= b 8.6e+32)
(fma (/ -0.5 a) b (* (/ -0.5 a) t_0))
(- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma(a, (c * -4.0), pow(b, 2.0)));
double t_1 = c / -b;
double tmp;
if (b <= -10800000000.0) {
tmp = t_1;
} else if (b <= -4.2e-50) {
tmp = 1.0 / (a * (-2.0 / (b + t_0)));
} else if (b <= -8e-116) {
tmp = t_1;
} else if (b <= 8.6e+32) {
tmp = fma((-0.5 / a), b, ((-0.5 / a) * t_0));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
function code(a, b, c) t_0 = sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) t_1 = Float64(c / Float64(-b)) tmp = 0.0 if (b <= -10800000000.0) tmp = t_1; elseif (b <= -4.2e-50) tmp = Float64(1.0 / Float64(a * Float64(-2.0 / Float64(b + t_0)))); elseif (b <= -8e-116) tmp = t_1; elseif (b <= 8.6e+32) tmp = fma(Float64(-0.5 / a), b, Float64(Float64(-0.5 / a) * t_0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c / (-b)), $MachinePrecision]}, If[LessEqual[b, -10800000000.0], t$95$1, If[LessEqual[b, -4.2e-50], N[(1.0 / N[(a * N[(-2.0 / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -8e-116], t$95$1, If[LessEqual[b, 8.6e+32], N[(N[(-0.5 / a), $MachinePrecision] * b + N[(N[(-0.5 / a), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}\\
t_1 := \frac{c}{-b}\\
\mathbf{if}\;b \leq -10800000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -4.2 \cdot 10^{-50}:\\
\;\;\;\;\frac{1}{a \cdot \frac{-2}{b + t\_0}}\\
\mathbf{elif}\;b \leq -8 \cdot 10^{-116}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.5}{a}, b, \frac{-0.5}{a} \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.08e10 or -4.2000000000000002e-50 < b < -8e-116Initial program 11.7%
div-sub10.4%
sub-neg10.4%
neg-mul-110.4%
*-commutative10.4%
associate-/l*10.2%
distribute-neg-frac10.2%
neg-mul-110.2%
*-commutative10.2%
associate-/l*10.4%
distribute-rgt-out11.7%
associate-/r*11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
Simplified11.8%
Taylor expanded in b around -inf 89.9%
mul-1-neg89.9%
distribute-neg-frac289.9%
Simplified89.9%
if -1.08e10 < b < -4.2000000000000002e-50Initial program 75.0%
div-sub75.2%
sub-neg75.2%
neg-mul-175.2%
*-commutative75.2%
associate-/l*75.0%
distribute-neg-frac75.0%
neg-mul-175.0%
*-commutative75.0%
associate-/l*74.8%
distribute-rgt-out75.0%
associate-/r*75.0%
metadata-eval75.0%
sub-neg75.0%
+-commutative75.0%
Simplified75.0%
associate-*l/75.0%
clear-num75.2%
*-commutative75.2%
pow275.2%
Applied egg-rr75.2%
div-inv75.2%
*-commutative75.2%
Applied egg-rr75.2%
associate-/r*75.2%
metadata-eval75.2%
Simplified75.2%
if -8e-116 < b < 8.5999999999999994e32Initial program 84.7%
div-sub84.8%
sub-neg84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.8%
distribute-neg-frac84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.7%
distribute-rgt-out84.7%
associate-/r*84.7%
metadata-eval84.7%
sub-neg84.7%
+-commutative84.7%
Simplified84.7%
distribute-lft-in84.7%
fma-define84.8%
*-commutative84.8%
pow284.8%
Applied egg-rr84.8%
if 8.5999999999999994e32 < b Initial program 62.1%
div-sub62.1%
sub-neg62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.1%
distribute-neg-frac62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.0%
distribute-rgt-out62.0%
associate-/r*62.0%
metadata-eval62.0%
sub-neg62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in a around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma a (* c -4.0) (pow b 2.0)))) (t_1 (/ c (- b))))
(if (<= b -2000000000.0)
t_1
(if (<= b -3.8e-52)
(/ 1.0 (* a (/ -2.0 (+ b t_0))))
(if (<= b -1.7e-115)
t_1
(if (<= b 8.6e+32)
(- (* b (/ -0.5 a)) (* t_0 (/ 0.5 a)))
(- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma(a, (c * -4.0), pow(b, 2.0)));
double t_1 = c / -b;
double tmp;
if (b <= -2000000000.0) {
tmp = t_1;
} else if (b <= -3.8e-52) {
tmp = 1.0 / (a * (-2.0 / (b + t_0)));
} else if (b <= -1.7e-115) {
tmp = t_1;
} else if (b <= 8.6e+32) {
tmp = (b * (-0.5 / a)) - (t_0 * (0.5 / a));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
function code(a, b, c) t_0 = sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) t_1 = Float64(c / Float64(-b)) tmp = 0.0 if (b <= -2000000000.0) tmp = t_1; elseif (b <= -3.8e-52) tmp = Float64(1.0 / Float64(a * Float64(-2.0 / Float64(b + t_0)))); elseif (b <= -1.7e-115) tmp = t_1; elseif (b <= 8.6e+32) tmp = Float64(Float64(b * Float64(-0.5 / a)) - Float64(t_0 * Float64(0.5 / a))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c / (-b)), $MachinePrecision]}, If[LessEqual[b, -2000000000.0], t$95$1, If[LessEqual[b, -3.8e-52], N[(1.0 / N[(a * N[(-2.0 / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -1.7e-115], t$95$1, If[LessEqual[b, 8.6e+32], N[(N[(b * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}\\
t_1 := \frac{c}{-b}\\
\mathbf{if}\;b \leq -2000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -3.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{1}{a \cdot \frac{-2}{b + t\_0}}\\
\mathbf{elif}\;b \leq -1.7 \cdot 10^{-115}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+32}:\\
\;\;\;\;b \cdot \frac{-0.5}{a} - t\_0 \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -2e9 or -3.8000000000000003e-52 < b < -1.6999999999999999e-115Initial program 11.7%
div-sub10.4%
sub-neg10.4%
neg-mul-110.4%
*-commutative10.4%
associate-/l*10.2%
distribute-neg-frac10.2%
neg-mul-110.2%
*-commutative10.2%
associate-/l*10.4%
distribute-rgt-out11.7%
associate-/r*11.7%
metadata-eval11.7%
sub-neg11.7%
+-commutative11.7%
Simplified11.8%
Taylor expanded in b around -inf 89.9%
mul-1-neg89.9%
distribute-neg-frac289.9%
Simplified89.9%
if -2e9 < b < -3.8000000000000003e-52Initial program 75.0%
div-sub75.2%
sub-neg75.2%
neg-mul-175.2%
*-commutative75.2%
associate-/l*75.0%
distribute-neg-frac75.0%
neg-mul-175.0%
*-commutative75.0%
associate-/l*74.8%
distribute-rgt-out75.0%
associate-/r*75.0%
metadata-eval75.0%
sub-neg75.0%
+-commutative75.0%
Simplified75.0%
associate-*l/75.0%
clear-num75.2%
*-commutative75.2%
pow275.2%
Applied egg-rr75.2%
div-inv75.2%
*-commutative75.2%
Applied egg-rr75.2%
associate-/r*75.2%
metadata-eval75.2%
Simplified75.2%
if -1.6999999999999999e-115 < b < 8.5999999999999994e32Initial program 84.7%
div-sub84.8%
sub-neg84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.8%
distribute-neg-frac84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.7%
distribute-rgt-out84.7%
associate-/r*84.7%
metadata-eval84.7%
sub-neg84.7%
+-commutative84.7%
Simplified84.7%
Applied egg-rr84.7%
if 8.5999999999999994e32 < b Initial program 62.1%
div-sub62.1%
sub-neg62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.1%
distribute-neg-frac62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.0%
distribute-rgt-out62.0%
associate-/r*62.0%
metadata-eval62.0%
sub-neg62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in a around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ c (- b))))
(if (<= b -2000000000.0)
t_0
(if (<= b -8.5e-39)
(/ 1.0 (* a (/ -2.0 (+ b (sqrt (fma a (* c -4.0) (pow b 2.0)))))))
(if (<= b -3.4e-100)
t_0
(if (<= b 8.6e+32)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = c / -b;
double tmp;
if (b <= -2000000000.0) {
tmp = t_0;
} else if (b <= -8.5e-39) {
tmp = 1.0 / (a * (-2.0 / (b + sqrt(fma(a, (c * -4.0), pow(b, 2.0))))));
} else if (b <= -3.4e-100) {
tmp = t_0;
} else if (b <= 8.6e+32) {
tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
function code(a, b, c) t_0 = Float64(c / Float64(-b)) tmp = 0.0 if (b <= -2000000000.0) tmp = t_0; elseif (b <= -8.5e-39) tmp = Float64(1.0 / Float64(a * Float64(-2.0 / Float64(b + sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))))))); elseif (b <= -3.4e-100) tmp = t_0; elseif (b <= 8.6e+32) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / Float64(a * 2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(c / (-b)), $MachinePrecision]}, If[LessEqual[b, -2000000000.0], t$95$0, If[LessEqual[b, -8.5e-39], N[(1.0 / N[(a * N[(-2.0 / N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -3.4e-100], t$95$0, If[LessEqual[b, 8.6e+32], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{-b}\\
\mathbf{if}\;b \leq -2000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq -8.5 \cdot 10^{-39}:\\
\;\;\;\;\frac{1}{a \cdot \frac{-2}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}}}\\
\mathbf{elif}\;b \leq -3.4 \cdot 10^{-100}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+32}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -2e9 or -8.5000000000000005e-39 < b < -3.39999999999999976e-100Initial program 10.9%
div-sub9.6%
sub-neg9.6%
neg-mul-19.6%
*-commutative9.6%
associate-/l*9.4%
distribute-neg-frac9.4%
neg-mul-19.4%
*-commutative9.4%
associate-/l*9.6%
distribute-rgt-out10.9%
associate-/r*10.9%
metadata-eval10.9%
sub-neg10.9%
+-commutative10.9%
Simplified11.0%
Taylor expanded in b around -inf 90.6%
mul-1-neg90.6%
distribute-neg-frac290.6%
Simplified90.6%
if -2e9 < b < -8.5000000000000005e-39Initial program 75.0%
div-sub75.2%
sub-neg75.2%
neg-mul-175.2%
*-commutative75.2%
associate-/l*75.0%
distribute-neg-frac75.0%
neg-mul-175.0%
*-commutative75.0%
associate-/l*74.8%
distribute-rgt-out75.0%
associate-/r*75.0%
metadata-eval75.0%
sub-neg75.0%
+-commutative75.0%
Simplified75.0%
associate-*l/75.0%
clear-num75.2%
*-commutative75.2%
pow275.2%
Applied egg-rr75.2%
div-inv75.2%
*-commutative75.2%
Applied egg-rr75.2%
associate-/r*75.2%
metadata-eval75.2%
Simplified75.2%
if -3.39999999999999976e-100 < b < 8.5999999999999994e32Initial program 84.0%
if 8.5999999999999994e32 < b Initial program 62.1%
div-sub62.1%
sub-neg62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.1%
distribute-neg-frac62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.0%
distribute-rgt-out62.0%
associate-/r*62.0%
metadata-eval62.0%
sub-neg62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in a around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ c (- b)))
(t_1 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))))
(if (<= b -2000000000.0)
t_0
(if (<= b -1.4e-52)
t_1
(if (<= b -5.2e-101)
t_0
(if (<= b 8.6e+32) t_1 (- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = c / -b;
double t_1 = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
double tmp;
if (b <= -2000000000.0) {
tmp = t_0;
} else if (b <= -1.4e-52) {
tmp = t_1;
} else if (b <= -5.2e-101) {
tmp = t_0;
} else if (b <= 8.6e+32) {
tmp = t_1;
} else {
tmp = (c / b) - (b / 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) :: t_1
real(8) :: tmp
t_0 = c / -b
t_1 = (-b - sqrt(((b * b) - (4.0d0 * (c * a))))) / (a * 2.0d0)
if (b <= (-2000000000.0d0)) then
tmp = t_0
else if (b <= (-1.4d-52)) then
tmp = t_1
else if (b <= (-5.2d-101)) then
tmp = t_0
else if (b <= 8.6d+32) then
tmp = t_1
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = c / -b;
double t_1 = (-b - Math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
double tmp;
if (b <= -2000000000.0) {
tmp = t_0;
} else if (b <= -1.4e-52) {
tmp = t_1;
} else if (b <= -5.2e-101) {
tmp = t_0;
} else if (b <= 8.6e+32) {
tmp = t_1;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): t_0 = c / -b t_1 = (-b - math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0) tmp = 0 if b <= -2000000000.0: tmp = t_0 elif b <= -1.4e-52: tmp = t_1 elif b <= -5.2e-101: tmp = t_0 elif b <= 8.6e+32: tmp = t_1 else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) t_0 = Float64(c / Float64(-b)) t_1 = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / Float64(a * 2.0)) tmp = 0.0 if (b <= -2000000000.0) tmp = t_0; elseif (b <= -1.4e-52) tmp = t_1; elseif (b <= -5.2e-101) tmp = t_0; elseif (b <= 8.6e+32) tmp = t_1; else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = c / -b; t_1 = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0); tmp = 0.0; if (b <= -2000000000.0) tmp = t_0; elseif (b <= -1.4e-52) tmp = t_1; elseif (b <= -5.2e-101) tmp = t_0; elseif (b <= 8.6e+32) tmp = t_1; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(c / (-b)), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2000000000.0], t$95$0, If[LessEqual[b, -1.4e-52], t$95$1, If[LessEqual[b, -5.2e-101], t$95$0, If[LessEqual[b, 8.6e+32], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{-b}\\
t_1 := \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{if}\;b \leq -2000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq -1.4 \cdot 10^{-52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -5.2 \cdot 10^{-101}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+32}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -2e9 or -1.39999999999999997e-52 < b < -5.2000000000000002e-101Initial program 10.9%
div-sub9.6%
sub-neg9.6%
neg-mul-19.6%
*-commutative9.6%
associate-/l*9.4%
distribute-neg-frac9.4%
neg-mul-19.4%
*-commutative9.4%
associate-/l*9.6%
distribute-rgt-out10.9%
associate-/r*10.9%
metadata-eval10.9%
sub-neg10.9%
+-commutative10.9%
Simplified11.0%
Taylor expanded in b around -inf 90.6%
mul-1-neg90.6%
distribute-neg-frac290.6%
Simplified90.6%
if -2e9 < b < -1.39999999999999997e-52 or -5.2000000000000002e-101 < b < 8.5999999999999994e32Initial program 83.2%
if 8.5999999999999994e32 < b Initial program 62.1%
div-sub62.1%
sub-neg62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.1%
distribute-neg-frac62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.0%
distribute-rgt-out62.0%
associate-/r*62.0%
metadata-eval62.0%
sub-neg62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in a around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-124)
(/ c (- b))
(if (<= b 4.1e-98)
(/ (- (- b) (sqrt (* c (* a -4.0)))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-124) {
tmp = c / -b;
} else if (b <= 4.1e-98) {
tmp = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp = (c / b) - (b / 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) :: tmp
if (b <= (-5d-124)) then
tmp = c / -b
else if (b <= 4.1d-98) then
tmp = (-b - sqrt((c * (a * (-4.0d0))))) / (a * 2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-124) {
tmp = c / -b;
} else if (b <= 4.1e-98) {
tmp = (-b - Math.sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-124: tmp = c / -b elif b <= 4.1e-98: tmp = (-b - math.sqrt((c * (a * -4.0)))) / (a * 2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-124) tmp = Float64(c / Float64(-b)); elseif (b <= 4.1e-98) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(c * Float64(a * -4.0)))) / Float64(a * 2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-124) tmp = c / -b; elseif (b <= 4.1e-98) tmp = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-124], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 4.1e-98], N[(N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-124}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-98}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.0000000000000003e-124Initial program 17.0%
div-sub15.8%
sub-neg15.8%
neg-mul-115.8%
*-commutative15.8%
associate-/l*15.6%
distribute-neg-frac15.6%
neg-mul-115.6%
*-commutative15.6%
associate-/l*15.8%
distribute-rgt-out17.0%
associate-/r*17.0%
metadata-eval17.0%
sub-neg17.0%
+-commutative17.0%
Simplified17.0%
Taylor expanded in b around -inf 84.2%
mul-1-neg84.2%
distribute-neg-frac284.2%
Simplified84.2%
if -5.0000000000000003e-124 < b < 4.0999999999999998e-98Initial program 85.3%
*-commutative85.3%
*-commutative85.3%
sqr-neg85.3%
*-commutative85.3%
sqr-neg85.3%
*-commutative85.3%
associate-*r*85.3%
Simplified85.3%
Taylor expanded in b around 0 77.6%
associate-*r*77.6%
Simplified77.6%
if 4.0999999999999998e-98 < b Initial program 66.5%
div-sub66.5%
sub-neg66.5%
neg-mul-166.5%
*-commutative66.5%
associate-/l*66.4%
distribute-neg-frac66.4%
neg-mul-166.4%
*-commutative66.4%
associate-/l*66.4%
distribute-rgt-out66.4%
associate-/r*66.4%
metadata-eval66.4%
sub-neg66.4%
+-commutative66.4%
Simplified66.4%
Taylor expanded in a around 0 90.6%
+-commutative90.6%
mul-1-neg90.6%
unsub-neg90.6%
Simplified90.6%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-124)
(/ c (- b))
(if (<= b 6.2e-109)
(* (/ -0.5 a) (sqrt (* a (* c -4.0))))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-124) {
tmp = c / -b;
} else if (b <= 6.2e-109) {
tmp = (-0.5 / a) * sqrt((a * (c * -4.0)));
} else {
tmp = (c / b) - (b / 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) :: tmp
if (b <= (-5d-124)) then
tmp = c / -b
else if (b <= 6.2d-109) then
tmp = ((-0.5d0) / a) * sqrt((a * (c * (-4.0d0))))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-124) {
tmp = c / -b;
} else if (b <= 6.2e-109) {
tmp = (-0.5 / a) * Math.sqrt((a * (c * -4.0)));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-124: tmp = c / -b elif b <= 6.2e-109: tmp = (-0.5 / a) * math.sqrt((a * (c * -4.0))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-124) tmp = Float64(c / Float64(-b)); elseif (b <= 6.2e-109) tmp = Float64(Float64(-0.5 / a) * sqrt(Float64(a * Float64(c * -4.0)))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-124) tmp = c / -b; elseif (b <= 6.2e-109) tmp = (-0.5 / a) * sqrt((a * (c * -4.0))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-124], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 6.2e-109], N[(N[(-0.5 / a), $MachinePrecision] * N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-124}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-109}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \sqrt{a \cdot \left(c \cdot -4\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.0000000000000003e-124Initial program 17.0%
div-sub15.8%
sub-neg15.8%
neg-mul-115.8%
*-commutative15.8%
associate-/l*15.6%
distribute-neg-frac15.6%
neg-mul-115.6%
*-commutative15.6%
associate-/l*15.8%
distribute-rgt-out17.0%
associate-/r*17.0%
metadata-eval17.0%
sub-neg17.0%
+-commutative17.0%
Simplified17.0%
Taylor expanded in b around -inf 84.2%
mul-1-neg84.2%
distribute-neg-frac284.2%
Simplified84.2%
if -5.0000000000000003e-124 < b < 6.1999999999999999e-109Initial program 84.8%
*-commutative84.8%
*-commutative84.8%
sqr-neg84.8%
*-commutative84.8%
sqr-neg84.8%
*-commutative84.8%
associate-*r*84.8%
Simplified84.8%
Taylor expanded in b around 0 78.2%
associate-*r*78.2%
Simplified78.2%
Applied egg-rr76.4%
+-lft-identity76.4%
*-commutative76.4%
Simplified76.4%
if 6.1999999999999999e-109 < b Initial program 67.3%
div-sub67.3%
sub-neg67.3%
neg-mul-167.3%
*-commutative67.3%
associate-/l*67.3%
distribute-neg-frac67.3%
neg-mul-167.3%
*-commutative67.3%
associate-/l*67.2%
distribute-rgt-out67.2%
associate-/r*67.2%
metadata-eval67.2%
sub-neg67.2%
+-commutative67.2%
Simplified67.2%
Taylor expanded in a around 0 89.7%
+-commutative89.7%
mul-1-neg89.7%
unsub-neg89.7%
Simplified89.7%
Final simplification84.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-124)
(/ c (- b))
(if (<= b 4e-109)
(/ (sqrt (* a (* c -4.0))) (* a -2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-124) {
tmp = c / -b;
} else if (b <= 4e-109) {
tmp = sqrt((a * (c * -4.0))) / (a * -2.0);
} else {
tmp = (c / b) - (b / 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) :: tmp
if (b <= (-5d-124)) then
tmp = c / -b
else if (b <= 4d-109) then
tmp = sqrt((a * (c * (-4.0d0)))) / (a * (-2.0d0))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-124) {
tmp = c / -b;
} else if (b <= 4e-109) {
tmp = Math.sqrt((a * (c * -4.0))) / (a * -2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-124: tmp = c / -b elif b <= 4e-109: tmp = math.sqrt((a * (c * -4.0))) / (a * -2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-124) tmp = Float64(c / Float64(-b)); elseif (b <= 4e-109) tmp = Float64(sqrt(Float64(a * Float64(c * -4.0))) / Float64(a * -2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-124) tmp = c / -b; elseif (b <= 4e-109) tmp = sqrt((a * (c * -4.0))) / (a * -2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-124], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 4e-109], N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-124}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-109}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.0000000000000003e-124Initial program 17.0%
div-sub15.8%
sub-neg15.8%
neg-mul-115.8%
*-commutative15.8%
associate-/l*15.6%
distribute-neg-frac15.6%
neg-mul-115.6%
*-commutative15.6%
associate-/l*15.8%
distribute-rgt-out17.0%
associate-/r*17.0%
metadata-eval17.0%
sub-neg17.0%
+-commutative17.0%
Simplified17.0%
Taylor expanded in b around -inf 84.2%
mul-1-neg84.2%
distribute-neg-frac284.2%
Simplified84.2%
if -5.0000000000000003e-124 < b < 4e-109Initial program 84.8%
div-sub84.8%
sub-neg84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.8%
distribute-neg-frac84.8%
neg-mul-184.8%
*-commutative84.8%
associate-/l*84.8%
distribute-rgt-out84.8%
associate-/r*84.8%
metadata-eval84.8%
sub-neg84.8%
+-commutative84.8%
Simplified84.8%
associate-*l/84.8%
clear-num84.6%
*-commutative84.6%
pow284.6%
Applied egg-rr84.6%
clear-num84.8%
pow1/284.8%
metadata-eval84.8%
pow-pow61.6%
pow1/365.5%
associate-*r/65.6%
*-commutative65.6%
distribute-lft-in65.6%
fma-define65.6%
pow1/361.6%
pow-pow84.8%
metadata-eval84.8%
pow1/284.8%
Applied egg-rr84.8%
Applied egg-rr76.4%
fma-undefine76.4%
+-rgt-identity76.4%
Simplified76.4%
if 4e-109 < b Initial program 67.3%
div-sub67.3%
sub-neg67.3%
neg-mul-167.3%
*-commutative67.3%
associate-/l*67.3%
distribute-neg-frac67.3%
neg-mul-167.3%
*-commutative67.3%
associate-/l*67.2%
distribute-rgt-out67.2%
associate-/r*67.2%
metadata-eval67.2%
sub-neg67.2%
+-commutative67.2%
Simplified67.2%
Taylor expanded in a around 0 89.7%
+-commutative89.7%
mul-1-neg89.7%
unsub-neg89.7%
Simplified89.7%
Final simplification84.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ c (- b)) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = c / -b;
} else {
tmp = (c / b) - (b / 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) :: tmp
if (b <= (-5d-310)) then
tmp = c / -b
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = c / -b;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = c / -b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(c / Float64(-b)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = c / -b; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(c / (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 29.8%
div-sub28.9%
sub-neg28.9%
neg-mul-128.9%
*-commutative28.9%
associate-/l*28.7%
distribute-neg-frac28.7%
neg-mul-128.7%
*-commutative28.7%
associate-/l*28.8%
distribute-rgt-out29.8%
associate-/r*29.8%
metadata-eval29.8%
sub-neg29.8%
+-commutative29.8%
Simplified29.8%
Taylor expanded in b around -inf 70.5%
mul-1-neg70.5%
distribute-neg-frac270.5%
Simplified70.5%
if -4.999999999999985e-310 < b Initial program 71.9%
div-sub71.9%
sub-neg71.9%
neg-mul-171.9%
*-commutative71.9%
associate-/l*71.9%
distribute-neg-frac71.9%
neg-mul-171.9%
*-commutative71.9%
associate-/l*71.9%
distribute-rgt-out71.9%
associate-/r*71.9%
metadata-eval71.9%
sub-neg71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in a around 0 66.0%
+-commutative66.0%
mul-1-neg66.0%
unsub-neg66.0%
Simplified66.0%
Final simplification68.3%
(FPCore (a b c) :precision binary64 (if (<= b -2.2e-231) (/ c (- b)) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-231) {
tmp = c / -b;
} else {
tmp = b / -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) :: tmp
if (b <= (-2.2d-231)) then
tmp = c / -b
else
tmp = b / -a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-231) {
tmp = c / -b;
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-231: tmp = c / -b else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-231) tmp = Float64(c / Float64(-b)); else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.2e-231) tmp = c / -b; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-231], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-231}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -2.20000000000000009e-231Initial program 24.8%
div-sub23.7%
sub-neg23.7%
neg-mul-123.7%
*-commutative23.7%
associate-/l*23.6%
distribute-neg-frac23.6%
neg-mul-123.6%
*-commutative23.6%
associate-/l*23.7%
distribute-rgt-out24.8%
associate-/r*24.8%
metadata-eval24.8%
sub-neg24.8%
+-commutative24.8%
Simplified24.8%
Taylor expanded in b around -inf 75.4%
mul-1-neg75.4%
distribute-neg-frac275.4%
Simplified75.4%
if -2.20000000000000009e-231 < b Initial program 73.8%
div-sub73.8%
sub-neg73.8%
neg-mul-173.8%
*-commutative73.8%
associate-/l*73.8%
distribute-neg-frac73.8%
neg-mul-173.8%
*-commutative73.8%
associate-/l*73.8%
distribute-rgt-out73.7%
associate-/r*73.7%
metadata-eval73.7%
sub-neg73.7%
+-commutative73.7%
Simplified73.7%
Taylor expanded in a around 0 61.5%
associate-*r/61.5%
mul-1-neg61.5%
Simplified61.5%
Final simplification68.2%
(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 50.0%
div-sub49.6%
sub-neg49.6%
neg-mul-149.6%
*-commutative49.6%
associate-/l*49.5%
distribute-neg-frac49.5%
neg-mul-149.5%
*-commutative49.5%
associate-/l*49.5%
distribute-rgt-out50.0%
associate-/r*50.0%
metadata-eval50.0%
sub-neg50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in b around -inf 37.7%
mul-1-neg37.7%
distribute-neg-frac237.7%
Simplified37.7%
Final simplification37.7%
(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 50.0%
div-sub49.6%
sub-neg49.6%
neg-mul-149.6%
*-commutative49.6%
associate-/l*49.5%
distribute-neg-frac49.5%
neg-mul-149.5%
*-commutative49.5%
associate-/l*49.5%
distribute-rgt-out50.0%
associate-/r*50.0%
metadata-eval50.0%
sub-neg50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in a around 0 32.9%
add-log-exp14.1%
exp-prod15.1%
add-sqr-sqrt14.6%
sqrt-prod15.8%
sqr-neg15.8%
sqrt-unprod7.1%
add-sqr-sqrt9.4%
sub-neg9.4%
+-inverses9.4%
metadata-eval9.4%
metadata-eval9.4%
Applied egg-rr9.4%
Final simplification9.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fabs (/ b 2.0)))
(t_1 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_2
(if (== (copysign a c) a)
(* (sqrt (- t_0 t_1)) (sqrt (+ t_0 t_1)))
(hypot (/ b 2.0) t_1))))
(if (< b 0.0) (/ c (- t_2 (/ b 2.0))) (/ (+ (/ b 2.0) t_2) (- a)))))
double code(double a, double b, double c) {
double t_0 = fabs((b / 2.0));
double t_1 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp;
if (copysign(a, c) == a) {
tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1));
} else {
tmp = hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = c / (t_2 - (b / 2.0));
} else {
tmp_1 = ((b / 2.0) + t_2) / -a;
}
return tmp_1;
}
public static double code(double a, double b, double c) {
double t_0 = Math.abs((b / 2.0));
double t_1 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp;
if (Math.copySign(a, c) == a) {
tmp = Math.sqrt((t_0 - t_1)) * Math.sqrt((t_0 + t_1));
} else {
tmp = Math.hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = c / (t_2 - (b / 2.0));
} else {
tmp_1 = ((b / 2.0) + t_2) / -a;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.fabs((b / 2.0)) t_1 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp = 0 if math.copysign(a, c) == a: tmp = math.sqrt((t_0 - t_1)) * math.sqrt((t_0 + t_1)) else: tmp = math.hypot((b / 2.0), t_1) t_2 = tmp tmp_1 = 0 if b < 0.0: tmp_1 = c / (t_2 - (b / 2.0)) else: tmp_1 = ((b / 2.0) + t_2) / -a return tmp_1
function code(a, b, c) t_0 = abs(Float64(b / 2.0)) t_1 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp = 0.0 if (copysign(a, c) == a) tmp = Float64(sqrt(Float64(t_0 - t_1)) * sqrt(Float64(t_0 + t_1))); else tmp = hypot(Float64(b / 2.0), t_1); end t_2 = tmp tmp_1 = 0.0 if (b < 0.0) tmp_1 = Float64(c / Float64(t_2 - Float64(b / 2.0))); else tmp_1 = Float64(Float64(Float64(b / 2.0) + t_2) / Float64(-a)); end return tmp_1 end
function tmp_3 = code(a, b, c) t_0 = abs((b / 2.0)); t_1 = sqrt(abs(a)) * sqrt(abs(c)); tmp = 0.0; if ((sign(c) * abs(a)) == a) tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1)); else tmp = hypot((b / 2.0), t_1); end t_2 = tmp; tmp_2 = 0.0; if (b < 0.0) tmp_2 = c / (t_2 - (b / 2.0)); else tmp_2 = ((b / 2.0) + t_2) / -a; end tmp_3 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Abs[N[(b / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(b / 2.0), $MachinePrecision] ^ 2 + t$95$1 ^ 2], $MachinePrecision]]}, If[Less[b, 0.0], N[(c / N[(t$95$2 - N[(b / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b / 2.0), $MachinePrecision] + t$95$2), $MachinePrecision] / (-a)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{b}{2}\right|\\
t_1 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_2 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{t\_0 - t\_1} \cdot \sqrt{t\_0 + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\frac{b}{2}, t\_1\right)\\
\end{array}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{t\_2 - \frac{b}{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{2} + t\_2}{-a}\\
\end{array}
\end{array}
herbie shell --seed 2024046
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-expected 10
:alt
(if (< b 0.0) (/ c (- (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b 2.0))) (/ (+ (/ b 2.0) (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (- a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))