
(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 (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0))))
(if (<= b -1e+27)
(if (>= b 0.0)
t_1
(/
(- (fabs (* b (sqrt (fma a (* -4.0 (/ (/ c b) b)) 1.0)))) b)
(* 2.0 a)))
(if (<= b 9e+124)
(if (>= b 0.0) t_1 (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (fma (/ c b) (* a -2.0) b)))
(/ (fma a (/ (* c c) (* b b)) c) (- b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -1e+27) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (fabs((b * sqrt(fma(a, (-4.0 * ((c / b) / b)), 1.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 9e+124) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - fma((c / b), (a * -2.0), b));
} else {
tmp_1 = fma(a, ((c * c) / (b * b)), c) / -b;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) tmp_1 = 0.0 if (b <= -1e+27) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(abs(Float64(b * sqrt(fma(a, Float64(-4.0 * Float64(Float64(c / b) / b)), 1.0)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 9e+124) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; 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(Float64(-b) - fma(Float64(c / b), Float64(a * -2.0), b))); else tmp_1 = Float64(fma(a, Float64(Float64(c * c) / Float64(b * b)), c) / Float64(-b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1e+27], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(N[Abs[N[(b * N[Sqrt[N[(a * N[(-4.0 * N[(N[(c / b), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 9e+124], If[GreaterEqual[b, 0.0], t$95$1, 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[((-b) - N[(N[(c / b), $MachinePrecision] * N[(a * -2.0), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision] / (-b)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+27}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|b \cdot \sqrt{\mathsf{fma}\left(a, -4 \cdot \frac{\frac{c}{b}}{b}, 1\right)}\right| - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{+124}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(\frac{c}{b}, a \cdot -2, b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c \cdot c}{b \cdot b}, c\right)}{-b}\\
\end{array}
\end{array}
if b < -1e27Initial program 57.5%
Taylor expanded in b around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6457.5
Simplified57.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-sqrt-squareN/A
lower-fabs.f6457.5
lift-sqrt.f64N/A
lift-*.f64N/A
Applied egg-rr97.1%
associate-/r*N/A
lift-/.f64N/A
lower-/.f6498.4
Applied egg-rr98.4%
if -1e27 < b < 9.0000000000000008e124Initial program 80.5%
if 9.0000000000000008e124 < b Initial program 45.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64100.0
Simplified100.0%
Taylor expanded in b around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Simplified100.0%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0))))
(if (<= b -1.5e-13)
(if (>= b 0.0)
t_1
(/
(- (fabs (* b (sqrt (fma a (* -4.0 (/ c (* b b))) 1.0)))) b)
(* 2.0 a)))
(if (<= b 3e+125)
(if (>= b 0.0) t_1 (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (fma (/ c b) (* a -2.0) b)))
(/ (fma a (/ (* c c) (* b b)) c) (- b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -1.5e-13) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (fabs((b * sqrt(fma(a, (-4.0 * (c / (b * b))), 1.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 3e+125) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - fma((c / b), (a * -2.0), b));
} else {
tmp_1 = fma(a, ((c * c) / (b * b)), c) / -b;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) tmp_1 = 0.0 if (b <= -1.5e-13) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(abs(Float64(b * sqrt(fma(a, Float64(-4.0 * Float64(c / Float64(b * b))), 1.0)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 3e+125) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; 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(Float64(-b) - fma(Float64(c / b), Float64(a * -2.0), b))); else tmp_1 = Float64(fma(a, Float64(Float64(c * c) / Float64(b * b)), c) / Float64(-b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.5e-13], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(N[Abs[N[(b * N[Sqrt[N[(a * N[(-4.0 * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3e+125], If[GreaterEqual[b, 0.0], t$95$1, 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[((-b) - N[(N[(c / b), $MachinePrecision] * N[(a * -2.0), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision] / (-b)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{if}\;b \leq -1.5 \cdot 10^{-13}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|b \cdot \sqrt{\mathsf{fma}\left(a, -4 \cdot \frac{c}{b \cdot b}, 1\right)}\right| - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{+125}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(\frac{c}{b}, a \cdot -2, b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c \cdot c}{b \cdot b}, c\right)}{-b}\\
\end{array}
\end{array}
if b < -1.49999999999999992e-13Initial program 60.0%
Taylor expanded in b around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6460.1
Simplified60.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-sqrt-squareN/A
lower-fabs.f6460.1
lift-sqrt.f64N/A
lift-*.f64N/A
Applied egg-rr94.8%
if -1.49999999999999992e-13 < b < 3.00000000000000015e125Initial program 80.6%
if 3.00000000000000015e125 < b Initial program 45.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64100.0
Simplified100.0%
Taylor expanded in b around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Simplified100.0%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (<= b -2e+61)
(if (>= b 0.0) (* (/ 2.0 b) (* c -0.5)) (/ (* b -2.0) (* 2.0 a)))
(if (<= b -9.4e-291)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (- t_0 b) (* 2.0 a)))
(if (<= b 9.5e+124)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- (- b) b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (fma (/ c b) (* a -2.0) b)))
(/ (fma a (/ (* c c) (* b b)) c) (- b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if (b <= -2e+61) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 / b) * (c * -0.5);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -9.4e-291) {
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 <= 9.5e+124) {
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) / (-b - fma((c / b), (a * -2.0), b));
} else {
tmp_1 = fma(a, ((c * c) / (b * b)), c) / -b;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) tmp_1 = 0.0 if (b <= -2e+61) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 / b) * Float64(c * -0.5)); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= -9.4e-291) 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 <= 9.5e+124) 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(Float64(-b) - fma(Float64(c / b), Float64(a * -2.0), b))); else tmp_1 = Float64(fma(a, Float64(Float64(c * c) / Float64(b * b)), c) / Float64(-b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2e+61], If[GreaterEqual[b, 0.0], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -9.4e-291], 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, 9.5e+124], 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[((-b) - N[(N[(c / b), $MachinePrecision] * N[(a * -2.0), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision] / (-b)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+61}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -9.4 \cdot 10^{-291}:\\
\;\;\;\;\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 9.5 \cdot 10^{+124}:\\
\;\;\;\;\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}{\left(-b\right) - \mathsf{fma}\left(\frac{c}{b}, a \cdot -2, b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c \cdot c}{b \cdot b}, c\right)}{-b}\\
\end{array}
\end{array}
if b < -1.9999999999999999e61Initial program 51.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6451.6
Simplified51.6%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6494.9
Simplified94.9%
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval94.9
Applied egg-rr94.9%
if -1.9999999999999999e61 < b < -9.3999999999999997e-291Initial program 80.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6480.2
Simplified80.2%
if -9.3999999999999997e-291 < b < 9.50000000000000004e124Initial program 82.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f6482.0
Simplified82.0%
if 9.50000000000000004e124 < b Initial program 45.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64100.0
Simplified100.0%
Taylor expanded in b around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Simplified100.0%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (<= b -1.25e+63)
(if (>= b 0.0) (* (/ 2.0 b) (* c -0.5)) (/ (* b -2.0) (* 2.0 a)))
(if (<= b 1e+124)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (fma (/ c b) (* a -2.0) b)))
(/ (fma a (/ (* c c) (* b b)) c) (- b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if (b <= -1.25e+63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 / b) * (c * -0.5);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1e+124) {
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) / (-b - fma((c / b), (a * -2.0), b));
} else {
tmp_1 = fma(a, ((c * c) / (b * b)), c) / -b;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) tmp_1 = 0.0 if (b <= -1.25e+63) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 / b) * Float64(c * -0.5)); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 1e+124) 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(Float64(-b) - fma(Float64(c / b), Float64(a * -2.0), b))); else tmp_1 = Float64(fma(a, Float64(Float64(c * c) / Float64(b * b)), c) / Float64(-b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.25e+63], If[GreaterEqual[b, 0.0], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+124], 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[((-b) - N[(N[(c / b), $MachinePrecision] * N[(a * -2.0), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision] / (-b)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -1.25 \cdot 10^{+63}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+124}:\\
\;\;\;\;\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}{\left(-b\right) - \mathsf{fma}\left(\frac{c}{b}, a \cdot -2, b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c \cdot c}{b \cdot b}, c\right)}{-b}\\
\end{array}
\end{array}
if b < -1.25000000000000003e63Initial program 51.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6451.6
Simplified51.6%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6494.9
Simplified94.9%
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval94.9
Applied egg-rr94.9%
if -1.25000000000000003e63 < b < 9.99999999999999948e123Initial program 81.1%
if 9.99999999999999948e123 < b Initial program 45.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64100.0
Simplified100.0%
Taylor expanded in b around inf
distribute-lft-outN/A
associate-*r/N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Simplified100.0%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -7.2e+44)
(if (>= b 0.0) (* (/ 2.0 b) (* c -0.5)) (/ (* b -2.0) (* 2.0 a)))
(if (<= b -9.2e-130)
(if (>= b 0.0)
(/ b a)
(* (/ 0.5 a) (- (sqrt (fma c (* a -4.0) (* b b))) b)))
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/ (- (sqrt (* -4.0 (* c a))) b) (* 2.0 a))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -7.2e+44) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 / b) * (c * -0.5);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -9.2e-130) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = (0.5 / a) * (sqrt(fma(c, (a * -4.0), (b * b))) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = (sqrt((-4.0 * (c * a))) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -7.2e+44) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 / b) * Float64(c * -0.5)); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= -9.2e-130) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(b / a); else tmp_3 = Float64(Float64(0.5 / a) * Float64(sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_1 = Float64(Float64(sqrt(Float64(-4.0 * Float64(c * a))) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -7.2e+44], If[GreaterEqual[b, 0.0], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -9.2e-130], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.2 \cdot 10^{+44}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -9.2 \cdot 10^{-130}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -7.2e44Initial program 54.1%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6454.1
Simplified54.1%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6495.2
Simplified95.2%
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval95.2
Applied egg-rr95.2%
if -7.2e44 < b < -9.2000000000000005e-130Initial program 89.1%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6489.1
Simplified89.1%
Applied egg-rr88.9%
Taylor expanded in c around inf
lower-/.f6488.9
Simplified88.9%
if -9.2000000000000005e-130 < b Initial program 67.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6466.8
Simplified66.8%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Simplified66.8%
Final simplification76.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e+61)
(if (>= b 0.0) (* (/ 2.0 b) (* c -0.5)) (/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2.4e+61) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 / b) * (c * -0.5);
} 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(((b * b) - (c * (4.0 * a)))) - 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 <= (-2.4d+61)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 / b) * (c * (-0.5d0))
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(((b * b) - (c * (4.0d0 * a)))) - 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 <= -2.4e+61) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 / b) * (c * -0.5);
} 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(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -2.4e+61: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 / b) * (c * -0.5) 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(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -2.4e+61) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 / b) * Float64(c * -0.5)); 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(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -2.4e+61) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 / b) * (c * -0.5); 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(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e+61], If[GreaterEqual[b, 0.0], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $MachinePrecision]), $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[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{+61}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\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{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -2.3999999999999999e61Initial program 51.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6451.6
Simplified51.6%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6494.9
Simplified94.9%
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval94.9
Applied egg-rr94.9%
if -2.3999999999999999e61 < b Initial program 71.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6471.3
Simplified71.3%
Final simplification76.4%
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e+43)
(if (>= b 0.0) (* (/ 2.0 b) (* c -0.5)) (/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (fma c (/ (* a -2.0) b) b)))
(* (/ 0.5 a) (- (sqrt (fma c (* a -4.0) (* b b))) b)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.5e+43) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 / b) * (c * -0.5);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - fma(c, ((a * -2.0) / b), b));
} else {
tmp_1 = (0.5 / a) * (sqrt(fma(c, (a * -4.0), (b * b))) - b);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.5e+43) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 / b) * Float64(c * -0.5)); 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(Float64(-b) - fma(c, Float64(Float64(a * -2.0) / b), b))); else tmp_1 = Float64(Float64(0.5 / a) * Float64(sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) - b)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3.5e+43], If[GreaterEqual[b, 0.0], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $MachinePrecision]), $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) - N[(c * N[(N[(a * -2.0), $MachinePrecision] / b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{+43}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(c, \frac{a \cdot -2}{b}, b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b\right)\\
\end{array}
\end{array}
if b < -3.5000000000000001e43Initial program 54.1%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6454.1
Simplified54.1%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6495.2
Simplified95.2%
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval95.2
Applied egg-rr95.2%
if -3.5000000000000001e43 < b Initial program 71.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6470.8
Simplified70.8%
Applied egg-rr70.8%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6470.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
Applied egg-rr70.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2.0 c) (* b -2.0))))
(if (<= b -7.8e-28)
(if (>= b 0.0) t_0 (* b (+ (/ c (* b b)) (/ -1.0 a))))
(if (>= b 0.0) t_0 (/ (- (sqrt (* -4.0 (* c a))) b) (* 2.0 a))))))
double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -7.8e-28) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = b * ((c / (b * b)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (sqrt((-4.0 * (c * a))) - 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
t_0 = (2.0d0 * c) / (b * (-2.0d0))
if (b <= (-7.8d-28)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = b * ((c / (b * b)) + ((-1.0d0) / a))
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (sqrt(((-4.0d0) * (c * a))) - b) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -7.8e-28) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = b * ((c / (b * b)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (Math.sqrt((-4.0 * (c * a))) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): t_0 = (2.0 * c) / (b * -2.0) tmp_1 = 0 if b <= -7.8e-28: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = b * ((c / (b * b)) + (-1.0 / a)) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = (math.sqrt((-4.0 * (c * a))) - b) / (2.0 * a) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) tmp_1 = 0.0 if (b <= -7.8e-28) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; 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 = t_0; else tmp_1 = Float64(Float64(sqrt(Float64(-4.0 * Float64(c * a))) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (2.0 * c) / (b * -2.0); tmp_2 = 0.0; if (b <= -7.8e-28) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = b * ((c / (b * b)) + (-1.0 / a)); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = (sqrt((-4.0 * (c * a))) - b) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -7.8e-28], If[GreaterEqual[b, 0.0], t$95$0, N[(b * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot c}{b \cdot -2}\\
\mathbf{if}\;b \leq -7.8 \cdot 10^{-28}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{b \cdot b} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -7.79999999999999998e-28Initial program 62.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6462.6
Simplified62.6%
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-*.f6486.7
Simplified86.7%
if -7.79999999999999998e-28 < b Initial program 69.7%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6469.1
Simplified69.1%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.3
Simplified66.3%
Final simplification72.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (* -2.0 (/ b (* 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 = -2.0 * (b / (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 = (-2.0d0) * (b / (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 = -2.0 * (b / (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 = -2.0 * (b / (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(-2.0 * Float64(b / 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 = -2.0 * (b / (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[(-2.0 * N[(b / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 67.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.1
Simplified67.1%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6464.8
Simplified64.8%
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6464.8
Applied egg-rr64.8%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* (/ 2.0 b) (* c -0.5)) (/ (* b -2.0) (* 2.0 a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 / b) * (c * -0.5);
} 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 / b) * (c * (-0.5d0))
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 / b) * (c * -0.5);
} else {
tmp = (b * -2.0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 / b) * (c * -0.5) 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 / b) * Float64(c * -0.5)); 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 / b) * (c * -0.5); 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 / b), $MachinePrecision] * N[(c * -0.5), $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}{b} \cdot \left(c \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 67.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f6467.1
Simplified67.1%
Taylor expanded in b around -inf
*-commutativeN/A
lower-*.f6464.8
Simplified64.8%
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval64.7
Applied egg-rr64.7%
herbie shell --seed 2024207
(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))))