
(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 (fma c (* a -4.0) (* b b)))))
(if (<= b -1.8e+93)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b 2.45e+92)
(if (>= b 0.0) (* c (/ -2.0 (+ b t_0))) (/ (- b t_0) (* a -2.0)))
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (+ b (* -2.0 (* a (/ c b))))))
(/ (* b -2.0) (* a 2.0)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma(c, (a * -4.0), (b * b)));
double tmp_1;
if (b <= -1.8e+93) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 2.45e+92) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (b + t_0));
} else {
tmp_3 = (b - t_0) / (a * -2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
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 <= -1.8e+93) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 2.45e+92) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(-2.0 / Float64(b + t_0))); else tmp_3 = Float64(Float64(b - t_0) / Float64(a * -2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a * Float64(c / b)))))); else tmp_1 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); 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, -1.8e+93], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 2.45e+92], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - t$95$0), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $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 -1.8 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.45 \cdot 10^{+92}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - t\_0}{a \cdot -2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.8e93Initial program 55.4%
Taylor expanded in b around -inf 98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in b around inf 98.0%
Taylor expanded in b around 0 98.0%
associate-*r/98.0%
neg-mul-198.0%
associate-*r/98.0%
neg-mul-198.0%
Simplified98.0%
if -1.8e93 < b < 2.4500000000000001e92Initial program 90.0%
Simplified90.0%
if 2.4500000000000001e92 < b Initial program 50.2%
Taylor expanded in b around -inf 50.2%
*-commutative50.2%
Simplified50.2%
Taylor expanded in a around 0 89.4%
associate-*r/94.7%
Simplified94.7%
Final simplification92.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1 (/ (* b -2.0) (* a 2.0))))
(if (<= b -1.8e+93)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b 1e-310)
(if (>= b 0.0)
(/ -1.0 (/ (+ b (sqrt (* c (* a -4.0)))) (* c 2.0)))
(/ (- t_0 b) (* a 2.0)))
(if (<= b 3.5e+92)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) t_1)
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (+ b (* -2.0 (* a (/ c b))))))
t_1))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = (b * -2.0) / (a * 2.0);
double tmp_1;
if (b <= -1.8e+93) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -1.0 / ((b + sqrt((c * (a * -4.0)))) / (c * 2.0));
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 3.5e+92) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = t_1;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = (b * (-2.0d0)) / (a * 2.0d0)
if (b <= (-1.8d+93)) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 1d-310) then
if (b >= 0.0d0) then
tmp_3 = (-1.0d0) / ((b + sqrt((c * (a * (-4.0d0))))) / (c * 2.0d0))
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b <= 3.5d+92) then
if (b >= 0.0d0) then
tmp_4 = (c * 2.0d0) / (-b - t_0)
else
tmp_4 = t_1
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c * 2.0d0) / (-b - (b + ((-2.0d0) * (a * (c / b)))))
else
tmp_1 = t_1
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 t_1 = (b * -2.0) / (a * 2.0);
double tmp_1;
if (b <= -1.8e+93) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -1.0 / ((b + Math.sqrt((c * (a * -4.0)))) / (c * 2.0));
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 3.5e+92) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = (b * -2.0) / (a * 2.0) tmp_1 = 0 if b <= -1.8e+93: tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 1e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = -1.0 / ((b + math.sqrt((c * (a * -4.0)))) / (c * 2.0)) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b <= 3.5e+92: tmp_4 = 0 if b >= 0.0: tmp_4 = (c * 2.0) / (-b - t_0) else: tmp_4 = t_1 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))) 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(b * -2.0) / Float64(a * 2.0)) tmp_1 = 0.0 if (b <= -1.8e+93) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-1.0 / Float64(Float64(b + sqrt(Float64(c * Float64(a * -4.0)))) / Float64(c * 2.0))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 3.5e+92) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a * Float64(c / b)))))); else tmp_1 = t_1; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = (b * -2.0) / (a * 2.0); tmp_2 = 0.0; if (b <= -1.8e+93) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 1e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -1.0 / ((b + sqrt((c * (a * -4.0)))) / (c * 2.0)); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b <= 3.5e+92) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (c * 2.0) / (-b - t_0); else tmp_5 = t_1; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))); else tmp_2 = t_1; end tmp_6 = 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]}, Block[{t$95$1 = N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.8e+93], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 1e-310], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(c * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.5e+92], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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{b \cdot -2}{a \cdot 2}\\
\mathbf{if}\;b \leq -1.8 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b + \sqrt{c \cdot \left(a \cdot -4\right)}}{c \cdot 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{+92}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.8e93Initial program 55.4%
Taylor expanded in b around -inf 98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in b around inf 98.0%
Taylor expanded in b around 0 98.0%
associate-*r/98.0%
neg-mul-198.0%
associate-*r/98.0%
neg-mul-198.0%
Simplified98.0%
if -1.8e93 < b < 9.999999999999969e-311Initial program 90.1%
add-cube-cbrt90.1%
pow390.1%
*-commutative90.1%
Applied egg-rr90.1%
rem-cube-cbrt90.1%
clear-num90.1%
inv-pow90.1%
pow290.1%
*-commutative90.1%
*-commutative90.1%
*-commutative90.1%
Applied egg-rr90.1%
unpow-190.1%
sub-neg90.1%
+-commutative90.1%
distribute-rgt-neg-in90.1%
distribute-rgt-neg-in90.1%
metadata-eval90.1%
fma-undefine90.1%
Simplified90.1%
Taylor expanded in c around inf 90.1%
*-commutative90.1%
*-commutative90.1%
associate-*r*90.1%
Simplified90.1%
if 9.999999999999969e-311 < b < 3.49999999999999986e92Initial program 89.7%
Taylor expanded in b around -inf 89.7%
*-commutative89.7%
Simplified89.7%
if 3.49999999999999986e92 < b Initial program 50.2%
Taylor expanded in b around -inf 50.2%
*-commutative50.2%
Simplified50.2%
Taylor expanded in a around 0 89.4%
associate-*r/94.7%
Simplified94.7%
Final simplification92.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* b -2.0) (* a 2.0))) (t_1 (sqrt (* -4.0 (* c a)))))
(if (<= b -1.4e-27)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b -5e-310)
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- t_1 b) (* a 2.0)))
(if (<= b 195.0)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_1)) t_0)
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (+ b (* -2.0 (* a (/ c b))))))
t_0))))))
double code(double a, double b, double c) {
double t_0 = (b * -2.0) / (a * 2.0);
double t_1 = sqrt((-4.0 * (c * a)));
double tmp_1;
if (b <= -1.4e-27) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= -5e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_3 = (t_1 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 195.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_1);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(b * -2.0) / Float64(a * 2.0)) t_1 = sqrt(Float64(-4.0 * Float64(c * a))) tmp_1 = 0.0 if (b <= -1.4e-27) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); 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(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_3 = Float64(Float64(t_1 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 195.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_1)); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a * Float64(c / b)))))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.4e-27], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, -5e-310], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 195.0], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot -2}{a \cdot 2}\\
t_1 := \sqrt{-4 \cdot \left(c \cdot a\right)}\\
\mathbf{if}\;b \leq -1.4 \cdot 10^{-27}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 195:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.4e-27Initial program 72.2%
Taylor expanded in b around -inf 87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in b around inf 87.9%
Taylor expanded in b around 0 87.9%
associate-*r/87.9%
neg-mul-187.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
if -1.4e-27 < b < -4.999999999999985e-310Initial program 86.2%
Taylor expanded in a around 0 86.2%
distribute-lft-out--86.2%
associate-/l*86.2%
fmm-def86.2%
Simplified86.2%
Taylor expanded in b around 0 71.7%
if -4.999999999999985e-310 < b < 195Initial program 87.8%
Taylor expanded in b around -inf 87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in b around 0 76.5%
if 195 < b Initial program 59.4%
Taylor expanded in b around -inf 59.4%
*-commutative59.4%
Simplified59.4%
Taylor expanded in a around 0 90.3%
associate-*r/94.4%
Simplified94.4%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -3.3e+91)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b 2e+92)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (+ b (* -2.0 (* a (/ c b))))))
(/ (* b -2.0) (* a 2.0)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -3.3e+91) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 2e+92) {
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 * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-3.3d+91)) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 2d+92) 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 * 2.0d0) / (-b - (b + ((-2.0d0) * (a * (c / b)))))
else
tmp_1 = (b * (-2.0d0)) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -3.3e+91) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 2e+92) {
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 * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -3.3e+91: tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 2e+92: 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 * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))) else: tmp_1 = (b * -2.0) / (a * 2.0) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -3.3e+91) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 2e+92) 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 * 2.0) / Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a * Float64(c / b)))))); else tmp_1 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -3.3e+91) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 2e+92) 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 * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))); else tmp_2 = (b * -2.0) / (a * 2.0); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -3.3e+91], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 2e+92], 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 * 2.0), $MachinePrecision] / N[((-b) - N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -3.3 \cdot 10^{+91}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+92}:\\
\;\;\;\;\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{c \cdot 2}{\left(-b\right) - \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
if b < -3.30000000000000017e91Initial program 55.4%
Taylor expanded in b around -inf 98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in b around inf 98.0%
Taylor expanded in b around 0 98.0%
associate-*r/98.0%
neg-mul-198.0%
associate-*r/98.0%
neg-mul-198.0%
Simplified98.0%
if -3.30000000000000017e91 < b < 2.0000000000000001e92Initial program 90.0%
if 2.0000000000000001e92 < b Initial program 50.2%
Taylor expanded in b around -inf 50.2%
*-commutative50.2%
Simplified50.2%
Taylor expanded in a around 0 89.4%
associate-*r/94.7%
Simplified94.7%
Final simplification92.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.3e+93)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b 90.0)
(if (>= b 0.0)
(/ -1.0 (/ (+ b (sqrt (* c (* a -4.0)))) (* c 2.0)))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (+ b (* -2.0 (* a (/ c b))))))
(/ (* b -2.0) (* a 2.0))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.3e+93) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 90.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -1.0 / ((b + sqrt((c * (a * -4.0)))) / (c * 2.0));
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b <= (-1.3d+93)) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 90.0d0) then
if (b >= 0.0d0) then
tmp_3 = (-1.0d0) / ((b + sqrt((c * (a * (-4.0d0))))) / (c * 2.0d0))
else
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c * 2.0d0) / (-b - (b + ((-2.0d0) * (a * (c / b)))))
else
tmp_1 = (b * (-2.0d0)) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.3e+93) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 90.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -1.0 / ((b + Math.sqrt((c * (a * -4.0)))) / (c * 2.0));
} else {
tmp_3 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -1.3e+93: tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 90.0: tmp_3 = 0 if b >= 0.0: tmp_3 = -1.0 / ((b + math.sqrt((c * (a * -4.0)))) / (c * 2.0)) else: tmp_3 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))) else: tmp_1 = (b * -2.0) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.3e+93) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 90.0) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-1.0 / Float64(Float64(b + sqrt(Float64(c * Float64(a * -4.0)))) / Float64(c * 2.0))); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a * Float64(c / b)))))); else tmp_1 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end return tmp_1 end
function tmp_5 = code(a, b, c) tmp_2 = 0.0; if (b <= -1.3e+93) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 90.0) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -1.0 / ((b + sqrt((c * (a * -4.0)))) / (c * 2.0)); else tmp_4 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))); else tmp_2 = (b * -2.0) / (a * 2.0); end tmp_5 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -1.3e+93], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 90.0], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(c * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.3 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 90:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b + \sqrt{c \cdot \left(a \cdot -4\right)}}{c \cdot 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.3e93Initial program 55.4%
Taylor expanded in b around -inf 98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in b around inf 98.0%
Taylor expanded in b around 0 98.0%
associate-*r/98.0%
neg-mul-198.0%
associate-*r/98.0%
neg-mul-198.0%
Simplified98.0%
if -1.3e93 < b < 90Initial program 89.4%
add-cube-cbrt89.0%
pow389.0%
*-commutative89.0%
Applied egg-rr89.0%
rem-cube-cbrt89.4%
clear-num89.4%
inv-pow89.4%
pow289.4%
*-commutative89.4%
*-commutative89.4%
*-commutative89.4%
Applied egg-rr89.4%
unpow-189.4%
sub-neg89.4%
+-commutative89.4%
distribute-rgt-neg-in89.4%
distribute-rgt-neg-in89.4%
metadata-eval89.4%
fma-undefine89.4%
Simplified89.4%
Taylor expanded in c around inf 85.8%
*-commutative85.8%
*-commutative85.8%
associate-*r*85.8%
Simplified85.8%
if 90 < b Initial program 59.4%
Taylor expanded in b around -inf 59.4%
*-commutative59.4%
Simplified59.4%
Taylor expanded in a around 0 90.3%
associate-*r/94.4%
Simplified94.4%
Final simplification90.8%
(FPCore (a b c)
:precision binary64
(if (<= b -7.6e-28)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (* -4.0 (* c a))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -7.6e-28) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = (sqrt((-4.0 * (c * a))) - b) / (a * 2.0);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -7.6e-28) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = Float64(Float64(sqrt(Float64(-4.0 * Float64(c * a))) - b) / Float64(a * 2.0)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -7.6e-28], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{-28}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -7.60000000000000018e-28Initial program 72.2%
Taylor expanded in b around -inf 87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in b around inf 87.9%
Taylor expanded in b around 0 87.9%
associate-*r/87.9%
neg-mul-187.9%
associate-*r/87.9%
neg-mul-187.9%
Simplified87.9%
if -7.60000000000000018e-28 < b Initial program 74.3%
Taylor expanded in a around 0 74.0%
distribute-lft-out--74.0%
associate-/l*75.9%
fmm-def75.9%
Simplified75.9%
Taylor expanded in b around 0 71.4%
Final simplification76.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* c 2.0) (- (- b) (+ b (* -2.0 (* a (/ c b)))))) (/ (* b -2.0) (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp = (b * -2.0) / (a * 2.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (c * 2.0d0) / (-b - (b + ((-2.0d0) * (a * (c / b)))))
else
tmp = (b * (-2.0d0)) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b)))));
} else {
tmp = (b * -2.0) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))) else: tmp = (b * -2.0) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c * 2.0) / Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a * Float64(c / b)))))); else tmp = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c * 2.0) / (-b - (b + (-2.0 * (a * (c / b))))); else tmp = (b * -2.0) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
Initial program 73.7%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in a around 0 64.4%
associate-*r/65.7%
Simplified65.7%
Final simplification65.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* c 2.0) (* 2.0 (- (* a (/ c b)) b))) (/ (* b -2.0) (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c * 2.0) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (b * -2.0) / (a * 2.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (c * 2.0d0) / (2.0d0 * ((a * (c / b)) - b))
else
tmp = (b * (-2.0d0)) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c * 2.0) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (b * -2.0) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c * 2.0) / (2.0 * ((a * (c / b)) - b)) else: tmp = (b * -2.0) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c * 2.0) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c * 2.0) / (2.0 * ((a * (c / b)) - b)); else tmp = (b * -2.0) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
Initial program 73.7%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in a around 0 64.4%
distribute-lft-out--64.4%
associate-/l*65.7%
Simplified65.7%
Final simplification65.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* 2.0 (/ c (* -2.0 (- b (* a (/ c b)))))) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = 2.0 * (c / (-2.0 * (b - (a * (c / b)))));
} 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 / ((-2.0d0) * (b - (a * (c / b)))))
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 / (-2.0 * (b - (a * (c / b)))));
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = 2.0 * (c / (-2.0 * (b - (a * (c / b))))) else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(2.0 * Float64(c / Float64(-2.0 * Float64(b - Float64(a * Float64(c / b)))))); 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 / (-2.0 * (b - (a * (c / b))))); else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(2.0 * N[(c / N[(-2.0 * N[(b - N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;2 \cdot \frac{c}{-2 \cdot \left(b - a \cdot \frac{c}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 73.7%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in a around 0 64.4%
associate-*r/65.7%
Simplified65.7%
Taylor expanded in b around -inf 64.3%
distribute-lft-out--64.3%
associate-*r/65.7%
neg-mul-165.7%
distribute-frac-neg265.7%
Simplified65.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c (- b)) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} 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 / -b
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 / -b;
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); 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 = c / -b; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 73.7%
Taylor expanded in b around -inf 64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in b around inf 65.5%
Taylor expanded in b around 0 65.5%
associate-*r/65.5%
neg-mul-165.5%
associate-*r/65.5%
neg-mul-165.5%
Simplified65.5%
Final simplification65.5%
herbie shell --seed 2024191
(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))))