
(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 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) (/ (* 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 (- (/ c b) (/ b a))))
(if (<= b -1.2e+97)
(if (>= b 0.0) (/ (* 2.0 c) (- b b)) t_0)
(if (<= b -3.8e-308)
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/ (- (sqrt (fma (* c a) -4.0 (* b b))) b) (* 2.0 a)))
(if (<= b 1e+121)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* c (* a 4.0))))))
t_0)
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* c (/ a b)) b)))
(/ (- (sqrt (* b b)) b) (* 2.0 a))))))))
double code(double a, double b, double c) {
double t_0 = (c / b) - (b / a);
double tmp_1;
if (b <= -1.2e+97) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b - b);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -3.8e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (b * -2.0);
} else {
tmp_3 = (sqrt(fma((c * a), -4.0, (b * b))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 1e+121) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - sqrt(((b * b) - (c * (a * 4.0)))));
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b));
} else {
tmp_1 = (sqrt((b * b)) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(c / b) - Float64(b / a)) tmp_1 = 0.0 if (b <= -1.2e+97) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b - b)); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -3.8e-308) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_3 = Float64(Float64(sqrt(fma(Float64(c * a), -4.0, Float64(b * b))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 1e+121) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))))); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(c * Float64(a / b)) - b))); else tmp_1 = Float64(Float64(sqrt(Float64(b * b)) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.2e+97], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b - b), $MachinePrecision]), $MachinePrecision], t$95$0], If[LessEqual[b, -3.8e-308], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+121], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(b * b), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{b} - \frac{b}{a}\\
\mathbf{if}\;b \leq -1.2 \cdot 10^{+97}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b - b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \leq -3.8 \cdot 10^{-308}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+121}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(c \cdot \frac{a}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.2e97Initial program 49.3%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6495.4
Simplified95.4%
Taylor expanded in a around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6495.6
Simplified95.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6495.6
Simplified95.6%
if -1.2e97 < b < -3.79999999999999975e-308Initial program 79.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6479.2
Simplified79.2%
Taylor expanded in b around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.2
Simplified79.2%
if -3.79999999999999975e-308 < b < 1.00000000000000004e121Initial program 78.7%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6478.6
Simplified78.6%
Taylor expanded in a around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6478.7
Simplified78.7%
if 1.00000000000000004e121 < b Initial program 47.1%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.3
Simplified98.3%
Taylor expanded in b around inf
unpow2N/A
lower-*.f6498.3
Simplified98.3%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma (* c a) -4.0 (* b b)))))
(if (<= b -1.2e+97)
(if (>= b 0.0) (/ (* 2.0 c) (- b b)) (- (/ c b) (/ b a)))
(if (<= b -3.8e-308)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (- t_0 b) (* 2.0 a)))
(if (<= b 1e+121)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- (- b) b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* c (/ a b)) b)))
(/ (- (sqrt (* b b)) b) (* 2.0 a))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma((c * a), -4.0, (b * b)));
double tmp_1;
if (b <= -1.2e+97) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b - b);
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -3.8e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (b * -2.0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 1e+121) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = (-b - b) / (2.0 * a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b));
} else {
tmp_1 = (sqrt((b * b)) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(fma(Float64(c * a), -4.0, Float64(b * b))) tmp_1 = 0.0 if (b <= -1.2e+97) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b - b)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -3.8e-308) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 1e+121) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_4 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(c * Float64(a / b)) - b))); else tmp_1 = Float64(Float64(sqrt(Float64(b * b)) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.2e+97], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b - b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -3.8e-308], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+121], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(b * b), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}\\
\mathbf{if}\;b \leq -1.2 \cdot 10^{+97}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -3.8 \cdot 10^{-308}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+121}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(c \cdot \frac{a}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.2e97Initial program 49.3%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6495.4
Simplified95.4%
Taylor expanded in a around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6495.6
Simplified95.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6495.6
Simplified95.6%
if -1.2e97 < b < -3.79999999999999975e-308Initial program 79.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6479.2
Simplified79.2%
Taylor expanded in b around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.2
Simplified79.2%
if -3.79999999999999975e-308 < b < 1.00000000000000004e121Initial program 78.7%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6478.7
Simplified78.7%
Taylor expanded in b around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.7
Simplified78.7%
if 1.00000000000000004e121 < b Initial program 47.1%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.3
Simplified98.3%
Taylor expanded in b around inf
unpow2N/A
lower-*.f6498.3
Simplified98.3%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -1.2e+97)
(if (>= b 0.0) (/ (* 2.0 c) (- b b)) (- (/ c b) (/ b a)))
(if (<= b 1e+121)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* c (/ a b)) b)))
(/ (- (sqrt (* b b)) b) (* 2.0 a)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -1.2e+97) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b - b);
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 1e+121) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b));
} else {
tmp_1 = (sqrt((b * b)) - b) / (2.0 * a);
}
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 <= (-1.2d+97)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (b - b)
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 1d+121) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (2.0d0 * ((c * (a / b)) - b))
else
tmp_1 = (sqrt((b * b)) - b) / (2.0d0 * a)
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 <= -1.2e+97) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b - b);
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 1e+121) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b));
} else {
tmp_1 = (Math.sqrt((b * b)) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -1.2e+97: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (b - b) else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 1e+121: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (-b - t_0) else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b)) else: tmp_1 = (math.sqrt((b * b)) - b) / (2.0 * a) 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 <= -1.2e+97) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b - b)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 1e+121) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(c * Float64(a / b)) - b))); else tmp_1 = Float64(Float64(sqrt(Float64(b * b)) - b) / Float64(2.0 * a)); 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 <= -1.2e+97) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (b - b); else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 1e+121) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (-b - t_0); else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (2.0 * ((c * (a / b)) - b)); else tmp_2 = (sqrt((b * b)) - b) / (2.0 * a); 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, -1.2e+97], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b - b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+121], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(b * b), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $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 -1.2 \cdot 10^{+97}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+121}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(c \cdot \frac{a}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.2e97Initial program 49.3%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6495.4
Simplified95.4%
Taylor expanded in a around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6495.6
Simplified95.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6495.6
Simplified95.6%
if -1.2e97 < b < 1.00000000000000004e121Initial program 79.0%
if 1.00000000000000004e121 < b Initial program 47.1%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.3
Simplified98.3%
Taylor expanded in b around inf
unpow2N/A
lower-*.f6498.3
Simplified98.3%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.2e+97)
(if (>= b 0.0) (/ (* 2.0 c) (- b b)) (- (/ c b) (/ b a)))
(if (<= b -3.8e-308)
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/ (- (sqrt (fma (* c a) -4.0 (* b b))) b) (* 2.0 a)))
(if (<= b 6.2e-93)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (* (* c a) -4.0))))
(/ (- (- b) b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* c (/ a b)) b)))
(/ (- (sqrt (* b b)) b) (* 2.0 a)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.2e+97) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b - b);
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -3.8e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (b * -2.0);
} else {
tmp_3 = (sqrt(fma((c * a), -4.0, (b * b))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 6.2e-93) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - sqrt(((c * a) * -4.0)));
} else {
tmp_4 = (-b - b) / (2.0 * a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b));
} else {
tmp_1 = (sqrt((b * b)) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.2e+97) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b - b)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -3.8e-308) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_3 = Float64(Float64(sqrt(fma(Float64(c * a), -4.0, Float64(b * b))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 6.2e-93) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(Float64(c * a) * -4.0)))); else tmp_4 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(c * Float64(a / b)) - b))); else tmp_1 = Float64(Float64(sqrt(Float64(b * b)) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1.2e+97], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b - b), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -3.8e-308], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6.2e-93], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(b * b), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{+97}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -3.8 \cdot 10^{-308}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(c \cdot a\right) \cdot -4}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(c \cdot \frac{a}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.2e97Initial program 49.3%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6495.4
Simplified95.4%
Taylor expanded in a around inf
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6495.6
Simplified95.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6495.6
Simplified95.6%
if -1.2e97 < b < -3.79999999999999975e-308Initial program 79.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6479.2
Simplified79.2%
Taylor expanded in b around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.2
Simplified79.2%
if -3.79999999999999975e-308 < b < 6.19999999999999999e-93Initial program 71.1%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6471.1
Simplified71.1%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6463.7
Simplified63.7%
if 6.19999999999999999e-93 < b Initial program 63.0%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6485.0
Simplified85.0%
Taylor expanded in b around inf
unpow2N/A
lower-*.f6485.0
Simplified85.0%
Final simplification82.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* (* c a) -4.0))))
(if (<= b -4.1e-36)
(if (>= b 0.0) (/ b a) (/ (* b -2.0) (* 2.0 a)))
(if (<= b -3.8e-308)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (- t_0 b) (* 2.0 a)))
(if (<= b 6.2e-93)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- (- b) b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* c (/ a b)) b)))
(/ (- (sqrt (* b b)) b) (* 2.0 a))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((c * a) * -4.0));
double tmp_1;
if (b <= -4.1e-36) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -3.8e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (b * -2.0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 6.2e-93) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = (-b - b) / (2.0 * a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b));
} else {
tmp_1 = (sqrt((b * b)) - b) / (2.0 * a);
}
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
real(8) :: tmp_4
t_0 = sqrt(((c * a) * (-4.0d0)))
if (b <= (-4.1d-36)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= (-3.8d-308)) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b <= 6.2d-93) then
if (b >= 0.0d0) then
tmp_4 = (2.0d0 * c) / (-b - t_0)
else
tmp_4 = (-b - b) / (2.0d0 * a)
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (2.0d0 * ((c * (a / b)) - b))
else
tmp_1 = (sqrt((b * b)) - b) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((c * a) * -4.0));
double tmp_1;
if (b <= -4.1e-36) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -3.8e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (b * -2.0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 6.2e-93) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = (-b - b) / (2.0 * a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b));
} else {
tmp_1 = (Math.sqrt((b * b)) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((c * a) * -4.0)) tmp_1 = 0 if b <= -4.1e-36: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b <= -3.8e-308: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (b * -2.0) else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b <= 6.2e-93: tmp_4 = 0 if b >= 0.0: tmp_4 = (2.0 * c) / (-b - t_0) else: tmp_4 = (-b - b) / (2.0 * a) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (2.0 * c) / (2.0 * ((c * (a / b)) - b)) else: tmp_1 = (math.sqrt((b * b)) - b) / (2.0 * a) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(c * a) * -4.0)) tmp_1 = 0.0 if (b <= -4.1e-36) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= -3.8e-308) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 6.2e-93) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_4 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(c * Float64(a / b)) - b))); else tmp_1 = Float64(Float64(sqrt(Float64(b * b)) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = sqrt(((c * a) * -4.0)); tmp_2 = 0.0; if (b <= -4.1e-36) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= -3.8e-308) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (b * -2.0); else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b <= 6.2e-93) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (2.0 * c) / (-b - t_0); else tmp_5 = (-b - b) / (2.0 * a); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (2.0 * ((c * (a / b)) - b)); else tmp_2 = (sqrt((b * b)) - b) / (2.0 * a); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.1e-36], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -3.8e-308], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6.2e-93], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(b * b), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left(c \cdot a\right) \cdot -4}\\
\mathbf{if}\;b \leq -4.1 \cdot 10^{-36}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -3.8 \cdot 10^{-308}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(c \cdot \frac{a}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -4.10000000000000013e-36Initial program 70.2%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6479.9
Simplified79.9%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.9
Simplified79.9%
Taylor expanded in c around inf
lower-/.f6479.9
Simplified79.9%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f6479.9
Simplified79.9%
if -4.10000000000000013e-36 < b < -3.79999999999999975e-308Initial program 67.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.0
Simplified67.0%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6458.6
Simplified58.6%
if -3.79999999999999975e-308 < b < 6.19999999999999999e-93Initial program 71.1%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6471.1
Simplified71.1%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6463.7
Simplified63.7%
if 6.19999999999999999e-93 < b Initial program 63.0%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6485.0
Simplified85.0%
Taylor expanded in b around inf
unpow2N/A
lower-*.f6485.0
Simplified85.0%
Final simplification76.6%
(FPCore (a b c)
:precision binary64
(if (<= b -4.1e-36)
(if (>= b 0.0) (/ b a) (/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/ (- (sqrt (* (* c a) -4.0)) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -4.1e-36) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = (sqrt(((c * a) * -4.0)) - b) / (2.0 * a);
}
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 <= (-4.1d-36)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_1 = (sqrt(((c * a) * (-4.0d0))) - b) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -4.1e-36) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = (Math.sqrt(((c * a) * -4.0)) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -4.1e-36: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / (b * -2.0) else: tmp_1 = (math.sqrt(((c * a) * -4.0)) - b) / (2.0 * a) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -4.1e-36) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(c * a) * -4.0)) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -4.1e-36) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (b * -2.0); else tmp_2 = (sqrt(((c * a) * -4.0)) - b) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -4.1e-36], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{-36}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -4.10000000000000013e-36Initial program 70.2%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6479.9
Simplified79.9%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6479.9
Simplified79.9%
Taylor expanded in c around inf
lower-/.f6479.9
Simplified79.9%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f6479.9
Simplified79.9%
if -4.10000000000000013e-36 < b Initial program 65.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6466.3
Simplified66.3%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6464.4
Simplified64.4%
Final simplification70.0%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (* b -2.0) (* 2.0 a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (b * -2.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) :: tmp
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = (b * (-2.0d0)) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (b * -2.0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = (b * -2.0) / (2.0 * a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (b * -2.0); else tmp = (b * -2.0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 67.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.7
Simplified67.7%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6464.5
Simplified64.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ b a) (/ (* b -2.0) (* 2.0 a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = (b * -2.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) :: tmp
if (b >= 0.0d0) then
tmp = b / a
else
tmp = (b * (-2.0d0)) / (2.0d0 * 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 * -2.0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = b / a else: tmp = (b * -2.0) / (2.0 * a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(b / a); else tmp = Float64(Float64(b * -2.0) / Float64(2.0 * 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 * -2.0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 67.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6464.0
Simplified64.0%
Taylor expanded in a around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6462.3
Simplified62.3%
Taylor expanded in c around inf
lower-/.f6433.9
Simplified33.9%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f6433.9
Simplified33.9%
herbie shell --seed 2024215
(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))))