
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) 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(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); 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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) 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(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); 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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* 2.0 (/ a (/ b c))))
(t_1 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_2 (- (- b) b)))
(if (<= b -5e+103)
(if (>= b 0.0) (/ t_2 (* a 2.0)) (/ (* 2.0 c) t_2))
(if (<= b 2.9e+93)
(if (>= b 0.0) (/ (- (- b) t_1) (* a 2.0)) (/ (* 2.0 c) (- t_1 b)))
(if (>= b 0.0)
(/ (fma -2.0 b t_0) (* a 2.0))
(/ 2.0 (cbrt (pow (/ t_0 c) 3.0))))))))
double code(double a, double b, double c) {
double t_0 = 2.0 * (a / (b / c));
double t_1 = sqrt(((b * b) - (c * (a * 4.0))));
double t_2 = -b - b;
double tmp_1;
if (b <= -5e+103) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / t_2;
}
tmp_1 = tmp_2;
} else if (b <= 2.9e+93) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_1) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_1 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = fma(-2.0, b, t_0) / (a * 2.0);
} else {
tmp_1 = 2.0 / cbrt(pow((t_0 / c), 3.0));
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(2.0 * Float64(a / Float64(b / c))) t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_2 = Float64(Float64(-b) - b) tmp_1 = 0.0 if (b <= -5e+103) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_2 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(2.0 * c) / t_2); end tmp_1 = tmp_2; elseif (b <= 2.9e+93) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_1 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(fma(-2.0, b, t_0) / Float64(a * 2.0)); else tmp_1 = Float64(2.0 / cbrt((Float64(t_0 / c) ^ 3.0))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, -5e+103], If[GreaterEqual[b, 0.0], N[(t$95$2 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / t$95$2), $MachinePrecision]], If[LessEqual[b, 2.9e+93], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(-2.0 * b + t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[Power[N[Power[N[(t$95$0 / c), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \frac{a}{\frac{b}{c}}\\
t_1 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_2 := \left(-b\right) - b\\
\mathbf{if}\;b \leq -5 \cdot 10^{+103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_2}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_2}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{+93}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_1 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, b, t_0\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\sqrt[3]{{\left(\frac{t_0}{c}\right)}^{3}}}\\
\end{array}
\end{array}
if b < -5e103Initial program 51.5%
Simplified50.4%
Taylor expanded in b around inf 50.4%
Taylor expanded in b around -inf 87.7%
Taylor expanded in a around 0 97.8%
associate-*r/97.8%
mul-1-neg97.8%
Simplified97.8%
if -5e103 < b < 2.8999999999999998e93Initial program 92.2%
if 2.8999999999999998e93 < b Initial program 58.5%
Simplified58.5%
Taylor expanded in b around inf 89.0%
fma-def89.0%
associate-/l*97.8%
Simplified97.8%
add-cbrt-cube97.8%
pow397.8%
Applied egg-rr97.8%
Taylor expanded in b around -inf 97.8%
*-commutative97.8%
associate-/l*97.8%
Simplified97.8%
Final simplification94.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))) (t_1 (- (- b) b)))
(if (<= b -2e+101)
(if (>= b 0.0) (/ t_1 (* a 2.0)) (/ (* 2.0 c) t_1))
(if (<= b 1.8e+94)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ 2.0 (/ (- t_0 b) c)))
(if (>= b 0.0)
(/ (- (- b) (+ b (* -2.0 (/ a (/ b c))))) (* a 2.0))
(/ 2.0 (/ t_1 c)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double t_1 = -b - b;
double tmp_1;
if (b <= -2e+101) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1.8e+94) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((t_0 - b) / c);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = 2.0 / (t_1 / c);
}
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
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
t_1 = -b - b
if (b <= (-2d+101)) then
if (b >= 0.0d0) then
tmp_2 = t_1 / (a * 2.0d0)
else
tmp_2 = (2.0d0 * c) / t_1
end if
tmp_1 = tmp_2
else if (b <= 1.8d+94) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (a * 2.0d0)
else
tmp_3 = 2.0d0 / ((t_0 - b) / c)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-b - (b + ((-2.0d0) * (a / (b / c))))) / (a * 2.0d0)
else
tmp_1 = 2.0d0 / (t_1 / c)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double t_1 = -b - b;
double tmp_1;
if (b <= -2e+101) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1.8e+94) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((t_0 - b) / c);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = 2.0 / (t_1 / c);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) t_1 = -b - b tmp_1 = 0 if b <= -2e+101: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 / (a * 2.0) else: tmp_2 = (2.0 * c) / t_1 tmp_1 = tmp_2 elif b <= 1.8e+94: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (a * 2.0) else: tmp_3 = 2.0 / ((t_0 - b) / c) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0) else: tmp_1 = 2.0 / (t_1 / c) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) t_1 = Float64(Float64(-b) - b) tmp_1 = 0.0 if (b <= -2e+101) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_1 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(2.0 * c) / t_1); end tmp_1 = tmp_2; elseif (b <= 1.8e+94) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_3 = Float64(2.0 / Float64(Float64(t_0 - b) / c)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a / Float64(b / c))))) / Float64(a * 2.0)); else tmp_1 = Float64(2.0 / Float64(t_1 / c)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); t_1 = -b - b; tmp_2 = 0.0; if (b <= -2e+101) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1 / (a * 2.0); else tmp_3 = (2.0 * c) / t_1; end tmp_2 = tmp_3; elseif (b <= 1.8e+94) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (a * 2.0); else tmp_4 = 2.0 / ((t_0 - b) / c); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0); else tmp_2 = 2.0 / (t_1 / c); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, -2e+101], If[GreaterEqual[b, 0.0], N[(t$95$1 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / t$95$1), $MachinePrecision]], If[LessEqual[b, 1.8e+94], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$0 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[(b + N[(-2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(t$95$1 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
t_1 := \left(-b\right) - b\\
\mathbf{if}\;b \leq -2 \cdot 10^{+101}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_1}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_0 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \frac{a}{\frac{b}{c}}\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_1}{c}}\\
\end{array}
\end{array}
if b < -2e101Initial program 51.5%
Simplified50.4%
Taylor expanded in b around inf 50.4%
Taylor expanded in b around -inf 87.7%
Taylor expanded in a around 0 97.8%
associate-*r/97.8%
mul-1-neg97.8%
Simplified97.8%
if -2e101 < b < 1.79999999999999996e94Initial program 92.2%
Simplified92.1%
if 1.79999999999999996e94 < b Initial program 58.5%
Simplified58.5%
Taylor expanded in b around -inf 58.5%
Taylor expanded in b around inf 89.0%
associate-/l*97.8%
Simplified97.8%
Final simplification94.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (- (- b) b)))
(if (<= b -2.2e+104)
(if (>= b 0.0) (/ t_1 (* a 2.0)) (/ (* 2.0 c) t_1))
(if (<= b 1e+94)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0)
(/ (- (- b) (+ b (* -2.0 (/ a (/ b c))))) (* a 2.0))
(/ 2.0 (/ t_1 c)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = -b - b;
double tmp_1;
if (b <= -2.2e+104) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1e+94) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = 2.0 / (t_1 / c);
}
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
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = -b - b
if (b <= (-2.2d+104)) then
if (b >= 0.0d0) then
tmp_2 = t_1 / (a * 2.0d0)
else
tmp_2 = (2.0d0 * c) / t_1
end if
tmp_1 = tmp_2
else if (b <= 1d+94) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (a * 2.0d0)
else
tmp_3 = (2.0d0 * c) / (t_0 - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-b - (b + ((-2.0d0) * (a / (b / c))))) / (a * 2.0d0)
else
tmp_1 = 2.0d0 / (t_1 / c)
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 - b;
double tmp_1;
if (b <= -2.2e+104) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1e+94) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = 2.0 / (t_1 / c);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = -b - b tmp_1 = 0 if b <= -2.2e+104: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 / (a * 2.0) else: tmp_2 = (2.0 * c) / t_1 tmp_1 = tmp_2 elif b <= 1e+94: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (a * 2.0) else: tmp_3 = (2.0 * c) / (t_0 - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0) else: tmp_1 = 2.0 / (t_1 / c) 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) - b) tmp_1 = 0.0 if (b <= -2.2e+104) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_1 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(2.0 * c) / t_1); end tmp_1 = tmp_2; elseif (b <= 1e+94) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a / Float64(b / c))))) / Float64(a * 2.0)); else tmp_1 = Float64(2.0 / Float64(t_1 / c)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = -b - b; tmp_2 = 0.0; if (b <= -2.2e+104) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1 / (a * 2.0); else tmp_3 = (2.0 * c) / t_1; end tmp_2 = tmp_3; elseif (b <= 1e+94) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (a * 2.0); else tmp_4 = (2.0 * c) / (t_0 - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0); else tmp_2 = 2.0 / (t_1 / c); 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]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, -2.2e+104], If[GreaterEqual[b, 0.0], N[(t$95$1 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / t$95$1), $MachinePrecision]], If[LessEqual[b, 1e+94], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[(b + N[(-2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(t$95$1 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \left(-b\right) - b\\
\mathbf{if}\;b \leq -2.2 \cdot 10^{+104}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_1}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \frac{a}{\frac{b}{c}}\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_1}{c}}\\
\end{array}
\end{array}
if b < -2.2e104Initial program 51.5%
Simplified50.4%
Taylor expanded in b around inf 50.4%
Taylor expanded in b around -inf 87.7%
Taylor expanded in a around 0 97.8%
associate-*r/97.8%
mul-1-neg97.8%
Simplified97.8%
if -2.2e104 < b < 1e94Initial program 92.2%
if 1e94 < b Initial program 58.5%
Simplified58.5%
Taylor expanded in b around -inf 58.5%
Taylor expanded in b around inf 89.0%
associate-/l*97.8%
Simplified97.8%
Final simplification94.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)) (t_1 (/ t_0 (* a 2.0))) (t_2 (/ 2.0 (/ t_0 c))))
(if (<= b -1.1e+104)
(if (>= b 0.0) t_1 (/ (* 2.0 c) t_0))
(if (<= b -1e-310)
(if (>= b 0.0)
t_1
(/ 2.0 (/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) c)))
(if (<= b 2.9e-112)
(if (>= b 0.0) (/ (- (- b) (sqrt (* c (* a -4.0)))) (* a 2.0)) t_2)
(if (>= b 0.0)
(/ (- (- b) (+ b (* -2.0 (/ a (/ b c))))) (* a 2.0))
t_2))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = t_0 / (a * 2.0);
double t_2 = 2.0 / (t_0 / c);
double tmp_1;
if (b <= -1.1e+104) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (2.0 * c) / t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 2.0 / ((sqrt(((b * b) - (4.0 * (a * c)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.9e-112) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp_4 = t_2;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = t_2;
}
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) :: t_2
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -b - b
t_1 = t_0 / (a * 2.0d0)
t_2 = 2.0d0 / (t_0 / c)
if (b <= (-1.1d+104)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = (2.0d0 * c) / t_0
end if
tmp_1 = tmp_2
else if (b <= (-1d-310)) then
if (b >= 0.0d0) then
tmp_3 = t_1
else
tmp_3 = 2.0d0 / ((sqrt(((b * b) - (4.0d0 * (a * c)))) - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 2.9d-112) then
if (b >= 0.0d0) then
tmp_4 = (-b - sqrt((c * (a * (-4.0d0))))) / (a * 2.0d0)
else
tmp_4 = t_2
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (-b - (b + ((-2.0d0) * (a / (b / c))))) / (a * 2.0d0)
else
tmp_1 = t_2
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = t_0 / (a * 2.0);
double t_2 = 2.0 / (t_0 / c);
double tmp_1;
if (b <= -1.1e+104) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (2.0 * c) / t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 2.0 / ((Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.9e-112) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - Math.sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp_4 = t_2;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = t_2;
}
return tmp_1;
}
def code(a, b, c): t_0 = -b - b t_1 = t_0 / (a * 2.0) t_2 = 2.0 / (t_0 / c) tmp_1 = 0 if b <= -1.1e+104: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = (2.0 * c) / t_0 tmp_1 = tmp_2 elif b <= -1e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = t_1 else: tmp_3 = 2.0 / ((math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / c) tmp_1 = tmp_3 elif b <= 2.9e-112: tmp_4 = 0 if b >= 0.0: tmp_4 = (-b - math.sqrt((c * (a * -4.0)))) / (a * 2.0) else: tmp_4 = t_2 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0) else: tmp_1 = t_2 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = Float64(t_0 / Float64(a * 2.0)) t_2 = Float64(2.0 / Float64(t_0 / c)) tmp_1 = 0.0 if (b <= -1.1e+104) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(2.0 * c) / t_0); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 2.9e-112) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - sqrt(Float64(c * Float64(a * -4.0)))) / Float64(a * 2.0)); else tmp_4 = t_2; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a / Float64(b / c))))) / Float64(a * 2.0)); else tmp_1 = t_2; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = -b - b; t_1 = t_0 / (a * 2.0); t_2 = 2.0 / (t_0 / c); tmp_2 = 0.0; if (b <= -1.1e+104) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = (2.0 * c) / t_0; end tmp_2 = tmp_3; elseif (b <= -1e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_1; else tmp_4 = 2.0 / ((sqrt(((b * b) - (4.0 * (a * c)))) - b) / c); end tmp_2 = tmp_4; elseif (b <= 2.9e-112) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0); else tmp_5 = t_2; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0); else tmp_2 = t_2; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.1e+104], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], t$95$1, N[(2.0 / N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.9e-112], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$2], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[(b + N[(-2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \frac{t_0}{a \cdot 2}\\
t_2 := \frac{2}{\frac{t_0}{c}}\\
\mathbf{if}\;b \leq -1.1 \cdot 10^{+104}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_0}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-112}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \frac{a}{\frac{b}{c}}\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if b < -1.1e104Initial program 51.5%
Simplified50.4%
Taylor expanded in b around inf 50.4%
Taylor expanded in b around -inf 87.7%
Taylor expanded in a around 0 97.8%
associate-*r/97.8%
mul-1-neg97.8%
Simplified97.8%
if -1.1e104 < b < -9.999999999999969e-311Initial program 88.2%
Simplified87.9%
Taylor expanded in b around inf 87.9%
if -9.999999999999969e-311 < b < 2.89999999999999992e-112Initial program 90.9%
Simplified90.9%
Taylor expanded in b around -inf 90.9%
Taylor expanded in b around 0 87.2%
associate-*r*87.2%
Simplified87.2%
if 2.89999999999999992e-112 < b Initial program 77.0%
Simplified77.0%
Taylor expanded in b around -inf 77.0%
Taylor expanded in b around inf 79.3%
associate-/l*84.2%
Simplified84.2%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)) (t_1 (/ 2.0 (/ t_0 c))) (t_2 (/ t_0 (* a 2.0))))
(if (<= b -3.7e-65)
(if (>= b 0.0) t_2 (/ (* 2.0 c) t_0))
(if (<= b -1e-310)
(if (>= b 0.0) t_2 (/ 2.0 (/ (- (sqrt (* c (* a -4.0))) b) c)))
(if (<= b 2.26e-110)
(if (>= b 0.0) (* (/ 0.5 a) (- (- b) (sqrt (* a (* c -4.0))))) t_1)
(if (>= b 0.0)
(/ (- (- b) (+ b (* -2.0 (/ a (/ b c))))) (* a 2.0))
t_1))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = 2.0 / (t_0 / c);
double t_2 = t_0 / (a * 2.0);
double tmp_1;
if (b <= -3.7e-65) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2;
} else {
tmp_2 = (2.0 * c) / t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_2;
} else {
tmp_3 = 2.0 / ((sqrt((c * (a * -4.0))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.26e-110) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (0.5 / a) * (-b - sqrt((a * (c * -4.0))));
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} 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) :: t_2
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -b - b
t_1 = 2.0d0 / (t_0 / c)
t_2 = t_0 / (a * 2.0d0)
if (b <= (-3.7d-65)) then
if (b >= 0.0d0) then
tmp_2 = t_2
else
tmp_2 = (2.0d0 * c) / t_0
end if
tmp_1 = tmp_2
else if (b <= (-1d-310)) then
if (b >= 0.0d0) then
tmp_3 = t_2
else
tmp_3 = 2.0d0 / ((sqrt((c * (a * (-4.0d0)))) - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 2.26d-110) then
if (b >= 0.0d0) then
tmp_4 = (0.5d0 / a) * (-b - sqrt((a * (c * (-4.0d0)))))
else
tmp_4 = t_1
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (-b - (b + ((-2.0d0) * (a / (b / c))))) / (a * 2.0d0)
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 = -b - b;
double t_1 = 2.0 / (t_0 / c);
double t_2 = t_0 / (a * 2.0);
double tmp_1;
if (b <= -3.7e-65) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2;
} else {
tmp_2 = (2.0 * c) / t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_2;
} else {
tmp_3 = 2.0 / ((Math.sqrt((c * (a * -4.0))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.26e-110) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (0.5 / a) * (-b - Math.sqrt((a * (c * -4.0))));
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = -b - b t_1 = 2.0 / (t_0 / c) t_2 = t_0 / (a * 2.0) tmp_1 = 0 if b <= -3.7e-65: tmp_2 = 0 if b >= 0.0: tmp_2 = t_2 else: tmp_2 = (2.0 * c) / t_0 tmp_1 = tmp_2 elif b <= -1e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = t_2 else: tmp_3 = 2.0 / ((math.sqrt((c * (a * -4.0))) - b) / c) tmp_1 = tmp_3 elif b <= 2.26e-110: tmp_4 = 0 if b >= 0.0: tmp_4 = (0.5 / a) * (-b - math.sqrt((a * (c * -4.0)))) else: tmp_4 = t_1 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0) else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = Float64(2.0 / Float64(t_0 / c)) t_2 = Float64(t_0 / Float64(a * 2.0)) tmp_1 = 0.0 if (b <= -3.7e-65) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_2; else tmp_2 = Float64(Float64(2.0 * c) / t_0); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_2; else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 2.26e-110) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(0.5 / a) * Float64(Float64(-b) - sqrt(Float64(a * Float64(c * -4.0))))); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a / Float64(b / c))))) / Float64(a * 2.0)); else tmp_1 = t_1; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = -b - b; t_1 = 2.0 / (t_0 / c); t_2 = t_0 / (a * 2.0); tmp_2 = 0.0; if (b <= -3.7e-65) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_2; else tmp_3 = (2.0 * c) / t_0; end tmp_2 = tmp_3; elseif (b <= -1e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_2; else tmp_4 = 2.0 / ((sqrt((c * (a * -4.0))) - b) / c); end tmp_2 = tmp_4; elseif (b <= 2.26e-110) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (0.5 / a) * (-b - sqrt((a * (c * -4.0)))); else tmp_5 = t_1; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0); else tmp_2 = t_1; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.7e-65], If[GreaterEqual[b, 0.0], t$95$2, N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], t$95$2, N[(2.0 / N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.26e-110], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[(b + N[(-2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \frac{2}{\frac{t_0}{c}}\\
t_2 := \frac{t_0}{a \cdot 2}\\
\mathbf{if}\;b \leq -3.7 \cdot 10^{-65}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_0}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.26 \cdot 10^{-110}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\left(-b\right) - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \frac{a}{\frac{b}{c}}\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -3.7e-65Initial program 68.8%
Simplified67.9%
Taylor expanded in b around inf 67.9%
Taylor expanded in b around -inf 88.7%
Taylor expanded in a around 0 95.1%
associate-*r/95.2%
mul-1-neg95.2%
Simplified95.2%
if -3.7e-65 < b < -9.999999999999969e-311Initial program 78.0%
Simplified77.9%
Taylor expanded in b around inf 77.9%
Taylor expanded in b around 0 64.3%
associate-*r*26.3%
Simplified64.3%
if -9.999999999999969e-311 < b < 2.26000000000000012e-110Initial program 90.9%
Simplified90.9%
Taylor expanded in b around -inf 90.9%
Taylor expanded in b around 0 87.2%
associate-*r*87.2%
Simplified87.2%
div-sub87.2%
*-commutative87.2%
*-commutative87.2%
Applied egg-rr87.2%
div-sub87.2%
*-lft-identity87.2%
associate-*l/86.9%
*-commutative86.9%
associate-/r*86.9%
metadata-eval86.9%
associate-*r*86.9%
*-commutative86.9%
associate-*l*86.9%
Simplified86.9%
if 2.26000000000000012e-110 < b Initial program 77.0%
Simplified77.0%
Taylor expanded in b around -inf 77.0%
Taylor expanded in b around inf 79.3%
associate-/l*84.2%
Simplified84.2%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b))
(t_1 (/ 2.0 (/ t_0 c)))
(t_2 (/ t_0 (* a 2.0)))
(t_3 (sqrt (* c (* a -4.0)))))
(if (<= b -1.05e-63)
(if (>= b 0.0) t_2 (/ (* 2.0 c) t_0))
(if (<= b -1e-310)
(if (>= b 0.0) t_2 (/ 2.0 (/ (- t_3 b) c)))
(if (<= b 9.1e-110)
(if (>= b 0.0) (/ (- (- b) t_3) (* a 2.0)) t_1)
(if (>= b 0.0)
(/ (- (- b) (+ b (* -2.0 (/ a (/ b c))))) (* a 2.0))
t_1))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = 2.0 / (t_0 / c);
double t_2 = t_0 / (a * 2.0);
double t_3 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -1.05e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2;
} else {
tmp_2 = (2.0 * c) / t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_2;
} else {
tmp_3 = 2.0 / ((t_3 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 9.1e-110) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_3) / (a * 2.0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} 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) :: t_2
real(8) :: t_3
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -b - b
t_1 = 2.0d0 / (t_0 / c)
t_2 = t_0 / (a * 2.0d0)
t_3 = sqrt((c * (a * (-4.0d0))))
if (b <= (-1.05d-63)) then
if (b >= 0.0d0) then
tmp_2 = t_2
else
tmp_2 = (2.0d0 * c) / t_0
end if
tmp_1 = tmp_2
else if (b <= (-1d-310)) then
if (b >= 0.0d0) then
tmp_3 = t_2
else
tmp_3 = 2.0d0 / ((t_3 - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 9.1d-110) then
if (b >= 0.0d0) then
tmp_4 = (-b - t_3) / (a * 2.0d0)
else
tmp_4 = t_1
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (-b - (b + ((-2.0d0) * (a / (b / c))))) / (a * 2.0d0)
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 = -b - b;
double t_1 = 2.0 / (t_0 / c);
double t_2 = t_0 / (a * 2.0);
double t_3 = Math.sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -1.05e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2;
} else {
tmp_2 = (2.0 * c) / t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_2;
} else {
tmp_3 = 2.0 / ((t_3 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 9.1e-110) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_3) / (a * 2.0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = -b - b t_1 = 2.0 / (t_0 / c) t_2 = t_0 / (a * 2.0) t_3 = math.sqrt((c * (a * -4.0))) tmp_1 = 0 if b <= -1.05e-63: tmp_2 = 0 if b >= 0.0: tmp_2 = t_2 else: tmp_2 = (2.0 * c) / t_0 tmp_1 = tmp_2 elif b <= -1e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = t_2 else: tmp_3 = 2.0 / ((t_3 - b) / c) tmp_1 = tmp_3 elif b <= 9.1e-110: tmp_4 = 0 if b >= 0.0: tmp_4 = (-b - t_3) / (a * 2.0) else: tmp_4 = t_1 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0) else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = Float64(2.0 / Float64(t_0 / c)) t_2 = Float64(t_0 / Float64(a * 2.0)) t_3 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -1.05e-63) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_2; else tmp_2 = Float64(Float64(2.0 * c) / t_0); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_2; else tmp_3 = Float64(2.0 / Float64(Float64(t_3 - b) / c)); end tmp_1 = tmp_3; elseif (b <= 9.1e-110) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_3) / Float64(a * 2.0)); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a / Float64(b / c))))) / Float64(a * 2.0)); else tmp_1 = t_1; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = -b - b; t_1 = 2.0 / (t_0 / c); t_2 = t_0 / (a * 2.0); t_3 = sqrt((c * (a * -4.0))); tmp_2 = 0.0; if (b <= -1.05e-63) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_2; else tmp_3 = (2.0 * c) / t_0; end tmp_2 = tmp_3; elseif (b <= -1e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_2; else tmp_4 = 2.0 / ((t_3 - b) / c); end tmp_2 = tmp_4; elseif (b <= 9.1e-110) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-b - t_3) / (a * 2.0); else tmp_5 = t_1; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0); else tmp_2 = t_1; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.05e-63], If[GreaterEqual[b, 0.0], t$95$2, N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], t$95$2, N[(2.0 / N[(N[(t$95$3 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 9.1e-110], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$3), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[(b + N[(-2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \frac{2}{\frac{t_0}{c}}\\
t_2 := \frac{t_0}{a \cdot 2}\\
t_3 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -1.05 \cdot 10^{-63}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_0}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_3 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 9.1 \cdot 10^{-110}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_3}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \frac{a}{\frac{b}{c}}\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -1.05e-63Initial program 68.8%
Simplified67.9%
Taylor expanded in b around inf 67.9%
Taylor expanded in b around -inf 88.7%
Taylor expanded in a around 0 95.1%
associate-*r/95.2%
mul-1-neg95.2%
Simplified95.2%
if -1.05e-63 < b < -9.999999999999969e-311Initial program 78.0%
Simplified77.9%
Taylor expanded in b around inf 77.9%
Taylor expanded in b around 0 64.3%
associate-*r*26.3%
Simplified64.3%
if -9.999999999999969e-311 < b < 9.1000000000000004e-110Initial program 90.9%
Simplified90.9%
Taylor expanded in b around -inf 90.9%
Taylor expanded in b around 0 87.2%
associate-*r*87.2%
Simplified87.2%
if 9.1000000000000004e-110 < b Initial program 77.0%
Simplified77.0%
Taylor expanded in b around -inf 77.0%
Taylor expanded in b around inf 79.3%
associate-/l*84.2%
Simplified84.2%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ 2.0 (/ (- (- b) b) c))))
(if (<= b 9.5e-110)
(if (>= b 0.0) (* (/ 0.5 a) (- (- b) (sqrt (* a (* c -4.0))))) t_0)
(if (>= b 0.0)
(/ (- (- b) (+ b (* -2.0 (/ a (/ b c))))) (* a 2.0))
t_0))))
double code(double a, double b, double c) {
double t_0 = 2.0 / ((-b - b) / c);
double tmp_1;
if (b <= 9.5e-110) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-b - sqrt((a * (c * -4.0))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = t_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
t_0 = 2.0d0 / ((-b - b) / c)
if (b <= 9.5d-110) then
if (b >= 0.0d0) then
tmp_2 = (0.5d0 / a) * (-b - sqrt((a * (c * (-4.0d0)))))
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (-b - (b + ((-2.0d0) * (a / (b / c))))) / (a * 2.0d0)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = 2.0 / ((-b - b) / c);
double tmp_1;
if (b <= 9.5e-110) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (0.5 / a) * (-b - Math.sqrt((a * (c * -4.0))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = 2.0 / ((-b - b) / c) tmp_1 = 0 if b <= 9.5e-110: tmp_2 = 0 if b >= 0.0: tmp_2 = (0.5 / a) * (-b - math.sqrt((a * (c * -4.0)))) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)) tmp_1 = 0.0 if (b <= 9.5e-110) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(0.5 / a) * Float64(Float64(-b) - sqrt(Float64(a * Float64(c * -4.0))))); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - Float64(b + Float64(-2.0 * Float64(a / Float64(b / c))))) / Float64(a * 2.0)); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = 2.0 / ((-b - b) / c); tmp_2 = 0.0; if (b <= 9.5e-110) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (0.5 / a) * (-b - sqrt((a * (c * -4.0)))); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (-b - (b + (-2.0 * (a / (b / c))))) / (a * 2.0); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 9.5e-110], If[GreaterEqual[b, 0.0], N[(N[(0.5 / a), $MachinePrecision] * N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[(b + N[(-2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{\frac{\left(-b\right) - b}{c}}\\
\mathbf{if}\;b \leq 9.5 \cdot 10^{-110}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\left(-b\right) - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \frac{a}{\frac{b}{c}}\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 9.50000000000000004e-110Initial program 74.1%
Simplified73.6%
Taylor expanded in b around -inf 76.6%
Taylor expanded in b around 0 76.1%
associate-*r*76.1%
Simplified76.1%
div-sub76.1%
*-commutative76.1%
*-commutative76.1%
Applied egg-rr76.1%
div-sub76.1%
*-lft-identity76.1%
associate-*l/76.0%
*-commutative76.0%
associate-/r*76.0%
metadata-eval76.0%
associate-*r*76.0%
*-commutative76.0%
associate-*l*76.0%
Simplified76.0%
if 9.50000000000000004e-110 < b Initial program 77.0%
Simplified77.0%
Taylor expanded in b around -inf 77.0%
Taylor expanded in b around inf 79.3%
associate-/l*84.2%
Simplified84.2%
Final simplification79.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (- b) b) (* a 2.0)) (/ 2.0 (* -2.0 (/ a b)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / (-2.0 * (a / b));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (-b - b) / (a * 2.0d0)
else
tmp = 2.0d0 / ((-2.0d0) * (a / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / (-2.0 * (a / b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-b - b) / (a * 2.0) else: tmp = 2.0 / (-2.0 * (a / b)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp = Float64(2.0 / Float64(-2.0 * Float64(a / b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-b - b) / (a * 2.0); else tmp = 2.0 / (-2.0 * (a / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(-2.0 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{-2 \cdot \frac{a}{b}}\\
\end{array}
\end{array}
Initial program 75.2%
Simplified74.9%
Taylor expanded in b around inf 70.4%
Taylor expanded in b around inf 33.6%
Final simplification33.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (- b) b) (* a 2.0)) (/ 2.0 (* 2.0 (/ a b)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / (2.0 * (a / b));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (-b - b) / (a * 2.0d0)
else
tmp = 2.0d0 / (2.0d0 * (a / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / (2.0 * (a / b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-b - b) / (a * 2.0) else: tmp = 2.0 / (2.0 * (a / b)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp = Float64(2.0 / Float64(2.0 * Float64(a / b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-b - b) / (a * 2.0); else tmp = 2.0 / (2.0 * (a / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(2.0 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{2 \cdot \frac{a}{b}}\\
\end{array}
\end{array}
Initial program 75.2%
Simplified74.9%
Taylor expanded in b around inf 70.4%
Taylor expanded in b around -inf 70.2%
Taylor expanded in b around 0 33.9%
Final simplification33.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (- b) b) (* a 2.0)) (/ 2.0 (/ (* b -2.0) c))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / ((b * -2.0) / c);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (-b - b) / (a * 2.0d0)
else
tmp = 2.0d0 / ((b * (-2.0d0)) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / ((b * -2.0) / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-b - b) / (a * 2.0) else: tmp = 2.0 / ((b * -2.0) / c) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp = Float64(2.0 / Float64(Float64(b * -2.0) / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-b - b) / (a * 2.0); else tmp = 2.0 / ((b * -2.0) / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(b * -2.0), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{b \cdot -2}{c}}\\
\end{array}
\end{array}
Initial program 75.2%
Simplified74.9%
Taylor expanded in b around inf 70.4%
Taylor expanded in b around -inf 72.2%
associate-*r/72.2%
*-commutative72.2%
Simplified72.2%
Final simplification72.2%
(FPCore (a b c) :precision binary64 (let* ((t_0 (- (- b) b))) (if (>= b 0.0) (/ t_0 (* a 2.0)) (/ (* 2.0 c) t_0))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double tmp;
if (b >= 0.0) {
tmp = t_0 / (a * 2.0);
} else {
tmp = (2.0 * c) / t_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) :: t_0
real(8) :: tmp
t_0 = -b - b
if (b >= 0.0d0) then
tmp = t_0 / (a * 2.0d0)
else
tmp = (2.0d0 * c) / t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -b - b;
double tmp;
if (b >= 0.0) {
tmp = t_0 / (a * 2.0);
} else {
tmp = (2.0 * c) / t_0;
}
return tmp;
}
def code(a, b, c): t_0 = -b - b tmp = 0 if b >= 0.0: tmp = t_0 / (a * 2.0) else: tmp = (2.0 * c) / t_0 return tmp
function code(a, b, c) t_0 = Float64(Float64(-b) - b) tmp = 0.0 if (b >= 0.0) tmp = Float64(t_0 / Float64(a * 2.0)); else tmp = Float64(Float64(2.0 * c) / t_0); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -b - b; tmp = 0.0; if (b >= 0.0) tmp = t_0 / (a * 2.0); else tmp = (2.0 * c) / t_0; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_0}\\
\end{array}
\end{array}
Initial program 75.2%
Simplified74.9%
Taylor expanded in b around inf 70.4%
Taylor expanded in b around -inf 70.2%
Taylor expanded in a around 0 72.7%
associate-*r/72.7%
mul-1-neg72.7%
Simplified72.7%
Final simplification72.7%
herbie shell --seed 2023319
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))