
(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 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(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
(if (<= b -4e+154)
(/ (fabs (+ b (fma -2.0 (* a (/ c b)) b))) (* a 2.0))
(if (<= b 6.2e-6)
(/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+154) {
tmp = fabs((b + fma(-2.0, (a * (c / b)), b))) / (a * 2.0);
} else if (b <= 6.2e-6) {
tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+154) tmp = Float64(abs(Float64(b + fma(-2.0, Float64(a * Float64(c / b)), b))) / Float64(a * 2.0)); elseif (b <= 6.2e-6) tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+154], N[(N[Abs[N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.2e-6], 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[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left|b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right|}{a \cdot 2}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.00000000000000015e154Initial program 29.7%
*-commutative29.7%
Simplified29.7%
Taylor expanded in a around 0 2.1%
add-sqr-sqrt2.1%
sqrt-unprod2.3%
pow22.3%
add-sqr-sqrt15.4%
sqrt-unprod29.9%
sqr-neg29.9%
sqrt-prod0.0%
add-sqr-sqrt30.0%
+-commutative30.0%
fma-define30.0%
associate-/l*30.0%
Applied egg-rr30.0%
unpow230.0%
rem-sqrt-square95.6%
Simplified95.6%
if -4.00000000000000015e154 < b < 6.1999999999999999e-6Initial program 82.1%
*-commutative82.1%
+-commutative82.1%
unsub-neg82.1%
fma-neg82.2%
*-commutative82.2%
associate-*r*82.2%
distribute-lft-neg-in82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
associate-*r*82.2%
metadata-eval82.2%
Simplified82.2%
if 6.1999999999999999e-6 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -3e+153)
(/ (fabs (+ b (fma -2.0 (* a (/ c b)) b))) (* a 2.0))
(if (<= b 2.4e-8)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+153) {
tmp = fabs((b + fma(-2.0, (a * (c / b)), b))) / (a * 2.0);
} else if (b <= 2.4e-8) {
tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3e+153) tmp = Float64(abs(Float64(b + fma(-2.0, Float64(a * Float64(c / b)), b))) / Float64(a * 2.0)); elseif (b <= 2.4e-8) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3e+153], N[(N[Abs[N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-8], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+153}:\\
\;\;\;\;\frac{\left|b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right|}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.00000000000000019e153Initial program 29.7%
*-commutative29.7%
Simplified29.7%
Taylor expanded in a around 0 2.1%
add-sqr-sqrt2.1%
sqrt-unprod2.3%
pow22.3%
add-sqr-sqrt15.4%
sqrt-unprod29.9%
sqr-neg29.9%
sqrt-prod0.0%
add-sqr-sqrt30.0%
+-commutative30.0%
fma-define30.0%
associate-/l*30.0%
Applied egg-rr30.0%
unpow230.0%
rem-sqrt-square95.6%
Simplified95.6%
if -3.00000000000000019e153 < b < 2.39999999999999998e-8Initial program 82.1%
if 2.39999999999999998e-8 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* a (* c -4.0))))
(t_1 (/ b (- a)))
(t_2 (* (/ -0.5 a) (- b t_0))))
(if (<= b -2.4e-30)
t_1
(if (<= b -5e-89)
t_2
(if (<= b -2e-129)
t_1
(if (<= b 1.45e-105)
t_2
(if (<= b 9.8e-25)
(/ 1.0 (- (/ a b) (/ b c)))
(if (<= b 2.7e-8) (/ (/ t_0 (- -2.0)) a) (/ (- c) b)))))))))
double code(double a, double b, double c) {
double t_0 = sqrt((a * (c * -4.0)));
double t_1 = b / -a;
double t_2 = (-0.5 / a) * (b - t_0);
double tmp;
if (b <= -2.4e-30) {
tmp = t_1;
} else if (b <= -5e-89) {
tmp = t_2;
} else if (b <= -2e-129) {
tmp = t_1;
} else if (b <= 1.45e-105) {
tmp = t_2;
} else if (b <= 9.8e-25) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 2.7e-8) {
tmp = (t_0 / -(-2.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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt((a * (c * (-4.0d0))))
t_1 = b / -a
t_2 = ((-0.5d0) / a) * (b - t_0)
if (b <= (-2.4d-30)) then
tmp = t_1
else if (b <= (-5d-89)) then
tmp = t_2
else if (b <= (-2d-129)) then
tmp = t_1
else if (b <= 1.45d-105) then
tmp = t_2
else if (b <= 9.8d-25) then
tmp = 1.0d0 / ((a / b) - (b / c))
else if (b <= 2.7d-8) then
tmp = (t_0 / -(-2.0d0)) / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((a * (c * -4.0)));
double t_1 = b / -a;
double t_2 = (-0.5 / a) * (b - t_0);
double tmp;
if (b <= -2.4e-30) {
tmp = t_1;
} else if (b <= -5e-89) {
tmp = t_2;
} else if (b <= -2e-129) {
tmp = t_1;
} else if (b <= 1.45e-105) {
tmp = t_2;
} else if (b <= 9.8e-25) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 2.7e-8) {
tmp = (t_0 / -(-2.0)) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt((a * (c * -4.0))) t_1 = b / -a t_2 = (-0.5 / a) * (b - t_0) tmp = 0 if b <= -2.4e-30: tmp = t_1 elif b <= -5e-89: tmp = t_2 elif b <= -2e-129: tmp = t_1 elif b <= 1.45e-105: tmp = t_2 elif b <= 9.8e-25: tmp = 1.0 / ((a / b) - (b / c)) elif b <= 2.7e-8: tmp = (t_0 / -(-2.0)) / a else: tmp = -c / b return tmp
function code(a, b, c) t_0 = sqrt(Float64(a * Float64(c * -4.0))) t_1 = Float64(b / Float64(-a)) t_2 = Float64(Float64(-0.5 / a) * Float64(b - t_0)) tmp = 0.0 if (b <= -2.4e-30) tmp = t_1; elseif (b <= -5e-89) tmp = t_2; elseif (b <= -2e-129) tmp = t_1; elseif (b <= 1.45e-105) tmp = t_2; elseif (b <= 9.8e-25) tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); elseif (b <= 2.7e-8) tmp = Float64(Float64(t_0 / Float64(-(-2.0))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt((a * (c * -4.0))); t_1 = b / -a; t_2 = (-0.5 / a) * (b - t_0); tmp = 0.0; if (b <= -2.4e-30) tmp = t_1; elseif (b <= -5e-89) tmp = t_2; elseif (b <= -2e-129) tmp = t_1; elseif (b <= 1.45e-105) tmp = t_2; elseif (b <= 9.8e-25) tmp = 1.0 / ((a / b) - (b / c)); elseif (b <= 2.7e-8) tmp = (t_0 / -(-2.0)) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(b / (-a)), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-0.5 / a), $MachinePrecision] * N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.4e-30], t$95$1, If[LessEqual[b, -5e-89], t$95$2, If[LessEqual[b, -2e-129], t$95$1, If[LessEqual[b, 1.45e-105], t$95$2, If[LessEqual[b, 9.8e-25], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.7e-8], N[(N[(t$95$0 / (--2.0)), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
t_1 := \frac{b}{-a}\\
t_2 := \frac{-0.5}{a} \cdot \left(b - t\_0\right)\\
\mathbf{if}\;b \leq -2.4 \cdot 10^{-30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-89}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-129}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-105}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t\_0}{--2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.39999999999999985e-30 or -4.99999999999999967e-89 < b < -1.9999999999999999e-129Initial program 63.9%
*-commutative63.9%
Simplified63.9%
Taylor expanded in b around -inf 87.6%
associate-*r/87.6%
mul-1-neg87.6%
Simplified87.6%
if -2.39999999999999985e-30 < b < -4.99999999999999967e-89 or -1.9999999999999999e-129 < b < 1.45000000000000002e-105Initial program 83.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in b around 0 73.2%
*-commutative73.2%
associate-*r*73.2%
Simplified73.2%
frac-2neg73.2%
div-inv73.0%
distribute-neg-in73.0%
add-sqr-sqrt44.7%
sqrt-unprod72.6%
sqr-neg72.6%
sqrt-unprod28.3%
add-sqr-sqrt69.9%
sub-neg69.9%
add-sqr-sqrt41.6%
sqrt-unprod70.0%
sqr-neg70.0%
sqrt-unprod28.3%
add-sqr-sqrt73.0%
distribute-rgt-neg-in73.0%
metadata-eval73.0%
associate-/r*73.0%
div-inv73.0%
metadata-eval73.0%
Applied egg-rr73.0%
*-commutative73.0%
associate-*l/73.0%
metadata-eval73.0%
Simplified73.0%
if 1.45000000000000002e-105 < b < 9.7999999999999998e-25Initial program 39.4%
*-commutative39.4%
Simplified39.4%
Applied egg-rr22.1%
hypot-undefine22.1%
add-sqr-sqrt39.2%
fma-define39.2%
Applied egg-rr39.2%
un-div-inv39.4%
clear-num39.4%
fma-undefine39.4%
add-sqr-sqrt22.3%
hypot-undefine22.3%
Applied egg-rr22.3%
Taylor expanded in a around 0 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt55.0%
metadata-eval55.0%
associate-*r/55.0%
mul-1-neg55.0%
Simplified55.0%
if 9.7999999999999998e-25 < b < 2.70000000000000002e-8Initial program 83.7%
*-commutative83.7%
Simplified83.7%
Applied egg-rr84.0%
hypot-undefine84.0%
add-sqr-sqrt84.0%
fma-define84.0%
Applied egg-rr84.0%
un-div-inv83.7%
clear-num83.7%
fma-undefine83.7%
add-sqr-sqrt83.7%
hypot-undefine83.7%
Applied egg-rr83.7%
clear-num83.7%
*-un-lft-identity83.7%
times-frac84.0%
Applied egg-rr84.0%
associate-*l/83.7%
*-lft-identity83.7%
associate--r+83.7%
+-inverses83.7%
neg-sub083.7%
*-commutative83.7%
Simplified83.7%
if 2.70000000000000002e-8 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification82.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ b (- a)))
(t_1 (sqrt (* a (* c -4.0))))
(t_2 (/ (- t_1 b) (* a 2.0))))
(if (<= b -3.5e-27)
t_0
(if (<= b -2.4e-90)
t_2
(if (<= b -2e-129)
t_0
(if (<= b 1.95e-109)
t_2
(if (<= b 9.8e-25)
(/ 1.0 (- (/ a b) (/ b c)))
(if (<= b 2.4e-8) (/ (/ t_1 (- -2.0)) a) (/ (- c) b)))))))))
double code(double a, double b, double c) {
double t_0 = b / -a;
double t_1 = sqrt((a * (c * -4.0)));
double t_2 = (t_1 - b) / (a * 2.0);
double tmp;
if (b <= -3.5e-27) {
tmp = t_0;
} else if (b <= -2.4e-90) {
tmp = t_2;
} else if (b <= -2e-129) {
tmp = t_0;
} else if (b <= 1.95e-109) {
tmp = t_2;
} else if (b <= 9.8e-25) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 2.4e-8) {
tmp = (t_1 / -(-2.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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = b / -a
t_1 = sqrt((a * (c * (-4.0d0))))
t_2 = (t_1 - b) / (a * 2.0d0)
if (b <= (-3.5d-27)) then
tmp = t_0
else if (b <= (-2.4d-90)) then
tmp = t_2
else if (b <= (-2d-129)) then
tmp = t_0
else if (b <= 1.95d-109) then
tmp = t_2
else if (b <= 9.8d-25) then
tmp = 1.0d0 / ((a / b) - (b / c))
else if (b <= 2.4d-8) then
tmp = (t_1 / -(-2.0d0)) / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = b / -a;
double t_1 = Math.sqrt((a * (c * -4.0)));
double t_2 = (t_1 - b) / (a * 2.0);
double tmp;
if (b <= -3.5e-27) {
tmp = t_0;
} else if (b <= -2.4e-90) {
tmp = t_2;
} else if (b <= -2e-129) {
tmp = t_0;
} else if (b <= 1.95e-109) {
tmp = t_2;
} else if (b <= 9.8e-25) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 2.4e-8) {
tmp = (t_1 / -(-2.0)) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = b / -a t_1 = math.sqrt((a * (c * -4.0))) t_2 = (t_1 - b) / (a * 2.0) tmp = 0 if b <= -3.5e-27: tmp = t_0 elif b <= -2.4e-90: tmp = t_2 elif b <= -2e-129: tmp = t_0 elif b <= 1.95e-109: tmp = t_2 elif b <= 9.8e-25: tmp = 1.0 / ((a / b) - (b / c)) elif b <= 2.4e-8: tmp = (t_1 / -(-2.0)) / a else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(b / Float64(-a)) t_1 = sqrt(Float64(a * Float64(c * -4.0))) t_2 = Float64(Float64(t_1 - b) / Float64(a * 2.0)) tmp = 0.0 if (b <= -3.5e-27) tmp = t_0; elseif (b <= -2.4e-90) tmp = t_2; elseif (b <= -2e-129) tmp = t_0; elseif (b <= 1.95e-109) tmp = t_2; elseif (b <= 9.8e-25) tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); elseif (b <= 2.4e-8) tmp = Float64(Float64(t_1 / Float64(-(-2.0))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = b / -a; t_1 = sqrt((a * (c * -4.0))); t_2 = (t_1 - b) / (a * 2.0); tmp = 0.0; if (b <= -3.5e-27) tmp = t_0; elseif (b <= -2.4e-90) tmp = t_2; elseif (b <= -2e-129) tmp = t_0; elseif (b <= 1.95e-109) tmp = t_2; elseif (b <= 9.8e-25) tmp = 1.0 / ((a / b) - (b / c)); elseif (b <= 2.4e-8) tmp = (t_1 / -(-2.0)) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(b / (-a)), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.5e-27], t$95$0, If[LessEqual[b, -2.4e-90], t$95$2, If[LessEqual[b, -2e-129], t$95$0, If[LessEqual[b, 1.95e-109], t$95$2, If[LessEqual[b, 9.8e-25], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-8], N[(N[(t$95$1 / (--2.0)), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{-a}\\
t_1 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
t_2 := \frac{t\_1 - b}{a \cdot 2}\\
\mathbf{if}\;b \leq -3.5 \cdot 10^{-27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq -2.4 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{-109}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t\_1}{--2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.5000000000000001e-27 or -2.4000000000000002e-90 < b < -1.9999999999999999e-129Initial program 63.9%
*-commutative63.9%
Simplified63.9%
Taylor expanded in b around -inf 87.6%
associate-*r/87.6%
mul-1-neg87.6%
Simplified87.6%
if -3.5000000000000001e-27 < b < -2.4000000000000002e-90 or -1.9999999999999999e-129 < b < 1.95000000000000011e-109Initial program 83.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in b around 0 73.2%
*-commutative73.2%
associate-*r*73.2%
Simplified73.2%
+-commutative73.2%
unsub-neg73.2%
Applied egg-rr73.2%
if 1.95000000000000011e-109 < b < 9.7999999999999998e-25Initial program 39.4%
*-commutative39.4%
Simplified39.4%
Applied egg-rr22.1%
hypot-undefine22.1%
add-sqr-sqrt39.2%
fma-define39.2%
Applied egg-rr39.2%
un-div-inv39.4%
clear-num39.4%
fma-undefine39.4%
add-sqr-sqrt22.3%
hypot-undefine22.3%
Applied egg-rr22.3%
Taylor expanded in a around 0 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt55.0%
metadata-eval55.0%
associate-*r/55.0%
mul-1-neg55.0%
Simplified55.0%
if 9.7999999999999998e-25 < b < 2.39999999999999998e-8Initial program 83.7%
*-commutative83.7%
Simplified83.7%
Applied egg-rr84.0%
hypot-undefine84.0%
add-sqr-sqrt84.0%
fma-define84.0%
Applied egg-rr84.0%
un-div-inv83.7%
clear-num83.7%
fma-undefine83.7%
add-sqr-sqrt83.7%
hypot-undefine83.7%
Applied egg-rr83.7%
clear-num83.7%
*-un-lft-identity83.7%
times-frac84.0%
Applied egg-rr84.0%
associate-*l/83.7%
*-lft-identity83.7%
associate--r+83.7%
+-inverses83.7%
neg-sub083.7%
*-commutative83.7%
Simplified83.7%
if 2.39999999999999998e-8 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification82.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ b (- a)))
(t_1 (sqrt (* a (* c -4.0))))
(t_2 (/ (- t_1 b) (* a 2.0))))
(if (<= b -2.2e-26)
t_0
(if (<= b -5.9e-89)
t_2
(if (<= b -2e-129)
t_0
(if (<= b 1.5e-106)
t_2
(if (<= b 9.8e-25)
(/ 1.0 (/ (fma a (/ c b) (* 4.0 (/ b -4.0))) c))
(if (<= b 2.4e-8) (/ (/ t_1 (- -2.0)) a) (/ (- c) b)))))))))
double code(double a, double b, double c) {
double t_0 = b / -a;
double t_1 = sqrt((a * (c * -4.0)));
double t_2 = (t_1 - b) / (a * 2.0);
double tmp;
if (b <= -2.2e-26) {
tmp = t_0;
} else if (b <= -5.9e-89) {
tmp = t_2;
} else if (b <= -2e-129) {
tmp = t_0;
} else if (b <= 1.5e-106) {
tmp = t_2;
} else if (b <= 9.8e-25) {
tmp = 1.0 / (fma(a, (c / b), (4.0 * (b / -4.0))) / c);
} else if (b <= 2.4e-8) {
tmp = (t_1 / -(-2.0)) / a;
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(b / Float64(-a)) t_1 = sqrt(Float64(a * Float64(c * -4.0))) t_2 = Float64(Float64(t_1 - b) / Float64(a * 2.0)) tmp = 0.0 if (b <= -2.2e-26) tmp = t_0; elseif (b <= -5.9e-89) tmp = t_2; elseif (b <= -2e-129) tmp = t_0; elseif (b <= 1.5e-106) tmp = t_2; elseif (b <= 9.8e-25) tmp = Float64(1.0 / Float64(fma(a, Float64(c / b), Float64(4.0 * Float64(b / -4.0))) / c)); elseif (b <= 2.4e-8) tmp = Float64(Float64(t_1 / Float64(-(-2.0))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(b / (-a)), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.2e-26], t$95$0, If[LessEqual[b, -5.9e-89], t$95$2, If[LessEqual[b, -2e-129], t$95$0, If[LessEqual[b, 1.5e-106], t$95$2, If[LessEqual[b, 9.8e-25], N[(1.0 / N[(N[(a * N[(c / b), $MachinePrecision] + N[(4.0 * N[(b / -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-8], N[(N[(t$95$1 / (--2.0)), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{-a}\\
t_1 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
t_2 := \frac{t\_1 - b}{a \cdot 2}\\
\mathbf{if}\;b \leq -2.2 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq -5.9 \cdot 10^{-89}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-106}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(a, \frac{c}{b}, 4 \cdot \frac{b}{-4}\right)}{c}}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{t\_1}{--2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.2000000000000001e-26 or -5.90000000000000021e-89 < b < -1.9999999999999999e-129Initial program 63.9%
*-commutative63.9%
Simplified63.9%
Taylor expanded in b around -inf 87.6%
associate-*r/87.6%
mul-1-neg87.6%
Simplified87.6%
if -2.2000000000000001e-26 < b < -5.90000000000000021e-89 or -1.9999999999999999e-129 < b < 1.50000000000000009e-106Initial program 83.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in b around 0 73.2%
*-commutative73.2%
associate-*r*73.2%
Simplified73.2%
+-commutative73.2%
unsub-neg73.2%
Applied egg-rr73.2%
if 1.50000000000000009e-106 < b < 9.7999999999999998e-25Initial program 39.4%
*-commutative39.4%
Simplified39.4%
Applied egg-rr22.1%
hypot-undefine22.1%
add-sqr-sqrt39.2%
fma-define39.2%
Applied egg-rr39.2%
un-div-inv39.4%
clear-num39.4%
fma-undefine39.4%
add-sqr-sqrt22.3%
hypot-undefine22.3%
Applied egg-rr22.3%
Taylor expanded in c around 0 0.0%
+-commutative0.0%
associate-/l*0.0%
fma-define0.0%
unpow20.0%
rem-square-sqrt55.0%
Simplified55.0%
if 9.7999999999999998e-25 < b < 2.39999999999999998e-8Initial program 83.7%
*-commutative83.7%
Simplified83.7%
Applied egg-rr84.0%
hypot-undefine84.0%
add-sqr-sqrt84.0%
fma-define84.0%
Applied egg-rr84.0%
un-div-inv83.7%
clear-num83.7%
fma-undefine83.7%
add-sqr-sqrt83.7%
hypot-undefine83.7%
Applied egg-rr83.7%
clear-num83.7%
*-un-lft-identity83.7%
times-frac84.0%
Applied egg-rr84.0%
associate-*l/83.7%
*-lft-identity83.7%
associate--r+83.7%
+-inverses83.7%
neg-sub083.7%
*-commutative83.7%
Simplified83.7%
if 2.39999999999999998e-8 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification82.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (/ (sqrt (* a (* c -4.0))) (- -2.0)) a)))
(if (<= b -1.7e-129)
(/ b (- a))
(if (<= b 5.6e-105)
t_0
(if (<= b 9.8e-25)
(/ 1.0 (- (/ a b) (/ b c)))
(if (<= b 2.4e-8) t_0 (/ (- c) b)))))))
double code(double a, double b, double c) {
double t_0 = (sqrt((a * (c * -4.0))) / -(-2.0)) / a;
double tmp;
if (b <= -1.7e-129) {
tmp = b / -a;
} else if (b <= 5.6e-105) {
tmp = t_0;
} else if (b <= 9.8e-25) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 2.4e-8) {
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 = (sqrt((a * (c * (-4.0d0)))) / -(-2.0d0)) / a
if (b <= (-1.7d-129)) then
tmp = b / -a
else if (b <= 5.6d-105) then
tmp = t_0
else if (b <= 9.8d-25) then
tmp = 1.0d0 / ((a / b) - (b / c))
else if (b <= 2.4d-8) 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 = (Math.sqrt((a * (c * -4.0))) / -(-2.0)) / a;
double tmp;
if (b <= -1.7e-129) {
tmp = b / -a;
} else if (b <= 5.6e-105) {
tmp = t_0;
} else if (b <= 9.8e-25) {
tmp = 1.0 / ((a / b) - (b / c));
} else if (b <= 2.4e-8) {
tmp = t_0;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = (math.sqrt((a * (c * -4.0))) / -(-2.0)) / a tmp = 0 if b <= -1.7e-129: tmp = b / -a elif b <= 5.6e-105: tmp = t_0 elif b <= 9.8e-25: tmp = 1.0 / ((a / b) - (b / c)) elif b <= 2.4e-8: tmp = t_0 else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) / Float64(-(-2.0))) / a) tmp = 0.0 if (b <= -1.7e-129) tmp = Float64(b / Float64(-a)); elseif (b <= 5.6e-105) tmp = t_0; elseif (b <= 9.8e-25) tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); elseif (b <= 2.4e-8) tmp = t_0; else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (sqrt((a * (c * -4.0))) / -(-2.0)) / a; tmp = 0.0; if (b <= -1.7e-129) tmp = b / -a; elseif (b <= 5.6e-105) tmp = t_0; elseif (b <= 9.8e-25) tmp = 1.0 / ((a / b) - (b / c)); elseif (b <= 2.4e-8) tmp = t_0; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (--2.0)), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[b, -1.7e-129], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 5.6e-105], t$95$0, If[LessEqual[b, 9.8e-25], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-8], t$95$0, N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{--2}}{a}\\
\mathbf{if}\;b \leq -1.7 \cdot 10^{-129}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.70000000000000007e-129Initial program 67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in b around -inf 81.0%
associate-*r/81.0%
mul-1-neg81.0%
Simplified81.0%
if -1.70000000000000007e-129 < b < 5.6e-105 or 9.7999999999999998e-25 < b < 2.39999999999999998e-8Initial program 80.9%
*-commutative80.9%
Simplified80.9%
Applied egg-rr80.5%
hypot-undefine79.0%
add-sqr-sqrt80.8%
fma-define80.8%
Applied egg-rr80.8%
un-div-inv80.9%
clear-num80.8%
fma-undefine80.8%
add-sqr-sqrt79.0%
hypot-undefine80.5%
Applied egg-rr80.5%
clear-num80.6%
*-un-lft-identity80.6%
times-frac80.5%
Applied egg-rr75.0%
associate-*l/75.1%
*-lft-identity75.1%
associate--r+75.2%
+-inverses75.2%
neg-sub075.2%
*-commutative75.2%
Simplified75.2%
if 5.6e-105 < b < 9.7999999999999998e-25Initial program 39.4%
*-commutative39.4%
Simplified39.4%
Applied egg-rr22.1%
hypot-undefine22.1%
add-sqr-sqrt39.2%
fma-define39.2%
Applied egg-rr39.2%
un-div-inv39.4%
clear-num39.4%
fma-undefine39.4%
add-sqr-sqrt22.3%
hypot-undefine22.3%
Applied egg-rr22.3%
Taylor expanded in a around 0 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt55.0%
metadata-eval55.0%
associate-*r/55.0%
mul-1-neg55.0%
Simplified55.0%
if 2.39999999999999998e-8 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e+154)
(/ b (- a))
(if (<= b 2.65e-8)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e+154) {
tmp = b / -a;
} else if (b <= 2.65e-8) {
tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.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) :: tmp
if (b <= (-1.25d+154)) then
tmp = b / -a
else if (b <= 2.65d-8) then
tmp = (sqrt(((b * b) - (4.0d0 * (a * c)))) - b) / (a * 2.0d0)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e+154) {
tmp = b / -a;
} else if (b <= 2.65e-8) {
tmp = (Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e+154: tmp = b / -a elif b <= 2.65e-8: tmp = (math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e+154) tmp = Float64(b / Float64(-a)); elseif (b <= 2.65e-8) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.25e+154) tmp = b / -a; elseif (b <= 2.65e-8) tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e+154], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.65e-8], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{+154}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.25000000000000001e154Initial program 29.7%
*-commutative29.7%
Simplified29.7%
Taylor expanded in b around -inf 95.5%
associate-*r/95.5%
mul-1-neg95.5%
Simplified95.5%
if -1.25000000000000001e154 < b < 2.6499999999999999e-8Initial program 82.1%
if 2.6499999999999999e-8 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification86.1%
(FPCore (a b c) :precision binary64 (if (<= b 550000.0) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 550000.0) {
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 <= 550000.0d0) 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 <= 550000.0) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 550000.0: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 550000.0) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 550000.0) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 550000.0], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 550000:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 5.5e5Initial program 69.2%
*-commutative69.2%
Simplified69.2%
Taylor expanded in b around -inf 53.5%
associate-*r/53.5%
mul-1-neg53.5%
Simplified53.5%
if 5.5e5 < b Initial program 15.0%
*-commutative15.0%
Simplified15.0%
Taylor expanded in b around inf 71.8%
frac-2neg71.8%
div-inv71.8%
associate-*r/71.8%
distribute-neg-frac271.8%
associate-*r*71.8%
*-commutative71.8%
add-sqr-sqrt0.0%
sqrt-unprod23.5%
sqr-neg23.5%
sqrt-unprod23.2%
add-sqr-sqrt23.2%
distribute-rgt-neg-in23.2%
metadata-eval23.2%
associate-/r*23.2%
div-inv23.2%
metadata-eval23.2%
Applied egg-rr23.2%
*-commutative23.2%
associate-*l/23.2%
metadata-eval23.2%
associate-/l*23.2%
Simplified23.2%
Taylor expanded in a around 0 23.0%
Final simplification44.7%
(FPCore (a b c) :precision binary64 (if (<= b 4.4e-254) (/ b (- a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.4e-254) {
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 <= 4.4d-254) 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 <= 4.4e-254) {
tmp = b / -a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.4e-254: tmp = b / -a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.4e-254) tmp = Float64(b / Float64(-a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4.4e-254) tmp = b / -a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.4e-254], N[(b / (-a)), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.4 \cdot 10^{-254}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 4.4000000000000002e-254Initial program 71.3%
*-commutative71.3%
Simplified71.3%
Taylor expanded in b around -inf 67.0%
associate-*r/67.0%
mul-1-neg67.0%
Simplified67.0%
if 4.4000000000000002e-254 < b Initial program 31.0%
*-commutative31.0%
Simplified31.0%
Taylor expanded in b around inf 68.7%
associate-*r/68.7%
neg-mul-168.7%
Simplified68.7%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / 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 / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 53.5%
*-commutative53.5%
Simplified53.5%
Applied egg-rr24.7%
Taylor expanded in a around 0 2.2%
Final simplification2.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 / 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 53.5%
*-commutative53.5%
Simplified53.5%
Taylor expanded in b around inf 24.4%
frac-2neg24.4%
div-inv24.4%
associate-*r/24.4%
distribute-neg-frac224.4%
associate-*r*24.4%
*-commutative24.4%
add-sqr-sqrt1.2%
sqrt-unprod8.1%
sqr-neg8.1%
sqrt-unprod7.0%
add-sqr-sqrt8.9%
distribute-rgt-neg-in8.9%
metadata-eval8.9%
associate-/r*8.9%
div-inv8.9%
metadata-eval8.9%
Applied egg-rr8.9%
*-commutative8.9%
associate-*l/8.9%
metadata-eval8.9%
associate-/l*9.0%
Simplified9.0%
Taylor expanded in a around 0 9.0%
Final simplification9.0%
(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) (/ (- t_2 (/ b 2.0)) a) (/ (- c) (+ (/ b 2.0) t_2)))))
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 = (t_2 - (b / 2.0)) / a;
} else {
tmp_1 = -c / ((b / 2.0) + t_2);
}
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 = (t_2 - (b / 2.0)) / a;
} else {
tmp_1 = -c / ((b / 2.0) + t_2);
}
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 = (t_2 - (b / 2.0)) / a else: tmp_1 = -c / ((b / 2.0) + t_2) 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(Float64(t_2 - Float64(b / 2.0)) / a); else tmp_1 = Float64(Float64(-c) / Float64(Float64(b / 2.0) + t_2)); 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 = (t_2 - (b / 2.0)) / a; else tmp_2 = -c / ((b / 2.0) + t_2); 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[(N[(t$95$2 - N[(b / 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / N[(N[(b / 2.0), $MachinePrecision] + t$95$2), $MachinePrecision]), $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{t\_2 - \frac{b}{2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\frac{b}{2} + t\_2}\\
\end{array}
\end{array}
herbie shell --seed 2024072
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-expected 10
:alt
(if (< b 0.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))))) (/ b 2.0)) a) (/ (- c) (+ (/ 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))))))))
(/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))