
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $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{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $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{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (* a (/ c b)) b)) (t_1 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -5e+140)
(if (>= b 0.0) (/ b a) (/ b (- a)))
(if (<= b 3.2e-303)
(if (>= b 0.0)
(/ 1.0 (* 2.0 (/ t_0 (* 2.0 c))))
(/ (- t_1 b) (* a 2.0)))
(if (<= b 2e+93)
(if (>= b 0.0) (/ (* c (- 2.0)) (+ b t_1)) (/ (* b -2.0) (* a 2.0)))
(if (>= b 0.0) (/ c t_0) (/ (- (+ b b)) (* a 2.0))))))))
double code(double a, double b, double c) {
double t_0 = (a * (c / b)) - b;
double t_1 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 3.2e-303) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 1.0 / (2.0 * (t_0 / (2.0 * c)));
} else {
tmp_3 = (t_1 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 2e+93) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * -2.0) / (b + t_1);
} else {
tmp_4 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c / t_0;
} else {
tmp_1 = -(b + b) / (a * 2.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 = (a * (c / b)) - b
t_1 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-5d+140)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 3.2d-303) then
if (b >= 0.0d0) then
tmp_3 = 1.0d0 / (2.0d0 * (t_0 / (2.0d0 * c)))
else
tmp_3 = (t_1 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b <= 2d+93) then
if (b >= 0.0d0) then
tmp_4 = (c * -2.0d0) / (b + t_1)
else
tmp_4 = (b * (-2.0d0)) / (a * 2.0d0)
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = c / t_0
else
tmp_1 = -(b + b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (a * (c / b)) - b;
double t_1 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 3.2e-303) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 1.0 / (2.0 * (t_0 / (2.0 * c)));
} else {
tmp_3 = (t_1 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 2e+93) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * -2.0) / (b + t_1);
} else {
tmp_4 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c / t_0;
} else {
tmp_1 = -(b + b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): t_0 = (a * (c / b)) - b t_1 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -5e+140: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 3.2e-303: tmp_3 = 0 if b >= 0.0: tmp_3 = 1.0 / (2.0 * (t_0 / (2.0 * c))) else: tmp_3 = (t_1 - b) / (a * 2.0) tmp_1 = tmp_3 elif b <= 2e+93: tmp_4 = 0 if b >= 0.0: tmp_4 = (c * -2.0) / (b + t_1) else: tmp_4 = (b * -2.0) / (a * 2.0) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = c / t_0 else: tmp_1 = -(b + b) / (a * 2.0) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(a * Float64(c / b)) - b) t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -5e+140) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 3.2e-303) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(1.0 / Float64(2.0 * Float64(t_0 / Float64(2.0 * c)))); else tmp_3 = Float64(Float64(t_1 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 2e+93) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * Float64(-2.0)) / Float64(b + t_1)); else tmp_4 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c / t_0); else tmp_1 = Float64(Float64(-Float64(b + b)) / Float64(a * 2.0)); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = (a * (c / b)) - b; t_1 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -5e+140) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 3.2e-303) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = 1.0 / (2.0 * (t_0 / (2.0 * c))); else tmp_4 = (t_1 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b <= 2e+93) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (c * -2.0) / (b + t_1); else tmp_5 = (b * -2.0) / (a * 2.0); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = c / t_0; else tmp_2 = -(b + b) / (a * 2.0); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5e+140], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 3.2e-303], If[GreaterEqual[b, 0.0], N[(1.0 / N[(2.0 * N[(t$95$0 / N[(2.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2e+93], If[GreaterEqual[b, 0.0], N[(N[(c * (-2.0)), $MachinePrecision] / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / t$95$0), $MachinePrecision], N[((-N[(b + b), $MachinePrecision]) / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \frac{c}{b} - b\\
t_1 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+140}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-303}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{2 \cdot \frac{t\_0}{2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(-2\right)}{b + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\left(b + b\right)}{a \cdot 2}\\
\end{array}
\end{array}
if b < -5.00000000000000008e140Initial program 39.9%
Taylor expanded in a around 0 39.9%
distribute-lft-out--39.9%
associate-/l*39.9%
Simplified39.9%
Taylor expanded in b around -inf 94.7%
Taylor expanded in c around inf 94.7%
Taylor expanded in b around inf 94.7%
associate-*r/94.7%
neg-mul-194.7%
Simplified94.7%
if -5.00000000000000008e140 < b < 3.19999999999999991e-303Initial program 88.5%
Taylor expanded in a around 0 88.5%
distribute-lft-out--88.5%
associate-/l*88.5%
Simplified88.5%
clear-num88.5%
inv-pow88.5%
associate-*r/88.5%
*-commutative88.5%
Applied egg-rr88.5%
unpow-188.5%
associate-/l*88.5%
associate-/l*88.5%
Simplified88.5%
if 3.19999999999999991e-303 < b < 2.00000000000000009e93Initial program 83.4%
Taylor expanded in b around -inf 83.4%
*-commutative83.4%
Simplified83.4%
if 2.00000000000000009e93 < b Initial program 50.6%
Taylor expanded in a around 0 91.4%
distribute-lft-out--91.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in b around -inf 100.0%
associate-/l*100.0%
associate-*r/91.4%
Applied egg-rr91.4%
associate-*r/91.4%
times-frac91.4%
metadata-eval91.4%
*-lft-identity91.4%
associate-/l*100.0%
Simplified100.0%
Final simplification90.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -5e+140)
(if (>= b 0.0) (/ b a) (/ b (- a)))
(if (<= b 3.15e+93)
(if (>= b 0.0) (/ (* c (- 2.0)) (+ b t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0) (/ c (- (* a (/ c b)) b)) (/ (- (+ b b)) (* a 2.0)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 3.15e+93) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * -2.0) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / ((a * (c / b)) - b);
} else {
tmp_1 = -(b + b) / (a * 2.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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-5d+140)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 3.15d+93) then
if (b >= 0.0d0) then
tmp_3 = (c * -2.0d0) / (b + t_0)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = c / ((a * (c / b)) - b)
else
tmp_1 = -(b + b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 3.15e+93) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * -2.0) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / ((a * (c / b)) - b);
} else {
tmp_1 = -(b + b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -5e+140: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 3.15e+93: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * -2.0) / (b + t_0) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = c / ((a * (c / b)) - b) else: tmp_1 = -(b + b) / (a * 2.0) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -5e+140) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 3.15e+93) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * Float64(-2.0)) / Float64(b + t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(Float64(a * Float64(c / b)) - b)); else tmp_1 = Float64(Float64(-Float64(b + b)) / Float64(a * 2.0)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -5e+140) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 3.15e+93) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * -2.0) / (b + t_0); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = c / ((a * (c / b)) - b); else tmp_2 = -(b + b) / (a * 2.0); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5e+140], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 3.15e+93], If[GreaterEqual[b, 0.0], N[(N[(c * (-2.0)), $MachinePrecision] / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[((-N[(b + b), $MachinePrecision]) / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+140}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.15 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(-2\right)}{b + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{c}{b} - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\left(b + b\right)}{a \cdot 2}\\
\end{array}
\end{array}
if b < -5.00000000000000008e140Initial program 39.9%
Taylor expanded in a around 0 39.9%
distribute-lft-out--39.9%
associate-/l*39.9%
Simplified39.9%
Taylor expanded in b around -inf 94.7%
Taylor expanded in c around inf 94.7%
Taylor expanded in b around inf 94.7%
associate-*r/94.7%
neg-mul-194.7%
Simplified94.7%
if -5.00000000000000008e140 < b < 3.14999999999999993e93Initial program 86.1%
if 3.14999999999999993e93 < b Initial program 50.6%
Taylor expanded in a around 0 91.4%
distribute-lft-out--91.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in b around -inf 100.0%
associate-/l*100.0%
associate-*r/91.4%
Applied egg-rr91.4%
associate-*r/91.4%
times-frac91.4%
metadata-eval91.4%
*-lft-identity91.4%
associate-/l*100.0%
Simplified100.0%
Final simplification90.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3.4e-96)
(if (>= b 0.0) (/ b a) (/ b (- a)))
(if (<= b 4e-298)
(if (>= b 0.0)
(* c (/ -2.0 (* a (+ (* (/ c b) -2.0) (* (/ b a) 2.0)))))
(/ (- b (sqrt (* a (* c -4.0)))) (* a -2.0)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ -1.0 (* a (/ 2.0 (+ b b))))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.4e-96) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 4e-298) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (a * (((c / b) * -2.0) + ((b / a) * 2.0))));
} else {
tmp_3 = (b - sqrt((a * (c * -4.0)))) / (a * -2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp_1 = -1.0 / (a * (2.0 / (b + b)));
}
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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b <= (-3.4d-96)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 4d-298) then
if (b >= 0.0d0) then
tmp_3 = c * ((-2.0d0) / (a * (((c / b) * (-2.0d0)) + ((b / a) * 2.0d0))))
else
tmp_3 = (b - sqrt((a * (c * (-4.0d0))))) / (a * (-2.0d0))
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (2.0d0 * ((a * (c / b)) - b))
else
tmp_1 = (-1.0d0) / (a * (2.0d0 / (b + b)))
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.4e-96) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 4e-298) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (a * (((c / b) * -2.0) + ((b / a) * 2.0))));
} else {
tmp_3 = (b - Math.sqrt((a * (c * -4.0)))) / (a * -2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp_1 = -1.0 / (a * (2.0 / (b + b)));
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -3.4e-96: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 4e-298: tmp_3 = 0 if b >= 0.0: tmp_3 = c * (-2.0 / (a * (((c / b) * -2.0) + ((b / a) * 2.0)))) else: tmp_3 = (b - math.sqrt((a * (c * -4.0)))) / (a * -2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp_1 = -1.0 / (a * (2.0 / (b + b))) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.4e-96) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 4e-298) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(-2.0 / Float64(a * Float64(Float64(Float64(c / b) * -2.0) + Float64(Float64(b / a) * 2.0))))); else tmp_3 = Float64(Float64(b - sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a * -2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp_1 = Float64(-1.0 / Float64(a * Float64(2.0 / Float64(b + b)))); end return tmp_1 end
function tmp_5 = code(a, b, c) tmp_2 = 0.0; if (b <= -3.4e-96) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 4e-298) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = c * (-2.0 / (a * (((c / b) * -2.0) + ((b / a) * 2.0)))); else tmp_4 = (b - sqrt((a * (c * -4.0)))) / (a * -2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (2.0 * ((a * (c / b)) - b)); else tmp_2 = -1.0 / (a * (2.0 / (b + b))); end tmp_5 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -3.4e-96], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 4e-298], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(a * N[(N[(N[(c / b), $MachinePrecision] * -2.0), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(a * N[(2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{-96}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-298}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{a \cdot \left(\frac{c}{b} \cdot -2 + \frac{b}{a} \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot -2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{a \cdot \frac{2}{b + b}}\\
\end{array}
\end{array}
if b < -3.4000000000000001e-96Initial program 68.7%
Taylor expanded in a around 0 68.7%
distribute-lft-out--68.7%
associate-/l*68.7%
Simplified68.7%
Taylor expanded in b around -inf 83.8%
Taylor expanded in c around inf 83.8%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
neg-mul-183.8%
Simplified83.8%
if -3.4000000000000001e-96 < b < 3.99999999999999965e-298Initial program 81.2%
Simplified81.2%
Taylor expanded in c around 0 78.4%
fma-define78.4%
associate-/l*78.4%
*-commutative78.4%
Simplified78.4%
add-cube-cbrt77.8%
pow377.7%
Applied egg-rr77.7%
Taylor expanded in c around inf 73.3%
Simplified73.8%
Taylor expanded in a around inf 73.8%
if 3.99999999999999965e-298 < b Initial program 69.0%
Taylor expanded in a around 0 65.8%
distribute-lft-out--65.8%
associate-/l*69.5%
Simplified69.5%
Taylor expanded in b around -inf 69.5%
clear-num69.5%
inv-pow69.5%
*-commutative69.5%
neg-mul-169.5%
*-commutative69.5%
neg-mul-169.5%
fma-define69.5%
Applied egg-rr69.5%
Simplified69.5%
Final simplification75.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+140)
(if (>= b 0.0) (/ b a) (/ b (- a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -5e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= (-5d+140)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (2.0d0 * ((a * (c / b)) - b))
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -5e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -5e+140: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = b / -a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -5e+140) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -5e+140) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (2.0 * ((a * (c / b)) - b)); else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -5e+140], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+140}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -5.00000000000000008e140Initial program 39.9%
Taylor expanded in a around 0 39.9%
distribute-lft-out--39.9%
associate-/l*39.9%
Simplified39.9%
Taylor expanded in b around -inf 94.7%
Taylor expanded in c around inf 94.7%
Taylor expanded in b around inf 94.7%
associate-*r/94.7%
neg-mul-194.7%
Simplified94.7%
if -5.00000000000000008e140 < b Initial program 76.7%
Taylor expanded in a around 0 74.4%
distribute-lft-out--74.4%
associate-/l*76.6%
Simplified76.6%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+131)
(if (>= b 0.0) (/ b a) (/ b (- a)))
(if (>= b 0.0)
(- (/ c b))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1e+131) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -(c / b);
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= (-1d+131)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = -(c / b)
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -1e+131) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -(c / b);
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -1e+131: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = b / -a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = -(c / b) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -1e+131) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(-Float64(c / b)); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -1e+131) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = -(c / b); else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -1e+131], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], (-N[(c / b), $MachinePrecision]), N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+131}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -9.9999999999999991e130Initial program 39.9%
Taylor expanded in a around 0 39.9%
distribute-lft-out--39.9%
associate-/l*39.9%
Simplified39.9%
Taylor expanded in b around -inf 94.7%
Taylor expanded in c around inf 94.7%
Taylor expanded in b around inf 94.7%
associate-*r/94.7%
neg-mul-194.7%
Simplified94.7%
if -9.9999999999999991e130 < b Initial program 76.7%
Taylor expanded in a around 0 74.4%
distribute-lft-out--74.4%
associate-/l*76.6%
Simplified76.6%
Taylor expanded in c around 0 76.5%
associate-*r/76.5%
mul-1-neg76.5%
Simplified76.5%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -9.5e+129)
(if (>= b 0.0) (/ b a) (/ b (- a)))
(if (>= b 0.0)
(/ 1.0 (* 2.0 (/ (- (* a (/ c b)) b) (* 2.0 c))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -9.5e+129) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = 1.0 / (2.0 * (((a * (c / b)) - b) / (2.0 * c)));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= (-9.5d+129)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = 1.0d0 / (2.0d0 * (((a * (c / b)) - b) / (2.0d0 * c)))
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -9.5e+129) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = 1.0 / (2.0 * (((a * (c / b)) - b) / (2.0 * c)));
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -9.5e+129: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = b / -a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = 1.0 / (2.0 * (((a * (c / b)) - b) / (2.0 * c))) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -9.5e+129) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(1.0 / Float64(2.0 * Float64(Float64(Float64(a * Float64(c / b)) - b) / Float64(2.0 * c)))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -9.5e+129) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = 1.0 / (2.0 * (((a * (c / b)) - b) / (2.0 * c))); else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -9.5e+129], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(1.0 / N[(2.0 * N[(N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.5 \cdot 10^{+129}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{1}{2 \cdot \frac{a \cdot \frac{c}{b} - b}{2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -9.5000000000000004e129Initial program 39.9%
Taylor expanded in a around 0 39.9%
distribute-lft-out--39.9%
associate-/l*39.9%
Simplified39.9%
Taylor expanded in b around -inf 94.7%
Taylor expanded in c around inf 94.7%
Taylor expanded in b around inf 94.7%
associate-*r/94.7%
neg-mul-194.7%
Simplified94.7%
if -9.5000000000000004e129 < b Initial program 76.7%
Taylor expanded in a around 0 74.4%
distribute-lft-out--74.4%
associate-/l*76.6%
Simplified76.6%
clear-num76.1%
inv-pow76.1%
associate-*r/73.9%
*-commutative73.9%
Applied egg-rr73.9%
unpow-173.9%
associate-/l*73.9%
associate-/l*76.1%
Simplified76.1%
Final simplification79.3%
(FPCore (a b c)
:precision binary64
(if (<= b -3.4e-96)
(if (>= b 0.0) (/ b a) (/ b (- a)))
(if (>= b 0.0)
(* c (/ -2.0 (fma -2.0 (* a (/ c b)) (* b 2.0))))
(/ (- b (sqrt (* a (* c -4.0)))) (* a -2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.4e-96) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / fma(-2.0, (a * (c / b)), (b * 2.0)));
} else {
tmp_1 = (b - sqrt((a * (c * -4.0)))) / (a * -2.0);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.4e-96) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / fma(-2.0, Float64(a * Float64(c / b)), Float64(b * 2.0)))); else tmp_1 = Float64(Float64(b - sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a * -2.0)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3.4e-96], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{-96}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{\mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot -2}\\
\end{array}
\end{array}
if b < -3.4000000000000001e-96Initial program 68.7%
Taylor expanded in a around 0 68.7%
distribute-lft-out--68.7%
associate-/l*68.7%
Simplified68.7%
Taylor expanded in b around -inf 83.8%
Taylor expanded in c around inf 83.8%
Taylor expanded in b around inf 83.8%
associate-*r/83.8%
neg-mul-183.8%
Simplified83.8%
if -3.4000000000000001e-96 < b Initial program 71.6%
Simplified71.5%
Taylor expanded in c around 0 68.3%
fma-define68.3%
associate-/l*71.2%
*-commutative71.2%
Simplified71.2%
add-cube-cbrt71.1%
pow371.1%
Applied egg-rr71.1%
Taylor expanded in c around inf 70.1%
Simplified70.2%
Final simplification75.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c (- (* a (/ c b)) b)) (/ (- (+ b b)) (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / ((a * (c / b)) - b);
} else {
tmp = -(b + b) / (a * 2.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = c / ((a * (c / b)) - b)
else
tmp = -(b + b) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / ((a * (c / b)) - b);
} else {
tmp = -(b + b) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / ((a * (c / b)) - b) else: tmp = -(b + b) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(Float64(a * Float64(c / b)) - b)); else tmp = Float64(Float64(-Float64(b + b)) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / ((a * (c / b)) - b); else tmp = -(b + b) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[((-N[(b + b), $MachinePrecision]) / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{c}{b} - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\left(b + b\right)}{a \cdot 2}\\
\end{array}
\end{array}
Initial program 70.5%
Taylor expanded in a around 0 68.6%
distribute-lft-out--68.6%
associate-/l*70.4%
Simplified70.4%
Taylor expanded in b around -inf 67.0%
associate-/l*67.0%
associate-*r/65.1%
Applied egg-rr65.1%
associate-*r/65.1%
times-frac65.1%
metadata-eval65.1%
*-lft-identity65.1%
associate-/l*67.0%
Simplified67.0%
Final simplification67.0%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ b a) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} 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 >= 0.0d0) then
tmp = b / a
else
tmp = b / -a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = b / a else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(b / a); else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = b / a; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 70.5%
Taylor expanded in a around 0 68.6%
distribute-lft-out--68.6%
associate-/l*70.4%
Simplified70.4%
Taylor expanded in b around -inf 67.0%
Taylor expanded in c around inf 33.8%
Taylor expanded in b around inf 33.8%
associate-*r/33.8%
neg-mul-133.8%
Simplified33.8%
Final simplification33.8%
herbie shell --seed 2024112
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))