
(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 10 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 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -1e+151)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- a)))
(if (<= b 1e+100)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) t_1)
(if (>= b 0.0)
(/ (* 2.0 c) (* b (fma 2.0 (* a (/ c (* b b))) -2.0)))
t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 1e+100) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = t_1;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * fma(2.0, (a * (c / (b * b))), -2.0));
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -1e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 1e+100) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_3 = t_1; end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * fma(2.0, Float64(a * Float64(c / Float64(b * b))), -2.0))); else tmp_1 = t_1; end return tmp_1 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]}, Block[{t$95$1 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1e+151], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 1e+100], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * N[(2.0 * N[(a * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot \mathsf{fma}\left(2, a \cdot \frac{c}{b \cdot b}, -2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 35.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6497.8
Applied rewrites97.8%
if -1.00000000000000002e151 < b < 1.00000000000000002e100Initial program 86.0%
if 1.00000000000000002e100 < b Initial program 56.9%
Taylor expanded in b around inf
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6493.7
Applied rewrites93.7%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a))))
(if (<= b -1e+151)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- a)))
(if (<= b 2.5e+100)
(if (>= b 0.0)
(* c (/ 2.0 (- (- b) (sqrt (fma c (* a -4.0) (* b b))))))
t_0)
(if (>= b 0.0)
(/ (* 2.0 c) (* b (fma 2.0 (* a (/ c (* b b))) -2.0)))
t_0)))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 2.5e+100) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (2.0 / (-b - sqrt(fma(c, (a * -4.0), (b * b)))));
} else {
tmp_3 = t_0;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * fma(2.0, (a * (c / (b * b))), -2.0));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -1e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 2.5e+100) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(2.0 / Float64(Float64(-b) - sqrt(fma(c, Float64(a * -4.0), Float64(b * b)))))); else tmp_3 = t_0; end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * fma(2.0, Float64(a * Float64(c / Float64(b * b))), -2.0))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1e+151], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 2.5e+100], If[GreaterEqual[b, 0.0], N[(c * N[(2.0 / N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * N[(2.0 * N[(a * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot \mathsf{fma}\left(2, a \cdot \frac{c}{b \cdot b}, -2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 35.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6497.8
Applied rewrites97.8%
if -1.00000000000000002e151 < b < 2.4999999999999999e100Initial program 86.0%
Applied rewrites85.9%
if 2.4999999999999999e100 < b Initial program 56.9%
Taylor expanded in b around inf
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6493.7
Applied rewrites93.7%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+151)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- a)))
(if (<= b -5e-310)
(if (>= b 0.0)
(* c (fma (- a) (/ c (* b (* b b))) (/ -1.0 b)))
(/ (- (sqrt (fma c (* a -4.0) (* b b))) b) (* 2.0 a)))
(if (<= b 1.02e-109)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (* -4.0 (* c a)))))
(* b (+ (/ c (* b b)) (/ -1.0 a))))
(if (>= b 0.0) (/ c (- b)) (/ c b))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= -5e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * fma(-a, (c / (b * (b * b))), (-1.0 / b));
} else {
tmp_3 = (sqrt(fma(c, (a * -4.0), (b * b))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 1.02e-109) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
} else {
tmp_4 = b * ((c / (b * b)) + (-1.0 / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= -5e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * fma(Float64(-a), Float64(c / Float64(b * Float64(b * b))), Float64(-1.0 / b))); else tmp_3 = Float64(Float64(sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 1.02e-109) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_4 = Float64(b * Float64(Float64(c / Float64(b * b)) + Float64(-1.0 / a))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(c / b); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1e+151], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, -5e-310], If[GreaterEqual[b, 0.0], N[(c * N[((-a) * N[(c / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.02e-109], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(c / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \mathsf{fma}\left(-a, \frac{c}{b \cdot \left(b \cdot b\right)}, \frac{-1}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-109}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{b \cdot b} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 35.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6497.8
Applied rewrites97.8%
if -1.00000000000000002e151 < b < -4.999999999999985e-310Initial program 85.2%
Taylor expanded in c around 0
lower-*.f64N/A
sub-negN/A
associate-/l*N/A
associate-*r*N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6485.2
Applied rewrites85.2%
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
Applied rewrites85.2%
if -4.999999999999985e-310 < b < 1.02e-109Initial program 80.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6480.0
Applied rewrites80.0%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.6
Applied rewrites70.6%
if 1.02e-109 < b Initial program 71.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6471.3
Applied rewrites71.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
Taylor expanded in b around 0
lower-/.f6484.7
Applied rewrites84.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3.85e+148)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- a)))
(if (<= b -5e-310)
(if (>= b 0.0)
(* c (fma (- a) (/ c (* b (* b b))) (/ -1.0 b)))
(* (- (sqrt (fma c (* a -4.0) (* b b))) b) (/ 0.5 a)))
(if (<= b 1.02e-109)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (* -4.0 (* c a)))))
(* b (+ (/ c (* b b)) (/ -1.0 a))))
(if (>= b 0.0) (/ c (- b)) (/ c b))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.85e+148) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= -5e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * fma(-a, (c / (b * (b * b))), (-1.0 / b));
} else {
tmp_3 = (sqrt(fma(c, (a * -4.0), (b * b))) - b) * (0.5 / a);
}
tmp_1 = tmp_3;
} else if (b <= 1.02e-109) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
} else {
tmp_4 = b * ((c / (b * b)) + (-1.0 / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.85e+148) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= -5e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * fma(Float64(-a), Float64(c / Float64(b * Float64(b * b))), Float64(-1.0 / b))); else tmp_3 = Float64(Float64(sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) - b) * Float64(0.5 / a)); end tmp_1 = tmp_3; elseif (b <= 1.02e-109) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_4 = Float64(b * Float64(Float64(c / Float64(b * b)) + Float64(-1.0 / a))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(c / b); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3.85e+148], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, -5e-310], If[GreaterEqual[b, 0.0], N[(c * N[((-a) * N[(c / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.02e-109], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(c / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.85 \cdot 10^{+148}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \mathsf{fma}\left(-a, \frac{c}{b \cdot \left(b \cdot b\right)}, \frac{-1}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b\right) \cdot \frac{0.5}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-109}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{b \cdot b} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < -3.8500000000000002e148Initial program 36.9%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6497.6
Applied rewrites97.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
if -3.8500000000000002e148 < b < -4.999999999999985e-310Initial program 85.0%
Taylor expanded in c around 0
lower-*.f64N/A
sub-negN/A
associate-/l*N/A
associate-*r*N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f6485.0
Applied rewrites85.0%
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6484.9
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
Applied rewrites84.9%
if -4.999999999999985e-310 < b < 1.02e-109Initial program 80.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6480.0
Applied rewrites80.0%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.6
Applied rewrites70.6%
if 1.02e-109 < b Initial program 71.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6471.3
Applied rewrites71.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
Taylor expanded in b around 0
lower-/.f6484.7
Applied rewrites84.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+151)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- a)))
(if (<= b 7.8e+136)
(if (>= b 0.0)
(* c (/ 2.0 (- (- b) (sqrt (fma c (* a -4.0) (* b b))))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
(if (>= b 0.0) (/ c (- b)) (/ c b)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 7.8e+136) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (2.0 / (-b - sqrt(fma(c, (a * -4.0), (b * b)))));
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 7.8e+136) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(2.0 / Float64(Float64(-b) - sqrt(fma(c, Float64(a * -4.0), Float64(b * b)))))); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(c / b); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1e+151], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 7.8e+136], If[GreaterEqual[b, 0.0], N[(c * N[(2.0 / N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $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[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(c / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{+136}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 35.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6497.8
Applied rewrites97.8%
if -1.00000000000000002e151 < b < 7.80000000000000038e136Initial program 86.3%
Applied rewrites86.2%
if 7.80000000000000038e136 < b Initial program 49.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6449.0
Applied rewrites49.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6494.2
Applied rewrites94.2%
Taylor expanded in b around 0
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6494.2
Applied rewrites94.2%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma c (* a -4.0) (* b b)))))
(if (<= b -3.85e+148)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- a)))
(if (<= b 7.8e+136)
(if (>= b 0.0) (* c (/ 2.0 (- (- b) t_0))) (* (/ -0.5 a) (- b t_0)))
(if (>= b 0.0) (/ c (- b)) (/ c b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma(c, (a * -4.0), (b * b)));
double tmp_1;
if (b <= -3.85e+148) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 7.8e+136) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (2.0 / (-b - t_0));
} else {
tmp_3 = (-0.5 / a) * (b - t_0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) tmp_1 = 0.0 if (b <= -3.85e+148) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 7.8e+136) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(2.0 / Float64(Float64(-b) - t_0))); else tmp_3 = Float64(Float64(-0.5 / a) * Float64(b - t_0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(c / b); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -3.85e+148], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 7.8e+136], If[GreaterEqual[b, 0.0], N[(c * N[(2.0 / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(c / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\\
\mathbf{if}\;b \leq -3.85 \cdot 10^{+148}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{+136}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - t\_0\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < -3.8500000000000002e148Initial program 36.9%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6497.6
Applied rewrites97.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
if -3.8500000000000002e148 < b < 7.80000000000000038e136Initial program 86.2%
Applied rewrites86.2%
*-commutativeN/A
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6486.1
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
Applied rewrites86.1%
if 7.80000000000000038e136 < b Initial program 49.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6449.0
Applied rewrites49.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6494.2
Applied rewrites94.2%
Taylor expanded in b around 0
lower-/.f6494.2
Applied rewrites94.2%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6494.2
Applied rewrites94.2%
Final simplification89.6%
(FPCore (a b c)
:precision binary64
(if (<= b 1.02e-109)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (* -4.0 (* c a)))))
(* b (+ (/ c (* b b)) (/ -1.0 a))))
(if (>= b 0.0) (/ c (- b)) (/ c b))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.02e-109) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
} else {
tmp_2 = b * ((c / (b * b)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / 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
if (b <= 1.02d-109) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - sqrt(((-4.0d0) * (c * a))))
else
tmp_2 = b * ((c / (b * b)) + ((-1.0d0) / a))
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = c / -b
else
tmp_1 = c / b
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.02e-109) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - Math.sqrt((-4.0 * (c * a))));
} else {
tmp_2 = b * ((c / (b * b)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 1.02e-109: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - math.sqrt((-4.0 * (c * a)))) else: tmp_2 = b * ((c / (b * b)) + (-1.0 / a)) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = c / -b else: tmp_1 = c / b return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 1.02e-109) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_2 = Float64(b * Float64(Float64(c / Float64(b * b)) + Float64(-1.0 / a))); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(c / b); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 1.02e-109) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a)))); else tmp_3 = b * ((c / (b * b)) + (-1.0 / a)); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = c / -b; else tmp_2 = c / b; end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 1.02e-109], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(c / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.02 \cdot 10^{-109}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{b \cdot b} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.02e-109Initial program 70.4%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6468.6
Applied rewrites68.6%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.5
Applied rewrites66.5%
if 1.02e-109 < b Initial program 71.3%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6471.3
Applied rewrites71.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6484.7
Applied rewrites84.7%
Taylor expanded in b around 0
lower-/.f6484.7
Applied rewrites84.7%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification73.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = (c / b) - (b / 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(c / b) - Float64(b / 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 = (c / b) - (b / 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[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
Initial program 70.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6469.6
Applied rewrites69.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
Taylor expanded in c around 0
lower--.f64N/A
lower-/.f64N/A
lower-/.f6468.0
Applied rewrites68.0%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- 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 / -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 / -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 / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = b / -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(b / Float64(-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 / -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[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 70.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6469.6
Applied rewrites69.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
Taylor expanded in b around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6467.6
Applied rewrites67.6%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c (- b)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} 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 = c / -b
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 = c / -b;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / -b; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
Initial program 70.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/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-*.f6469.6
Applied rewrites69.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
Taylor expanded in b around 0
lower-/.f6437.5
Applied rewrites37.5%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6437.5
Applied rewrites37.5%
herbie shell --seed 2024219
(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))))