
(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))))))
(if (<= b -4.4e+108)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) (- (/ c b) (/ b a)))
(if (<= b 2.55e+81)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0) (/ (/ c -1.0) b) (/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -4.4e+108) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.55e+81) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / -1.0) / 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) :: 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 <= (-4.4d+108)) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (b + b))
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 2.55d+81) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c / (-1.0d0)) / b
else
tmp_1 = -c / b
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 <= -4.4e+108) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.55e+81) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / -1.0) / b;
} else {
tmp_1 = -c / b;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -4.4e+108: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (b + b)) else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 2.55e+81: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) / (-b - t_0) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c / -1.0) / b else: tmp_1 = -c / b 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 <= -4.4e+108) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 2.55e+81) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / -1.0) / b); else tmp_1 = Float64(Float64(-c) / b); 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 <= -4.4e+108) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (b + b)); else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 2.55e+81) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) / (-b - t_0); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c / -1.0) / b; else tmp_2 = -c / b; 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, -4.4e+108], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.55e+81], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / -1.0), $MachinePrecision] / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -4.4 \cdot 10^{+108}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.55 \cdot 10^{+81}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\frac{c}{-1}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.4000000000000003e108Initial program 54.8%
Simplified54.9%
Taylor expanded in c around 0 54.9%
Taylor expanded in b around -inf 95.1%
+-commutative95.1%
mul-1-neg95.1%
unsub-neg95.1%
Simplified95.1%
if -4.4000000000000003e108 < b < 2.5500000000000001e81Initial program 86.4%
if 2.5500000000000001e81 < b Initial program 56.5%
Simplified56.5%
Taylor expanded in c around 0 96.2%
associate-*r/96.5%
count-296.5%
associate-/r*96.5%
associate-/l*96.5%
metadata-eval96.5%
Applied egg-rr96.5%
Taylor expanded in c around 0 96.5%
mul-1-neg96.5%
distribute-neg-frac96.5%
Simplified96.5%
Final simplification90.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -1e+104)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) (- (/ c b) (/ b a)))
(if (<= b 2.55e+81)
(if (>= b 0.0) (/ 2.0 (/ (- (- b) t_0) c)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0) (/ (/ c -1.0) b) (/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -1e+104) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.55e+81) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / ((-b - t_0) / c);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / -1.0) / 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) :: 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 <= (-1d+104)) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (b + b))
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 2.55d+81) then
if (b >= 0.0d0) then
tmp_3 = 2.0d0 / ((-b - t_0) / c)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c / (-1.0d0)) / b
else
tmp_1 = -c / b
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 <= -1e+104) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.55e+81) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / ((-b - t_0) / c);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / -1.0) / b;
} else {
tmp_1 = -c / b;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -1e+104: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (b + b)) else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 2.55e+81: tmp_3 = 0 if b >= 0.0: tmp_3 = 2.0 / ((-b - t_0) / c) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c / -1.0) / b else: tmp_1 = -c / b 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 <= -1e+104) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 2.55e+81) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(2.0 / Float64(Float64(Float64(-b) - t_0) / c)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / -1.0) / b); else tmp_1 = Float64(Float64(-c) / b); 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 <= -1e+104) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (b + b)); else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 2.55e+81) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = 2.0 / ((-b - t_0) / c); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c / -1.0) / b; else tmp_2 = -c / b; 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, -1e+104], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.55e+81], If[GreaterEqual[b, 0.0], N[(2.0 / N[(N[((-b) - t$95$0), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / -1.0), $MachinePrecision] / b), $MachinePrecision], N[((-c) / b), $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 \cdot 10^{+104}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.55 \cdot 10^{+81}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - t_0}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\frac{c}{-1}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1e104Initial program 54.8%
Simplified54.9%
Taylor expanded in c around 0 54.9%
Taylor expanded in b around -inf 95.1%
+-commutative95.1%
mul-1-neg95.1%
unsub-neg95.1%
Simplified95.1%
if -1e104 < b < 2.5500000000000001e81Initial program 86.4%
Simplified86.4%
if 2.5500000000000001e81 < b Initial program 56.5%
Simplified56.5%
Taylor expanded in c around 0 96.2%
associate-*r/96.5%
count-296.5%
associate-/r*96.5%
associate-/l*96.5%
metadata-eval96.5%
Applied egg-rr96.5%
Taylor expanded in c around 0 96.5%
mul-1-neg96.5%
distribute-neg-frac96.5%
Simplified96.5%
Final simplification90.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -1.0 (/ b a) (/ c b))))
(if (<= b -1.9e-116)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) (- (/ c b) (/ b a)))
(if (<= b -5e-310)
(if (>= b 0.0)
(/ (/ c -1.0) b)
(* (/ 0.5 a) (- (sqrt (* a (* c -4.0))) b)))
(if (<= b 5.2e-118)
(if (>= b 0.0) (/ (* c -2.0) (+ b (sqrt (* -4.0 (* c a))))) t_0)
(if (>= b 0.0)
(* c (/ -2.0 (+ b (+ b (* -2.0 (* c (/ a b)))))))
t_0))))))
double code(double a, double b, double c) {
double t_0 = fma(-1.0, (b / a), (c / b));
double tmp_1;
if (b <= -1.9e-116) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -5e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c / -1.0) / b;
} else {
tmp_3 = (0.5 / a) * (sqrt((a * (c * -4.0))) - b);
}
tmp_1 = tmp_3;
} else if (b <= 5.2e-118) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * -2.0) / (b + sqrt((-4.0 * (c * a))));
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = fma(-1.0, Float64(b / a), Float64(c / b)) tmp_1 = 0.0 if (b <= -1.9e-116) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -5e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c / -1.0) / b); else tmp_3 = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(a * Float64(c * -4.0))) - b)); end tmp_1 = tmp_3; elseif (b <= 5.2e-118) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * -2.0) / Float64(b + sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.9e-116], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-310], If[GreaterEqual[b, 0.0], N[(N[(c / -1.0), $MachinePrecision] / b), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5.2e-118], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{if}\;b \leq -1.9 \cdot 10^{-116}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{c}{-1}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-118}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -1.9000000000000001e-116Initial program 71.2%
Simplified71.2%
Taylor expanded in c around 0 71.2%
Taylor expanded in b around -inf 83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
if -1.9000000000000001e-116 < b < -4.999999999999985e-310Initial program 80.7%
Simplified80.7%
Taylor expanded in c around 0 80.7%
associate-*r/80.7%
count-280.7%
associate-/r*80.7%
associate-/l*80.7%
metadata-eval80.7%
Applied egg-rr80.7%
Taylor expanded in c around inf 80.7%
associate-*r*80.7%
*-commutative80.7%
*-commutative80.7%
*-commutative80.7%
Simplified80.7%
div-sub80.7%
sub-neg80.7%
div-inv80.4%
*-commutative80.4%
associate-*r*80.4%
*-commutative80.4%
metadata-eval80.4%
associate-/r*80.4%
metadata-eval80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
associate-/r*80.4%
metadata-eval80.4%
metadata-eval80.4%
Applied egg-rr80.4%
sub-neg80.4%
distribute-rgt-out--80.4%
associate-*r*80.4%
*-commutative80.4%
*-commutative80.4%
Simplified80.4%
if -4.999999999999985e-310 < b < 5.2e-118Initial program 75.6%
Simplified75.6%
Taylor expanded in b around -inf 75.6%
fma-def75.6%
Simplified75.6%
Applied egg-rr75.5%
Taylor expanded in b around 0 70.7%
associate-*r*70.7%
*-commutative70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
associate-*r/70.7%
+-commutative70.7%
pow-pow70.9%
metadata-eval70.9%
pow1/270.9%
*-commutative70.9%
associate-*l*70.9%
*-commutative70.9%
Applied egg-rr70.9%
if 5.2e-118 < b Initial program 71.7%
Simplified71.6%
Taylor expanded in b around -inf 71.6%
fma-def71.6%
Simplified71.6%
Applied egg-rr71.3%
Taylor expanded in c around 0 85.4%
*-commutative85.4%
associate-*r/87.7%
Simplified87.7%
Final simplification82.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -1.0 (/ b a) (/ c b))))
(if (<= b -5.2e-117)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) (- (/ c b) (/ b a)))
(if (<= b -5e-310)
(if (>= b 0.0)
(/ (/ c -1.0) b)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0)))
(if (<= b 1.3e-118)
(if (>= b 0.0) (/ (* c -2.0) (+ b (sqrt (* -4.0 (* c a))))) t_0)
(if (>= b 0.0)
(* c (/ -2.0 (+ b (+ b (* -2.0 (* c (/ a b)))))))
t_0))))))
double code(double a, double b, double c) {
double t_0 = fma(-1.0, (b / a), (c / b));
double tmp_1;
if (b <= -5.2e-117) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -5e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c / -1.0) / b;
} else {
tmp_3 = (sqrt((c * (a * -4.0))) - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 1.3e-118) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * -2.0) / (b + sqrt((-4.0 * (c * a))));
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = fma(-1.0, Float64(b / a), Float64(c / b)) tmp_1 = 0.0 if (b <= -5.2e-117) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -5e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c / -1.0) / b); else tmp_3 = Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 1.3e-118) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * -2.0) / Float64(b + sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.2e-117], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-310], If[GreaterEqual[b, 0.0], N[(N[(c / -1.0), $MachinePrecision] / b), $MachinePrecision], N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.3e-118], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{if}\;b \leq -5.2 \cdot 10^{-117}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{c}{-1}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.3 \cdot 10^{-118}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -5.19999999999999966e-117Initial program 71.2%
Simplified71.2%
Taylor expanded in c around 0 71.2%
Taylor expanded in b around -inf 83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
if -5.19999999999999966e-117 < b < -4.999999999999985e-310Initial program 80.7%
Simplified80.7%
Taylor expanded in c around 0 80.7%
associate-*r/80.7%
count-280.7%
associate-/r*80.7%
associate-/l*80.7%
metadata-eval80.7%
Applied egg-rr80.7%
Taylor expanded in c around inf 80.7%
associate-*r*80.7%
*-commutative80.7%
*-commutative80.7%
*-commutative80.7%
Simplified80.7%
if -4.999999999999985e-310 < b < 1.3e-118Initial program 75.6%
Simplified75.6%
Taylor expanded in b around -inf 75.6%
fma-def75.6%
Simplified75.6%
Applied egg-rr75.5%
Taylor expanded in b around 0 70.7%
associate-*r*70.7%
*-commutative70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
associate-*r/70.7%
+-commutative70.7%
pow-pow70.9%
metadata-eval70.9%
pow1/270.9%
*-commutative70.9%
associate-*l*70.9%
*-commutative70.9%
Applied egg-rr70.9%
if 1.3e-118 < b Initial program 71.7%
Simplified71.6%
Taylor expanded in b around -inf 71.6%
fma-def71.6%
Simplified71.6%
Applied egg-rr71.3%
Taylor expanded in c around 0 85.4%
*-commutative85.4%
associate-*r/87.7%
Simplified87.7%
Final simplification82.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -1.0 (/ b a) (/ c b))))
(if (<= b 5.2e-118)
(if (>= b 0.0) (* c (/ -2.0 (+ b (sqrt (* -4.0 (* c a)))))) t_0)
(if (>= b 0.0) (* c (/ -2.0 (+ b (+ b (* -2.0 (* c (/ a b))))))) t_0))))
double code(double a, double b, double c) {
double t_0 = fma(-1.0, (b / a), (c / b));
double tmp_1;
if (b <= 5.2e-118) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + sqrt((-4.0 * (c * a)))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = fma(-1.0, Float64(b / a), Float64(c / b)) tmp_1 = 0.0 if (b <= 5.2e-118) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + sqrt(Float64(-4.0 * Float64(c * a)))))); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 5.2e-118], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{if}\;b \leq 5.2 \cdot 10^{-118}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 5.2e-118Initial program 73.9%
Simplified74.0%
Taylor expanded in b around -inf 67.0%
fma-def67.0%
Simplified67.0%
Applied egg-rr67.0%
Taylor expanded in b around 0 66.0%
associate-*r*66.0%
*-commutative66.0%
*-commutative66.0%
*-commutative66.0%
Simplified66.0%
pow-pow66.1%
metadata-eval66.1%
pow1/266.1%
*-commutative66.1%
associate-*l*66.1%
*-commutative66.1%
Applied egg-rr66.1%
if 5.2e-118 < b Initial program 71.7%
Simplified71.6%
Taylor expanded in b around -inf 71.6%
fma-def71.6%
Simplified71.6%
Applied egg-rr71.3%
Taylor expanded in c around 0 85.4%
*-commutative85.4%
associate-*r/87.7%
Simplified87.7%
Final simplification73.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -1.0 (/ b a) (/ c b))))
(if (<= b 4.5e-118)
(if (>= b 0.0) (/ (* c -2.0) (+ b (sqrt (* -4.0 (* c a))))) t_0)
(if (>= b 0.0) (* c (/ -2.0 (+ b (+ b (* -2.0 (* c (/ a b))))))) t_0))))
double code(double a, double b, double c) {
double t_0 = fma(-1.0, (b / a), (c / b));
double tmp_1;
if (b <= 4.5e-118) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * -2.0) / (b + sqrt((-4.0 * (c * a))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = fma(-1.0, Float64(b / a), Float64(c / b)) tmp_1 = 0.0 if (b <= 4.5e-118) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c * -2.0) / Float64(b + sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 4.5e-118], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{if}\;b \leq 4.5 \cdot 10^{-118}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 4.5e-118Initial program 73.9%
Simplified74.0%
Taylor expanded in b around -inf 67.0%
fma-def67.0%
Simplified67.0%
Applied egg-rr67.0%
Taylor expanded in b around 0 66.0%
associate-*r*66.0%
*-commutative66.0%
*-commutative66.0%
*-commutative66.0%
Simplified66.0%
associate-*r/66.0%
+-commutative66.0%
pow-pow66.1%
metadata-eval66.1%
pow1/266.1%
*-commutative66.1%
associate-*l*66.1%
*-commutative66.1%
Applied egg-rr66.1%
if 4.5e-118 < b Initial program 71.7%
Simplified71.6%
Taylor expanded in b around -inf 71.6%
fma-def71.6%
Simplified71.6%
Applied egg-rr71.3%
Taylor expanded in c around 0 85.4%
*-commutative85.4%
associate-*r/87.7%
Simplified87.7%
Final simplification73.3%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c (/ -2.0 (+ b (+ b (* -2.0 (* c (/ a b))))))) (fma -1.0 (/ b a) (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp = fma(-1.0, (b / a), (c / b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp = fma(-1.0, Float64(b / a), Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}
\end{array}
Initial program 73.2%
Simplified73.2%
Taylor expanded in b around -inf 68.5%
fma-def68.5%
Simplified68.5%
Applied egg-rr68.4%
Taylor expanded in c around 0 64.4%
*-commutative64.4%
associate-*r/65.2%
Simplified65.2%
Final simplification65.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.2e-207) (if (>= b 0.0) (* c -2.0) (/ (- b) a)) (if (>= b 0.0) (/ (/ c -1.0) b) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.2e-207) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * -2.0;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c / -1.0) / 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.2d-207) then
if (b >= 0.0d0) then
tmp_2 = c * (-2.0d0)
else
tmp_2 = -b / a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (c / (-1.0d0)) / 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.2e-207) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * -2.0;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c / -1.0) / b;
} else {
tmp_1 = -c / b;
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 1.2e-207: tmp_2 = 0 if b >= 0.0: tmp_2 = c * -2.0 else: tmp_2 = -b / a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (c / -1.0) / b else: tmp_1 = -c / b return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 1.2e-207) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * -2.0); else tmp_2 = Float64(Float64(-b) / a); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / -1.0) / b); else tmp_1 = Float64(Float64(-c) / b); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 1.2e-207) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * -2.0; else tmp_3 = -b / a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (c / -1.0) / b; else tmp_2 = -c / b; end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 1.2e-207], If[GreaterEqual[b, 0.0], N[(c * -2.0), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / -1.0), $MachinePrecision] / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.2 \cdot 10^{-207}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\frac{c}{-1}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 1.19999999999999994e-207Initial program 72.7%
Simplified72.7%
Taylor expanded in c around 0 65.1%
*-commutative65.1%
frac-2neg65.1%
metadata-eval65.1%
associate-*l/65.1%
flip-+64.6%
distribute-neg-frac64.6%
+-inverses64.6%
metadata-eval64.6%
+-inverses64.6%
flip-+64.7%
associate-/l*64.7%
flip-+64.6%
+-inverses64.6%
+-inverses64.6%
Applied egg-rr64.6%
Simplified65.4%
Taylor expanded in b around -inf 57.3%
associate-*r/57.3%
mul-1-neg57.3%
Simplified57.3%
if 1.19999999999999994e-207 < b Initial program 74.0%
Simplified73.9%
Taylor expanded in c around 0 77.0%
associate-*r/77.2%
count-277.2%
associate-/r*77.2%
associate-/l*77.2%
metadata-eval77.2%
Applied egg-rr77.2%
Taylor expanded in c around 0 77.2%
mul-1-neg77.2%
distribute-neg-frac77.2%
Simplified77.2%
Final simplification65.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c (/ -2.0 (+ b b))) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (b + b));
} 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 = c * ((-2.0d0) / (b + b))
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 = c * (-2.0 / (b + b));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c * (-2.0 / (b + b)) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * Float64(-2.0 / Float64(b + b))); 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 = c * (-2.0 / (b + b)); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
Initial program 73.2%
Simplified73.2%
Taylor expanded in c around 0 69.8%
Taylor expanded in b around -inf 65.1%
+-commutative65.1%
mul-1-neg65.1%
unsub-neg65.1%
Simplified65.1%
Final simplification65.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c -2.0) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * -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 = c * (-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 = c * -2.0;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c * -2.0 else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * -2.0); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c * -2.0; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * -2.0), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
Initial program 73.2%
Simplified73.2%
Taylor expanded in c around 0 69.8%
*-commutative69.8%
frac-2neg69.8%
metadata-eval69.8%
associate-*l/69.8%
flip-+39.4%
distribute-neg-frac39.4%
+-inverses39.4%
metadata-eval39.4%
+-inverses39.4%
flip-+46.9%
associate-/l*46.9%
flip-+39.4%
+-inverses39.4%
+-inverses39.4%
Applied egg-rr39.4%
Simplified42.3%
Taylor expanded in b around -inf 37.3%
associate-*r/37.3%
mul-1-neg37.3%
Simplified37.3%
Final simplification37.3%
herbie shell --seed 2023326
(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))))