
(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)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (2.0 * c) / (-b + t_0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (2.0 * c) / (-b + t_0);
}
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 = (2.0 * c) / (-b + t_0) 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(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (2.0 * c) / (-b + t_0); 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[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (2.0 * c) / (-b + t_0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (2.0 * c) / (-b + t_0);
}
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 = (2.0 * c) / (-b + t_0) 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(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (2.0 * c) / (-b + t_0); 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[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b))
(t_1 (sqrt (fma b b (* a (* c -4.0)))))
(t_2 (* (/ b a) 2.0)))
(if (<= b -3.7e+77)
(if (>= b 0.0) (* -0.5 t_2) t_0)
(if (<= b 1e+112)
(if (>= b 0.0) (* -0.5 (/ (+ b t_1) a)) (/ (* 2.0 c) (- t_1 b)))
(if (>= b 0.0) (* -0.5 (+ (* -2.0 (/ c b)) t_2)) t_0)))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = sqrt(fma(b, b, (a * (c * -4.0))));
double t_2 = (b / a) * 2.0;
double tmp_1;
if (b <= -3.7e+77) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_2;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= 1e+112) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((b + t_1) / a);
} else {
tmp_3 = (2.0 * c) / (t_1 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_2);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = sqrt(fma(b, b, Float64(a * Float64(c * -4.0)))) t_2 = Float64(Float64(b / a) * 2.0) tmp_1 = 0.0 if (b <= -3.7e+77) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * t_2); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= 1e+112) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-0.5 * Float64(Float64(b + t_1) / a)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_1 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + t_2)); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(b * b + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[b, -3.7e+77], If[GreaterEqual[b, 0.0], N[(-0.5 * t$95$2), $MachinePrecision], t$95$0], If[LessEqual[b, 1e+112], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + t$95$1), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\\
t_2 := \frac{b}{a} \cdot 2\\
\mathbf{if}\;b \leq -3.7 \cdot 10^{+77}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot t_2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+112}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + t_1}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_1 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + t_2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -3.69999999999999995e77Initial program 54.1%
Simplified54.1%
Taylor expanded in b around -inf 97.2%
associate-*r/97.2%
neg-mul-197.2%
Simplified97.2%
Taylor expanded in b around inf 97.2%
*-commutative97.2%
Simplified97.2%
if -3.69999999999999995e77 < b < 9.9999999999999993e111Initial program 91.8%
Simplified91.9%
if 9.9999999999999993e111 < b Initial program 58.1%
Simplified58.1%
Taylor expanded in b around -inf 58.1%
associate-*r/58.1%
neg-mul-158.1%
Simplified58.1%
Taylor expanded in b around inf 100.0%
Final simplification95.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b)) (t_1 (* (/ b a) 2.0)))
(if (<= b -2.5e-66)
(if (>= b 0.0) (* -0.5 t_1) t_0)
(if (<= b -2e-311)
(if (>= b 0.0)
(* -0.5 (/ (* c -2.0) b))
(/ (* 2.0 c) (- (sqrt (* c (* a -4.0))) b)))
(if (<= b 9e+112)
(if (>= b 0.0)
(* -0.5 (/ (+ b (sqrt (+ (* a (* c -4.0)) (* b b)))) a))
t_0)
(if (>= b 0.0) (* -0.5 (+ (* -2.0 (/ c b)) t_1)) t_0))))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = (b / a) * 2.0;
double tmp_1;
if (b <= -2.5e-66) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_1;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -2e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((c * -2.0) / b);
} else {
tmp_3 = (2.0 * c) / (sqrt((c * (a * -4.0))) - b);
}
tmp_1 = tmp_3;
} else if (b <= 9e+112) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -0.5 * ((b + sqrt(((a * (c * -4.0)) + (b * b)))) / a);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -c / b
t_1 = (b / a) * 2.0d0
if (b <= (-2.5d-66)) then
if (b >= 0.0d0) then
tmp_2 = (-0.5d0) * t_1
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b <= (-2d-311)) then
if (b >= 0.0d0) then
tmp_3 = (-0.5d0) * ((c * (-2.0d0)) / b)
else
tmp_3 = (2.0d0 * c) / (sqrt((c * (a * (-4.0d0)))) - b)
end if
tmp_1 = tmp_3
else if (b <= 9d+112) then
if (b >= 0.0d0) then
tmp_4 = (-0.5d0) * ((b + sqrt(((a * (c * (-4.0d0))) + (b * b)))) / a)
else
tmp_4 = t_0
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * (((-2.0d0) * (c / b)) + t_1)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = (b / a) * 2.0;
double tmp_1;
if (b <= -2.5e-66) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_1;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -2e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((c * -2.0) / b);
} else {
tmp_3 = (2.0 * c) / (Math.sqrt((c * (a * -4.0))) - b);
}
tmp_1 = tmp_3;
} else if (b <= 9e+112) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -0.5 * ((b + Math.sqrt(((a * (c * -4.0)) + (b * b)))) / a);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -c / b t_1 = (b / a) * 2.0 tmp_1 = 0 if b <= -2.5e-66: tmp_2 = 0 if b >= 0.0: tmp_2 = -0.5 * t_1 else: tmp_2 = t_0 tmp_1 = tmp_2 elif b <= -2e-311: tmp_3 = 0 if b >= 0.0: tmp_3 = -0.5 * ((c * -2.0) / b) else: tmp_3 = (2.0 * c) / (math.sqrt((c * (a * -4.0))) - b) tmp_1 = tmp_3 elif b <= 9e+112: tmp_4 = 0 if b >= 0.0: tmp_4 = -0.5 * ((b + math.sqrt(((a * (c * -4.0)) + (b * b)))) / a) else: tmp_4 = t_0 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = Float64(Float64(b / a) * 2.0) tmp_1 = 0.0 if (b <= -2.5e-66) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * t_1); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -2e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-0.5 * Float64(Float64(c * -2.0) / b)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(sqrt(Float64(c * Float64(a * -4.0))) - b)); end tmp_1 = tmp_3; elseif (b <= 9e+112) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(Float64(a * Float64(c * -4.0)) + Float64(b * b)))) / a)); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + t_1)); else tmp_1 = t_0; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = -c / b; t_1 = (b / a) * 2.0; tmp_2 = 0.0; if (b <= -2.5e-66) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -0.5 * t_1; else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b <= -2e-311) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -0.5 * ((c * -2.0) / b); else tmp_4 = (2.0 * c) / (sqrt((c * (a * -4.0))) - b); end tmp_2 = tmp_4; elseif (b <= 9e+112) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = -0.5 * ((b + sqrt(((a * (c * -4.0)) + (b * b)))) / a); else tmp_5 = t_0; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = -0.5 * ((-2.0 * (c / b)) + t_1); else tmp_2 = t_0; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[b, -2.5e-66], If[GreaterEqual[b, 0.0], N[(-0.5 * t$95$1), $MachinePrecision], t$95$0], If[LessEqual[b, -2e-311], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(c * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 9e+112], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + N[Sqrt[N[(N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := \frac{b}{a} \cdot 2\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{-66}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{c \cdot -2}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{c \cdot \left(a \cdot -4\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{+112}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{a \cdot \left(c \cdot -4\right) + b \cdot b}}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -2.49999999999999981e-66Initial program 66.9%
Simplified66.9%
Taylor expanded in b around -inf 91.5%
associate-*r/91.5%
neg-mul-191.5%
Simplified91.5%
Taylor expanded in b around inf 91.5%
*-commutative91.5%
Simplified91.5%
if -2.49999999999999981e-66 < b < -1.9999999999999e-311Initial program 90.6%
Simplified90.7%
Taylor expanded in b around inf 90.7%
+-commutative90.7%
*-commutative90.7%
fma-def90.7%
*-lft-identity90.7%
times-frac90.7%
/-rgt-identity90.7%
Simplified90.7%
Taylor expanded in b around 0 76.2%
*-commutative76.2%
associate-*l*76.2%
Simplified76.2%
Taylor expanded in b around 0 76.2%
associate-*r/76.2%
Simplified76.2%
if -1.9999999999999e-311 < b < 8.9999999999999998e112Initial program 90.5%
Simplified90.5%
Taylor expanded in b around -inf 90.5%
associate-*r/90.5%
neg-mul-190.5%
Simplified90.5%
fma-udef90.5%
Applied egg-rr90.5%
if 8.9999999999999998e112 < b Initial program 58.1%
Simplified58.1%
Taylor expanded in b around -inf 58.1%
associate-*r/58.1%
neg-mul-158.1%
Simplified58.1%
Taylor expanded in b around inf 100.0%
Final simplification91.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b))
(t_1 (sqrt (+ (* a (* c -4.0)) (* b b))))
(t_2 (* (/ b a) 2.0)))
(if (<= b -3.1e+77)
(if (>= b 0.0) (* -0.5 t_2) t_0)
(if (<= b -2e-311)
(if (>= b 0.0)
(* -0.5 (/ (fma b 2.0 (* -2.0 (* c (/ a b)))) a))
(/ (* 2.0 c) (- t_1 b)))
(if (<= b 3.7e+112)
(if (>= b 0.0) (* -0.5 (/ (+ b t_1) a)) t_0)
(if (>= b 0.0) (* -0.5 (+ (* -2.0 (/ c b)) t_2)) t_0))))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = sqrt(((a * (c * -4.0)) + (b * b)));
double t_2 = (b / a) * 2.0;
double tmp_1;
if (b <= -3.1e+77) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_2;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -2e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * (fma(b, 2.0, (-2.0 * (c * (a / b)))) / a);
} else {
tmp_3 = (2.0 * c) / (t_1 - b);
}
tmp_1 = tmp_3;
} else if (b <= 3.7e+112) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -0.5 * ((b + t_1) / a);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_2);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = sqrt(Float64(Float64(a * Float64(c * -4.0)) + Float64(b * b))) t_2 = Float64(Float64(b / a) * 2.0) tmp_1 = 0.0 if (b <= -3.1e+77) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * t_2); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -2e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-0.5 * Float64(fma(b, 2.0, Float64(-2.0 * Float64(c * Float64(a / b)))) / a)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_1 - b)); end tmp_1 = tmp_3; elseif (b <= 3.7e+112) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(-0.5 * Float64(Float64(b + t_1) / a)); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + t_2)); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[b, -3.1e+77], If[GreaterEqual[b, 0.0], N[(-0.5 * t$95$2), $MachinePrecision], t$95$0], If[LessEqual[b, -2e-311], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b * 2.0 + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.7e+112], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + t$95$1), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := \sqrt{a \cdot \left(c \cdot -4\right) + b \cdot b}\\
t_2 := \frac{b}{a} \cdot 2\\
\mathbf{if}\;b \leq -3.1 \cdot 10^{+77}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot t_2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{\mathsf{fma}\left(b, 2, -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_1 - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{+112}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + t_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + t_2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -3.09999999999999999e77Initial program 54.1%
Simplified54.1%
Taylor expanded in b around -inf 97.2%
associate-*r/97.2%
neg-mul-197.2%
Simplified97.2%
Taylor expanded in b around inf 97.2%
*-commutative97.2%
Simplified97.2%
if -3.09999999999999999e77 < b < -1.9999999999999e-311Initial program 93.5%
Simplified93.5%
Taylor expanded in b around inf 93.5%
+-commutative93.5%
*-commutative93.5%
fma-def93.5%
*-lft-identity93.5%
times-frac93.5%
/-rgt-identity93.5%
Simplified93.5%
fma-udef47.3%
Applied egg-rr93.5%
if -1.9999999999999e-311 < b < 3.70000000000000004e112Initial program 90.5%
Simplified90.5%
Taylor expanded in b around -inf 90.5%
associate-*r/90.5%
neg-mul-190.5%
Simplified90.5%
fma-udef90.5%
Applied egg-rr90.5%
if 3.70000000000000004e112 < b Initial program 58.1%
Simplified58.1%
Taylor expanded in b around -inf 58.1%
associate-*r/58.1%
neg-mul-158.1%
Simplified58.1%
Taylor expanded in b around inf 100.0%
Final simplification95.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b))
(t_1 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_2 (* (/ b a) 2.0)))
(if (<= b -2.5e+77)
(if (>= b 0.0) (* -0.5 t_2) t_0)
(if (<= b 9e+112)
(if (>= b 0.0) (/ (- (- b) t_1) (* a 2.0)) (/ (* 2.0 c) (- t_1 b)))
(if (>= b 0.0) (* -0.5 (+ (* -2.0 (/ c b)) t_2)) t_0)))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = sqrt(((b * b) - (c * (a * 4.0))));
double t_2 = (b / a) * 2.0;
double tmp_1;
if (b <= -2.5e+77) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_2;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= 9e+112) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_1) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_1 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_2);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = -c / b
t_1 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_2 = (b / a) * 2.0d0
if (b <= (-2.5d+77)) then
if (b >= 0.0d0) then
tmp_2 = (-0.5d0) * t_2
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b <= 9d+112) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_1) / (a * 2.0d0)
else
tmp_3 = (2.0d0 * c) / (t_1 - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * (((-2.0d0) * (c / b)) + t_2)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_2 = (b / a) * 2.0;
double tmp_1;
if (b <= -2.5e+77) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_2;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= 9e+112) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_1) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_1 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_2);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -c / b t_1 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_2 = (b / a) * 2.0 tmp_1 = 0 if b <= -2.5e+77: tmp_2 = 0 if b >= 0.0: tmp_2 = -0.5 * t_2 else: tmp_2 = t_0 tmp_1 = tmp_2 elif b <= 9e+112: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_1) / (a * 2.0) else: tmp_3 = (2.0 * c) / (t_1 - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_2) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_2 = Float64(Float64(b / a) * 2.0) tmp_1 = 0.0 if (b <= -2.5e+77) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * t_2); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= 9e+112) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_1 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + t_2)); else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = -c / b; t_1 = sqrt(((b * b) - (c * (a * 4.0)))); t_2 = (b / a) * 2.0; tmp_2 = 0.0; if (b <= -2.5e+77) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -0.5 * t_2; else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b <= 9e+112) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_1) / (a * 2.0); else tmp_4 = (2.0 * c) / (t_1 - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -0.5 * ((-2.0 * (c / b)) + t_2); else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[b, -2.5e+77], If[GreaterEqual[b, 0.0], N[(-0.5 * t$95$2), $MachinePrecision], t$95$0], If[LessEqual[b, 9e+112], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_2 := \frac{b}{a} \cdot 2\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{+77}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot t_2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{+112}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_1 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + t_2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -2.50000000000000002e77Initial program 54.1%
Simplified54.1%
Taylor expanded in b around -inf 97.2%
associate-*r/97.2%
neg-mul-197.2%
Simplified97.2%
Taylor expanded in b around inf 97.2%
*-commutative97.2%
Simplified97.2%
if -2.50000000000000002e77 < b < 8.9999999999999998e112Initial program 91.8%
if 8.9999999999999998e112 < b Initial program 58.1%
Simplified58.1%
Taylor expanded in b around -inf 58.1%
associate-*r/58.1%
neg-mul-158.1%
Simplified58.1%
Taylor expanded in b around inf 100.0%
Final simplification95.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b)) (t_1 (* (/ b a) 2.0)) (t_2 (sqrt (* c (* a -4.0)))))
(if (<= b -2.15e-66)
(if (>= b 0.0) (* -0.5 t_1) t_0)
(if (<= b -2e-311)
(if (>= b 0.0) (* -0.5 (/ (* c -2.0) b)) (/ (* 2.0 c) (- t_2 b)))
(if (<= b 7.6e-100)
(if (>= b 0.0) (* -0.5 (/ (+ b t_2) a)) t_0)
(if (>= b 0.0) (* -0.5 (+ (* -2.0 (/ c b)) t_1)) t_0))))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = (b / a) * 2.0;
double t_2 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -2.15e-66) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_1;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -2e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((c * -2.0) / b);
} else {
tmp_3 = (2.0 * c) / (t_2 - b);
}
tmp_1 = tmp_3;
} else if (b <= 7.6e-100) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -0.5 * ((b + t_2) / a);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -c / b
t_1 = (b / a) * 2.0d0
t_2 = sqrt((c * (a * (-4.0d0))))
if (b <= (-2.15d-66)) then
if (b >= 0.0d0) then
tmp_2 = (-0.5d0) * t_1
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b <= (-2d-311)) then
if (b >= 0.0d0) then
tmp_3 = (-0.5d0) * ((c * (-2.0d0)) / b)
else
tmp_3 = (2.0d0 * c) / (t_2 - b)
end if
tmp_1 = tmp_3
else if (b <= 7.6d-100) then
if (b >= 0.0d0) then
tmp_4 = (-0.5d0) * ((b + t_2) / a)
else
tmp_4 = t_0
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * (((-2.0d0) * (c / b)) + t_1)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = (b / a) * 2.0;
double t_2 = Math.sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -2.15e-66) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_1;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -2e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((c * -2.0) / b);
} else {
tmp_3 = (2.0 * c) / (t_2 - b);
}
tmp_1 = tmp_3;
} else if (b <= 7.6e-100) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -0.5 * ((b + t_2) / a);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -c / b t_1 = (b / a) * 2.0 t_2 = math.sqrt((c * (a * -4.0))) tmp_1 = 0 if b <= -2.15e-66: tmp_2 = 0 if b >= 0.0: tmp_2 = -0.5 * t_1 else: tmp_2 = t_0 tmp_1 = tmp_2 elif b <= -2e-311: tmp_3 = 0 if b >= 0.0: tmp_3 = -0.5 * ((c * -2.0) / b) else: tmp_3 = (2.0 * c) / (t_2 - b) tmp_1 = tmp_3 elif b <= 7.6e-100: tmp_4 = 0 if b >= 0.0: tmp_4 = -0.5 * ((b + t_2) / a) else: tmp_4 = t_0 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = Float64(Float64(b / a) * 2.0) t_2 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -2.15e-66) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * t_1); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -2e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-0.5 * Float64(Float64(c * -2.0) / b)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_2 - b)); end tmp_1 = tmp_3; elseif (b <= 7.6e-100) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(-0.5 * Float64(Float64(b + t_2) / a)); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + t_1)); else tmp_1 = t_0; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = -c / b; t_1 = (b / a) * 2.0; t_2 = sqrt((c * (a * -4.0))); tmp_2 = 0.0; if (b <= -2.15e-66) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -0.5 * t_1; else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b <= -2e-311) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -0.5 * ((c * -2.0) / b); else tmp_4 = (2.0 * c) / (t_2 - b); end tmp_2 = tmp_4; elseif (b <= 7.6e-100) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = -0.5 * ((b + t_2) / a); else tmp_5 = t_0; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = -0.5 * ((-2.0 * (c / b)) + t_1); else tmp_2 = t_0; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.15e-66], If[GreaterEqual[b, 0.0], N[(-0.5 * t$95$1), $MachinePrecision], t$95$0], If[LessEqual[b, -2e-311], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(c * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7.6e-100], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + t$95$2), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := \frac{b}{a} \cdot 2\\
t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -2.15 \cdot 10^{-66}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{c \cdot -2}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_2 - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + t_2}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -2.15000000000000007e-66Initial program 66.9%
Simplified66.9%
Taylor expanded in b around -inf 91.5%
associate-*r/91.5%
neg-mul-191.5%
Simplified91.5%
Taylor expanded in b around inf 91.5%
*-commutative91.5%
Simplified91.5%
if -2.15000000000000007e-66 < b < -1.9999999999999e-311Initial program 90.6%
Simplified90.7%
Taylor expanded in b around inf 90.7%
+-commutative90.7%
*-commutative90.7%
fma-def90.7%
*-lft-identity90.7%
times-frac90.7%
/-rgt-identity90.7%
Simplified90.7%
Taylor expanded in b around 0 76.2%
*-commutative76.2%
associate-*l*76.2%
Simplified76.2%
Taylor expanded in b around 0 76.2%
associate-*r/76.2%
Simplified76.2%
if -1.9999999999999e-311 < b < 7.59999999999999995e-100Initial program 88.3%
Simplified88.3%
Taylor expanded in b around -inf 88.3%
associate-*r/88.3%
neg-mul-188.3%
Simplified88.3%
Taylor expanded in b around 0 88.3%
*-commutative7.8%
associate-*l*7.8%
Simplified88.3%
if 7.59999999999999995e-100 < b Initial program 73.2%
Simplified73.2%
Taylor expanded in b around -inf 73.2%
associate-*r/73.2%
neg-mul-173.2%
Simplified73.2%
Taylor expanded in b around inf 89.1%
Final simplification88.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b)) (t_1 (* (/ b a) 2.0)))
(if (<= b -2.3e-69)
(if (>= b 0.0) (* -0.5 t_1) t_0)
(if (<= b 1e-296)
(if (>= b 0.0)
(* -0.5 (/ (* c -2.0) b))
(/ (* 2.0 c) (- (sqrt (* c (* a -4.0))) b)))
(if (>= b 0.0) (* -0.5 (+ (* -2.0 (/ c b)) t_1)) t_0)))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = (b / a) * 2.0;
double tmp_1;
if (b <= -2.3e-69) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_1;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= 1e-296) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((c * -2.0) / b);
} else {
tmp_3 = (2.0 * c) / (sqrt((c * (a * -4.0))) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = -c / b
t_1 = (b / a) * 2.0d0
if (b <= (-2.3d-69)) then
if (b >= 0.0d0) then
tmp_2 = (-0.5d0) * t_1
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b <= 1d-296) then
if (b >= 0.0d0) then
tmp_3 = (-0.5d0) * ((c * (-2.0d0)) / b)
else
tmp_3 = (2.0d0 * c) / (sqrt((c * (a * (-4.0d0)))) - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * (((-2.0d0) * (c / b)) + t_1)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = (b / a) * 2.0;
double tmp_1;
if (b <= -2.3e-69) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * t_1;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= 1e-296) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -0.5 * ((c * -2.0) / b);
} else {
tmp_3 = (2.0 * c) / (Math.sqrt((c * (a * -4.0))) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -c / b t_1 = (b / a) * 2.0 tmp_1 = 0 if b <= -2.3e-69: tmp_2 = 0 if b >= 0.0: tmp_2 = -0.5 * t_1 else: tmp_2 = t_0 tmp_1 = tmp_2 elif b <= 1e-296: tmp_3 = 0 if b >= 0.0: tmp_3 = -0.5 * ((c * -2.0) / b) else: tmp_3 = (2.0 * c) / (math.sqrt((c * (a * -4.0))) - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -0.5 * ((-2.0 * (c / b)) + t_1) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = Float64(Float64(b / a) * 2.0) tmp_1 = 0.0 if (b <= -2.3e-69) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * t_1); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= 1e-296) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-0.5 * Float64(Float64(c * -2.0) / b)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(sqrt(Float64(c * Float64(a * -4.0))) - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + t_1)); else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = -c / b; t_1 = (b / a) * 2.0; tmp_2 = 0.0; if (b <= -2.3e-69) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -0.5 * t_1; else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b <= 1e-296) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -0.5 * ((c * -2.0) / b); else tmp_4 = (2.0 * c) / (sqrt((c * (a * -4.0))) - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -0.5 * ((-2.0 * (c / b)) + t_1); else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[b, -2.3e-69], If[GreaterEqual[b, 0.0], N[(-0.5 * t$95$1), $MachinePrecision], t$95$0], If[LessEqual[b, 1e-296], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(c * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := \frac{b}{a} \cdot 2\\
\mathbf{if}\;b \leq -2.3 \cdot 10^{-69}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{-296}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{c \cdot -2}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{c \cdot \left(a \cdot -4\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -2.3000000000000001e-69Initial program 66.9%
Simplified66.9%
Taylor expanded in b around -inf 91.5%
associate-*r/91.5%
neg-mul-191.5%
Simplified91.5%
Taylor expanded in b around inf 91.5%
*-commutative91.5%
Simplified91.5%
if -2.3000000000000001e-69 < b < 1e-296Initial program 90.8%
Simplified90.9%
Taylor expanded in b around inf 88.1%
+-commutative88.1%
*-commutative88.1%
fma-def88.1%
*-lft-identity88.1%
times-frac88.1%
/-rgt-identity88.1%
Simplified88.1%
Taylor expanded in b around 0 74.0%
*-commutative74.0%
associate-*l*74.0%
Simplified74.0%
Taylor expanded in b around 0 74.0%
associate-*r/74.0%
Simplified74.0%
if 1e-296 < b Initial program 75.9%
Simplified75.9%
Taylor expanded in b around -inf 75.9%
associate-*r/75.9%
neg-mul-175.9%
Simplified75.9%
Taylor expanded in b around inf 74.5%
Final simplification80.8%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -0.5 (+ (* -2.0 (/ c b)) (* (/ b a) 2.0))) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * ((-2.0 * (c / b)) + ((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 >= 0.0d0) then
tmp = (-0.5d0) * (((-2.0d0) * (c / b)) + ((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 >= 0.0) {
tmp = -0.5 * ((-2.0 * (c / b)) + ((b / a) * 2.0));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -0.5 * ((-2.0 * (c / b)) + ((b / a) * 2.0)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + Float64(Float64(b / 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 >= 0.0) tmp = -0.5 * ((-2.0 * (c / b)) + ((b / a) * 2.0)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + \frac{b}{a} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 74.5%
Simplified74.5%
Taylor expanded in b around -inf 74.7%
associate-*r/74.7%
neg-mul-174.7%
Simplified74.7%
Taylor expanded in b around inf 73.7%
Final simplification73.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -0.5 (* (/ b a) 2.0)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * ((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 >= 0.0d0) then
tmp = (-0.5d0) * ((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 >= 0.0) {
tmp = -0.5 * ((b / a) * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -0.5 * ((b / a) * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-0.5 * Float64(Float64(b / 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 >= 0.0) tmp = -0.5 * ((b / a) * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(\frac{b}{a} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 74.5%
Simplified74.5%
Taylor expanded in b around -inf 74.7%
associate-*r/74.7%
neg-mul-174.7%
Simplified74.7%
Taylor expanded in b around inf 73.4%
*-commutative73.4%
Simplified73.4%
Final simplification73.4%
herbie shell --seed 2023274
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))