
(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 9 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 (- (* b b) (* c (* 4.0 a))))
(t_1 (/ (* 2.0 c) (- (- b) (sqrt t_0)))))
(if (<= b -2.8e+157)
(if (>= b 0.0) t_1 (/ (fma 2.0 (* a (/ c b)) (* b -2.0)) (* 2.0 a)))
(if (<= b 5.5e+96)
(if (>= b 0.0) t_1 (/ (- (pow t_0 0.5) b) (* 2.0 a)))
(if (>= b 0.0) (* -2.0 (/ (* c 0.5) b)) (* (/ -0.5 a) (+ b b)))))))
double code(double a, double b, double c) {
double t_0 = (b * b) - (c * (4.0 * a));
double t_1 = (2.0 * c) / (-b - sqrt(t_0));
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = fma(2.0, (a * (c / b)), (b * -2.0)) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 5.5e+96) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (pow(t_0, 0.5) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * ((c * 0.5) / b);
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(b * b) - Float64(c * Float64(4.0 * a))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(t_0))) tmp_1 = 0.0 if (b <= -2.8e+157) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(fma(2.0, Float64(a * Float64(c / b)), Float64(b * -2.0)) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 5.5e+96) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(Float64((t_0 ^ 0.5) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-2.0 * Float64(Float64(c * 0.5) / b)); else tmp_1 = Float64(Float64(-0.5 / a) * Float64(b + b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.8e+157], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5.5e+96], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(N[Power[t$95$0, 0.5], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot b - c \cdot \left(4 \cdot a\right)\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - \sqrt{t_0}}\\
\mathbf{if}\;b \leq -2.8 \cdot 10^{+157}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(2, a \cdot \frac{c}{b}, b \cdot -2\right)}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{+96}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{{t_0}^{0.5} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c \cdot 0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + b\right)\\
\end{array}
\end{array}
if b < -2.8000000000000003e157Initial program 37.9%
pow1/237.9%
*-commutative37.9%
*-commutative37.9%
Applied egg-rr37.9%
Taylor expanded in b around -inf 88.7%
fma-def88.7%
associate-*l/96.9%
*-commutative96.9%
*-commutative96.9%
Simplified96.9%
if -2.8000000000000003e157 < b < 5.5000000000000002e96Initial program 85.4%
pow1/285.4%
*-commutative85.4%
*-commutative85.4%
Applied egg-rr85.4%
if 5.5000000000000002e96 < b Initial program 56.5%
Simplified56.5%
Taylor expanded in b around inf 88.8%
associate-/l*95.4%
Simplified95.4%
Taylor expanded in b around -inf 95.4%
Taylor expanded in c around 0 95.5%
*-commutative95.5%
associate-*l/95.5%
Simplified95.5%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (<= b -2.8e+157)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (+ b (* -2.0 (/ c (/ b a)))))))
(- (/ c b) (/ b a)))
(if (<= b 4.4e+97)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0) (* -2.0 (/ (* c 0.5) b)) (* (/ -0.5 a) (+ b b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 4.4e+97) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * ((c * 0.5) / b);
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
if (b <= (-2.8d+157)) then
if (b >= 0.0d0) then
tmp_2 = (-2.0d0) * (c / (b + (b + ((-2.0d0) * (c / (b / a))))))
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 4.4d+97) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-2.0d0) * ((c * 0.5d0) / b)
else
tmp_1 = ((-0.5d0) / a) * (b + b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 4.4e+97) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * ((c * 0.5) / b);
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) tmp_1 = 0 if b <= -2.8e+157: tmp_2 = 0 if b >= 0.0: tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))) else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 4.4e+97: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (-b - t_0) else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -2.0 * ((c * 0.5) / b) else: tmp_1 = (-0.5 / a) * (b + b) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) tmp_1 = 0.0 if (b <= -2.8e+157) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-2.0 * Float64(c / Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a))))))); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 4.4e+97) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-2.0 * Float64(Float64(c * 0.5) / b)); else tmp_1 = Float64(Float64(-0.5 / a) * Float64(b + b)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); tmp_2 = 0.0; if (b <= -2.8e+157) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))); else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 4.4e+97) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (-b - t_0); else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -2.0 * ((c * 0.5) / b); else tmp_2 = (-0.5 / a) * (b + b); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.8e+157], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(c / N[(b + N[(b + N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4.4e+97], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -2.8 \cdot 10^{+157}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+97}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c \cdot 0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + b\right)\\
\end{array}
\end{array}
if b < -2.8000000000000003e157Initial program 37.9%
Simplified37.9%
Taylor expanded in b around inf 37.9%
associate-/l*37.9%
Simplified37.9%
Taylor expanded in b around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
Simplified96.9%
if -2.8000000000000003e157 < b < 4.4000000000000002e97Initial program 85.4%
if 4.4000000000000002e97 < b Initial program 56.5%
Simplified56.5%
Taylor expanded in b around inf 88.8%
associate-/l*95.4%
Simplified95.4%
Taylor expanded in b around -inf 95.4%
Taylor expanded in c around 0 95.5%
*-commutative95.5%
associate-*l/95.5%
Simplified95.5%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0))))
(if (<= b -2.8e+157)
(if (>= b 0.0) t_1 (/ (fma 2.0 (* a (/ c b)) (* b -2.0)) (* 2.0 a)))
(if (<= b 1e+94)
(if (>= b 0.0) t_1 (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0) (* -2.0 (/ (* c 0.5) b)) (* (/ -0.5 a) (+ b b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = fma(2.0, (a * (c / b)), (b * -2.0)) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1e+94) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * ((c * 0.5) / b);
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) tmp_1 = 0.0 if (b <= -2.8e+157) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(fma(2.0, Float64(a * Float64(c / b)), Float64(b * -2.0)) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 1e+94) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-2.0 * Float64(Float64(c * 0.5) / b)); else tmp_1 = Float64(Float64(-0.5 / a) * Float64(b + b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.8e+157], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+94], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{if}\;b \leq -2.8 \cdot 10^{+157}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(2, a \cdot \frac{c}{b}, b \cdot -2\right)}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c \cdot 0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + b\right)\\
\end{array}
\end{array}
if b < -2.8000000000000003e157Initial program 37.9%
pow1/237.9%
*-commutative37.9%
*-commutative37.9%
Applied egg-rr37.9%
Taylor expanded in b around -inf 88.7%
fma-def88.7%
associate-*l/96.9%
*-commutative96.9%
*-commutative96.9%
Simplified96.9%
if -2.8000000000000003e157 < b < 1e94Initial program 85.4%
if 1e94 < b Initial program 56.5%
Simplified56.5%
Taylor expanded in b around inf 88.8%
associate-/l*95.4%
Simplified95.4%
Taylor expanded in b around -inf 95.4%
Taylor expanded in c around 0 95.5%
*-commutative95.5%
associate-*l/95.5%
Simplified95.5%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(if (<= b -2.8e+157)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (+ b (* -2.0 (/ c (/ b a)))))))
(- (/ c b) (/ b a)))
(if (<= b -4e-310)
(if (>= b 0.0)
(- (- (/ c b)) (/ (* c c) (/ (pow b 3.0) a)))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
(if (>= b 0.0)
(* -2.0 (/ c (+ b (+ b (* -2.0 (* c (/ a b)))))))
(* (/ -0.5 a) (+ b b))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -4e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -(c / b) - ((c * c) / (pow(b, 3.0) / a));
} else {
tmp_3 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b <= (-2.8d+157)) then
if (b >= 0.0d0) then
tmp_2 = (-2.0d0) * (c / (b + (b + ((-2.0d0) * (c / (b / a))))))
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= (-4d-310)) then
if (b >= 0.0d0) then
tmp_3 = -(c / b) - ((c * c) / ((b ** 3.0d0) / a))
else
tmp_3 = (sqrt(((b * b) - (c * (4.0d0 * a)))) - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-2.0d0) * (c / (b + (b + ((-2.0d0) * (c * (a / b))))))
else
tmp_1 = ((-0.5d0) / a) * (b + b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -4e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -(c / b) - ((c * c) / (Math.pow(b, 3.0) / a));
} else {
tmp_3 = (Math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -2.8e+157: tmp_2 = 0 if b >= 0.0: tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))) else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= -4e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = -(c / b) - ((c * c) / (math.pow(b, 3.0) / a)) else: tmp_3 = (math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b)))))) else: tmp_1 = (-0.5 / a) * (b + b) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -2.8e+157) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-2.0 * Float64(c / Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a))))))); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -4e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(-Float64(c / b)) - Float64(Float64(c * c) / Float64((b ^ 3.0) / a))); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-2.0 * Float64(c / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp_1 = Float64(Float64(-0.5 / a) * Float64(b + b)); end return tmp_1 end
function tmp_5 = code(a, b, c) tmp_2 = 0.0; if (b <= -2.8e+157) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))); else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= -4e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -(c / b) - ((c * c) / ((b ^ 3.0) / a)); else tmp_4 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b)))))); else tmp_2 = (-0.5 / a) * (b + b); end tmp_5 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -2.8e+157], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(c / N[(b + N[(b + N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -4e-310], If[GreaterEqual[b, 0.0], N[((-N[(c / b), $MachinePrecision]) - N[(N[(c * c), $MachinePrecision] / N[(N[Power[b, 3.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(c / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+157}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(-\frac{c}{b}\right) - \frac{c \cdot c}{\frac{{b}^{3}}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + b\right)\\
\end{array}
\end{array}
if b < -2.8000000000000003e157Initial program 37.9%
Simplified37.9%
Taylor expanded in b around inf 37.9%
associate-/l*37.9%
Simplified37.9%
Taylor expanded in b around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
Simplified96.9%
if -2.8000000000000003e157 < b < -3.999999999999988e-310Initial program 89.0%
Taylor expanded in c around 0 89.0%
distribute-lft-out89.0%
associate-/l*89.0%
unpow289.0%
Simplified89.0%
if -3.999999999999988e-310 < b Initial program 68.2%
Simplified68.2%
Taylor expanded in b around inf 65.5%
associate-/l*68.8%
Simplified68.8%
Taylor expanded in b around -inf 68.8%
div-inv68.8%
Applied egg-rr68.8%
Taylor expanded in b around 0 68.8%
Final simplification80.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (<= b -2.8e+157)
(if (>= b 0.0)
(* -2.0 (/ c (+ b (+ b (* -2.0 (/ c (/ b a)))))))
(- (/ c b) (/ b a)))
(if (<= b 9.2e-103)
(if (>= b 0.0) (* c (/ 2.0 (- b t_0))) (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0)
(* -2.0 (/ c (+ b (+ b (* -2.0 (* c (/ a b)))))))
(* (/ -0.5 a) (+ b b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 9.2e-103) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (2.0 / (b - t_0));
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
if (b <= (-2.8d+157)) then
if (b >= 0.0d0) then
tmp_2 = (-2.0d0) * (c / (b + (b + ((-2.0d0) * (c / (b / a))))))
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 9.2d-103) then
if (b >= 0.0d0) then
tmp_3 = c * (2.0d0 / (b - t_0))
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-2.0d0) * (c / (b + (b + ((-2.0d0) * (c * (a / b))))))
else
tmp_1 = ((-0.5d0) / a) * (b + b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if (b <= -2.8e+157) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 9.2e-103) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (2.0 / (b - t_0));
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp_1 = (-0.5 / a) * (b + b);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) tmp_1 = 0 if b <= -2.8e+157: tmp_2 = 0 if b >= 0.0: tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))) else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 9.2e-103: tmp_3 = 0 if b >= 0.0: tmp_3 = c * (2.0 / (b - t_0)) else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b)))))) else: tmp_1 = (-0.5 / a) * (b + b) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) tmp_1 = 0.0 if (b <= -2.8e+157) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-2.0 * Float64(c / Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a))))))); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 9.2e-103) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(2.0 / Float64(b - t_0))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-2.0 * Float64(c / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp_1 = Float64(Float64(-0.5 / a) * Float64(b + b)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); tmp_2 = 0.0; if (b <= -2.8e+157) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))); else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 9.2e-103) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = c * (2.0 / (b - t_0)); else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b)))))); else tmp_2 = (-0.5 / a) * (b + b); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.8e+157], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(c / N[(b + N[(b + N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 9.2e-103], If[GreaterEqual[b, 0.0], N[(c * N[(2.0 / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-2.0 * N[(c / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -2.8 \cdot 10^{+157}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 9.2 \cdot 10^{-103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{b - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + b\right)\\
\end{array}
\end{array}
if b < -2.8000000000000003e157Initial program 37.9%
Simplified37.9%
Taylor expanded in b around inf 37.9%
associate-/l*37.9%
Simplified37.9%
Taylor expanded in b around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
Simplified96.9%
if -2.8000000000000003e157 < b < 9.2000000000000003e-103Initial program 86.1%
expm1-log1p-u83.3%
expm1-udef73.7%
*-commutative73.7%
add-sqr-sqrt69.6%
sqrt-unprod73.1%
sqr-neg73.1%
sqrt-prod73.2%
add-sqr-sqrt73.2%
*-commutative73.2%
*-commutative73.2%
Applied egg-rr73.2%
expm1-def81.2%
expm1-log1p84.0%
associate-*r/84.0%
Simplified84.0%
if 9.2000000000000003e-103 < b Initial program 66.1%
Simplified66.1%
Taylor expanded in b around inf 79.3%
associate-/l*83.6%
Simplified83.6%
Taylor expanded in b around -inf 83.6%
div-inv83.6%
Applied egg-rr83.6%
Taylor expanded in b around 0 83.6%
Final simplification86.0%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -2.0 (/ c (+ b (+ b (* -2.0 (* c (/ a b))))))) (* (/ -0.5 a) (+ b b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp = (-0.5 / a) * (b + 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 = (-2.0d0) * (c / (b + (b + ((-2.0d0) * (c * (a / b))))))
else
tmp = ((-0.5d0) / a) * (b + b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b))))));
} else {
tmp = (-0.5 / a) * (b + b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b)))))) else: tmp = (-0.5 / a) * (b + b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-2.0 * Float64(c / Float64(b + Float64(b + Float64(-2.0 * Float64(c * Float64(a / b))))))); else tmp = Float64(Float64(-0.5 / a) * Float64(b + b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -2.0 * (c / (b + (b + (-2.0 * (c * (a / b)))))); else tmp = (-0.5 / a) * (b + b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-2.0 * N[(c / N[(b + N[(b + N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b + -2 \cdot \left(c \cdot \frac{a}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + b\right)\\
\end{array}
\end{array}
Initial program 70.7%
Simplified70.6%
Taylor expanded in b around inf 69.4%
associate-/l*70.9%
Simplified70.9%
Taylor expanded in b around -inf 68.2%
div-inv68.2%
Applied egg-rr68.2%
Taylor expanded in b around 0 68.2%
Final simplification68.2%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -2.0 (/ c (+ b (+ b (* -2.0 (/ c (/ b a))))))) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (-2.0d0) * (c / (b + (b + ((-2.0d0) * (c / (b / a))))))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a))))));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-2.0 * Float64(c / Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a))))))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -2.0 * (c / (b + (b + (-2.0 * (c / (b / a)))))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-2.0 * N[(c / N[(b + N[(b + N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
Initial program 70.7%
Simplified70.6%
Taylor expanded in b around inf 69.4%
associate-/l*70.9%
Simplified70.9%
Taylor expanded in b around -inf 68.5%
mul-1-neg68.5%
unsub-neg68.5%
Simplified68.5%
Final simplification68.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -2.0 (* -0.5 (/ b a))) (/ (* -0.5 (+ b b)) a)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -2.0 * (-0.5 * (b / a));
} else {
tmp = (-0.5 * (b + b)) / a;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (-2.0d0) * ((-0.5d0) * (b / a))
else
tmp = ((-0.5d0) * (b + b)) / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -2.0 * (-0.5 * (b / a));
} else {
tmp = (-0.5 * (b + b)) / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -2.0 * (-0.5 * (b / a)) else: tmp = (-0.5 * (b + b)) / a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-2.0 * Float64(-0.5 * Float64(b / a))); else tmp = Float64(Float64(-0.5 * Float64(b + b)) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -2.0 * (-0.5 * (b / a)); else tmp = (-0.5 * (b + b)) / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-2.0 * N[(-0.5 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(b + b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \left(-0.5 \cdot \frac{b}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot \left(b + b\right)}{a}\\
\end{array}
\end{array}
Initial program 70.7%
Simplified70.6%
Taylor expanded in b around inf 69.4%
associate-/l*70.9%
Simplified70.9%
Taylor expanded in b around -inf 68.2%
Taylor expanded in c around inf 37.8%
associate-*r/37.9%
cancel-sign-sub-inv37.9%
metadata-eval37.9%
*-un-lft-identity37.9%
Applied egg-rr37.9%
Final simplification37.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -2.0 (/ (* c 0.5) b)) (* (/ -0.5 a) (+ b b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -2.0 * ((c * 0.5) / b);
} else {
tmp = (-0.5 / a) * (b + 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 = (-2.0d0) * ((c * 0.5d0) / b)
else
tmp = ((-0.5d0) / a) * (b + b)
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 * 0.5) / b);
} else {
tmp = (-0.5 / a) * (b + b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -2.0 * ((c * 0.5) / b) else: tmp = (-0.5 / a) * (b + b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-2.0 * Float64(Float64(c * 0.5) / b)); else tmp = Float64(Float64(-0.5 / a) * Float64(b + b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -2.0 * ((c * 0.5) / b); else tmp = (-0.5 / a) * (b + b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-2.0 * N[(N[(c * 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c \cdot 0.5}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + b\right)\\
\end{array}
\end{array}
Initial program 70.7%
Simplified70.6%
Taylor expanded in b around inf 69.4%
associate-/l*70.9%
Simplified70.9%
Taylor expanded in b around -inf 68.2%
Taylor expanded in c around 0 68.0%
*-commutative68.0%
associate-*l/68.0%
Simplified68.0%
Final simplification68.0%
herbie shell --seed 2023199
(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))))