
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- 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 (/ c (/ b a)))))
(if (<= b -5e+113)
(if (>= b 0.0) (* (/ -0.5 a) (+ b (+ b t_0))) (/ (* -2.0 c) (+ b b)))
(if (<= b -1.6e-278)
(if (>= b 0.0)
(* (/ -0.5 a) (fma b 2.0 t_0))
(* c (/ -2.0 (- b (sqrt (+ (* b b) (* c (* a -4.0))))))))
(if (<= b 2e+126)
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* a 2.0))
(/ 2.0 (/ (* b -2.0) c)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (* c (/ -2.0 (+ b b)))))))))
double code(double a, double b, double c) {
double t_0 = -2.0 * (c / (b / a));
double tmp_1;
if (b <= -5e+113) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + (b + t_0));
} else {
tmp_2 = (-2.0 * c) / (b + b);
}
tmp_1 = tmp_2;
} else if (b <= -1.6e-278) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-0.5 / a) * fma(b, 2.0, t_0);
} else {
tmp_3 = c * (-2.0 / (b - sqrt(((b * b) + (c * (a * -4.0))))));
}
tmp_1 = tmp_3;
} else if (b <= 2e+126) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0);
} else {
tmp_4 = 2.0 / ((b * -2.0) / c);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = c * (-2.0 / (b + b));
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(-2.0 * Float64(c / Float64(b / a))) tmp_1 = 0.0 if (b <= -5e+113) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-0.5 / a) * Float64(b + Float64(b + t_0))); else tmp_2 = Float64(Float64(-2.0 * c) / Float64(b + b)); end tmp_1 = tmp_2; elseif (b <= -1.6e-278) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(-0.5 / a) * fma(b, 2.0, t_0)); else tmp_3 = Float64(c * Float64(-2.0 / Float64(b - sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0))))))); end tmp_1 = tmp_3; elseif (b <= 2e+126) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(a * 2.0)); else tmp_4 = Float64(2.0 / Float64(Float64(b * -2.0) / c)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(c * Float64(-2.0 / Float64(b + b))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5e+113], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -1.6e-278], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b * 2.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2e+126], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(b * -2.0), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \frac{c}{\frac{b}{a}}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+113}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(b + t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot c}{b + b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1.6 \cdot 10^{-278}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \mathsf{fma}\left(b, 2, t_0\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b - \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+126}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{b \cdot -2}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\end{array}
\end{array}
if b < -5e113Initial program 46.9%
Simplified46.8%
Taylor expanded in b around -inf 92.7%
Taylor expanded in b around inf 92.7%
associate-/l*92.7%
Simplified92.7%
associate-*r/93.0%
cancel-sign-sub-inv93.0%
metadata-eval93.0%
*-un-lft-identity93.0%
Applied egg-rr93.0%
if -5e113 < b < -1.60000000000000009e-278Initial program 89.3%
Simplified89.1%
Taylor expanded in b around inf 89.1%
+-commutative89.1%
*-commutative89.1%
fma-def89.1%
associate-/l*89.1%
Simplified89.1%
fma-udef89.1%
*-commutative89.1%
associate-*l*89.1%
*-commutative89.1%
Applied egg-rr89.1%
if -1.60000000000000009e-278 < b < 1.99999999999999985e126Initial program 79.8%
associate-*l*79.8%
*-commutative79.8%
associate-/l*79.8%
associate-*l*79.8%
Simplified79.8%
Taylor expanded in b around -inf 80.9%
associate-*r/80.9%
*-commutative80.9%
Simplified80.9%
if 1.99999999999999985e126 < b Initial program 39.6%
Simplified39.5%
Taylor expanded in b around -inf 39.5%
Taylor expanded in a around 0 98.1%
mul-1-neg98.1%
unsub-neg98.1%
Simplified98.1%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (/ -2.0 (+ b b)))))
(if (<= b -1.75e-99)
(if (>= b 0.0)
(/ (- (* a (/ c b)) b) a)
(* c (/ -2.0 (- (+ b b) (* (/ c b) (* a 2.0))))))
(if (<= b -1.6e-278)
(if (>= b 0.0)
(/ (* b -2.0) (* a 2.0))
(/ 2.0 (/ (- (sqrt (* (* a c) -4.0)) b) c)))
(if (<= b 5.2e+125)
(if (>= b 0.0)
(* (/ -0.5 a) (+ b (sqrt (+ (* b b) (* c (* a -4.0))))))
t_0)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_0))))))
double code(double a, double b, double c) {
double t_0 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= -1.75e-99) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = ((a * (c / b)) - b) / a;
} else {
tmp_2 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0))));
}
tmp_1 = tmp_2;
} else if (b <= -1.6e-278) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (b * -2.0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((sqrt(((a * c) * -4.0)) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 5.2e+125) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-0.5 / a) * (b + sqrt(((b * b) + (c * (a * -4.0)))));
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} 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
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = c * ((-2.0d0) / (b + b))
if (b <= (-1.75d-99)) then
if (b >= 0.0d0) then
tmp_2 = ((a * (c / b)) - b) / a
else
tmp_2 = c * ((-2.0d0) / ((b + b) - ((c / b) * (a * 2.0d0))))
end if
tmp_1 = tmp_2
else if (b <= (-1.6d-278)) then
if (b >= 0.0d0) then
tmp_3 = (b * (-2.0d0)) / (a * 2.0d0)
else
tmp_3 = 2.0d0 / ((sqrt(((a * c) * (-4.0d0))) - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 5.2d+125) then
if (b >= 0.0d0) then
tmp_4 = ((-0.5d0) / a) * (b + sqrt(((b * b) + (c * (a * (-4.0d0))))))
else
tmp_4 = t_0
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
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 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= -1.75e-99) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = ((a * (c / b)) - b) / a;
} else {
tmp_2 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0))));
}
tmp_1 = tmp_2;
} else if (b <= -1.6e-278) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (b * -2.0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((Math.sqrt(((a * c) * -4.0)) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 5.2e+125) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-0.5 / a) * (b + Math.sqrt(((b * b) + (c * (a * -4.0)))));
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = c * (-2.0 / (b + b)) tmp_1 = 0 if b <= -1.75e-99: tmp_2 = 0 if b >= 0.0: tmp_2 = ((a * (c / b)) - b) / a else: tmp_2 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0)))) tmp_1 = tmp_2 elif b <= -1.6e-278: tmp_3 = 0 if b >= 0.0: tmp_3 = (b * -2.0) / (a * 2.0) else: tmp_3 = 2.0 / ((math.sqrt(((a * c) * -4.0)) - b) / c) tmp_1 = tmp_3 elif b <= 5.2e+125: tmp_4 = 0 if b >= 0.0: tmp_4 = (-0.5 / a) * (b + math.sqrt(((b * b) + (c * (a * -4.0))))) else: tmp_4 = t_0 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(c * Float64(-2.0 / Float64(b + b))) tmp_1 = 0.0 if (b <= -1.75e-99) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(a * Float64(c / b)) - b) / a); else tmp_2 = Float64(c * Float64(-2.0 / Float64(Float64(b + b) - Float64(Float64(c / b) * Float64(a * 2.0))))); end tmp_1 = tmp_2; elseif (b <= -1.6e-278) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 5.2e+125) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(-0.5 / a) * Float64(b + sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0)))))); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_0; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = c * (-2.0 / (b + b)); tmp_2 = 0.0; if (b <= -1.75e-99) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = ((a * (c / b)) - b) / a; else tmp_3 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0)))); end tmp_2 = tmp_3; elseif (b <= -1.6e-278) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (b * -2.0) / (a * 2.0); else tmp_4 = 2.0 / ((sqrt(((a * c) * -4.0)) - b) / c); end tmp_2 = tmp_4; elseif (b <= 5.2e+125) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-0.5 / a) * (b + sqrt(((b * b) + (c * (a * -4.0))))); else tmp_5 = t_0; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = t_0; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.75e-99], If[GreaterEqual[b, 0.0], N[(N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(-2.0 / N[(N[(b + b), $MachinePrecision] - N[(N[(c / b), $MachinePrecision] * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -1.6e-278], If[GreaterEqual[b, 0.0], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5.2e+125], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \frac{-2}{b + b}\\
\mathbf{if}\;b \leq -1.75 \cdot 10^{-99}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{a \cdot \frac{c}{b} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{\left(b + b\right) - \frac{c}{b} \cdot \left(a \cdot 2\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq -1.6 \cdot 10^{-278}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{\left(a \cdot c\right) \cdot -4} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{+125}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -1.7499999999999999e-99Initial program 69.9%
Simplified69.7%
Taylor expanded in b around inf 69.7%
+-commutative69.7%
*-commutative69.7%
fma-def69.7%
associate-/l*69.7%
Simplified69.7%
Taylor expanded in b around -inf 80.3%
fma-def80.3%
associate-/l*85.2%
mul-1-neg85.2%
Simplified85.2%
associate-*r/85.5%
Applied egg-rr85.5%
associate-*r/85.2%
fma-udef85.2%
associate-/l*80.3%
neg-mul-180.3%
+-commutative80.3%
associate--r+80.3%
cancel-sign-sub-inv80.3%
metadata-eval80.3%
*-lft-identity80.3%
*-commutative80.3%
associate-/l*85.2%
associate-/r/85.2%
associate-*l*85.2%
Simplified85.2%
associate-*l/85.2%
Applied egg-rr85.2%
fma-udef85.2%
*-commutative85.2%
count-285.2%
distribute-rgt-in85.2%
count-285.2%
*-commutative85.2%
associate-*l*85.2%
metadata-eval85.2%
*-commutative85.2%
neg-mul-185.2%
associate-/l*85.2%
*-commutative85.2%
associate-*l*85.2%
associate-/l*85.2%
associate-/r/85.2%
metadata-eval85.2%
Simplified85.2%
if -1.7499999999999999e-99 < b < -1.60000000000000009e-278Initial program 78.6%
associate-*l*78.6%
*-commutative78.6%
associate-/l*78.5%
associate-*l*78.5%
Simplified78.5%
Taylor expanded in b around inf 78.5%
*-commutative78.5%
Simplified78.5%
Taylor expanded in b around 0 67.4%
*-commutative67.4%
Simplified67.4%
if -1.60000000000000009e-278 < b < 5.20000000000000006e125Initial program 79.8%
Simplified79.7%
Taylor expanded in b around -inf 80.7%
fma-udef46.6%
*-commutative46.6%
associate-*l*46.6%
*-commutative46.6%
Applied egg-rr80.7%
if 5.20000000000000006e125 < b Initial program 39.6%
Simplified39.5%
Taylor expanded in b around -inf 39.5%
Taylor expanded in a around 0 98.1%
mul-1-neg98.1%
unsub-neg98.1%
Simplified98.1%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -2.0 (/ c (/ b a))))
(t_1 (sqrt (+ (* b b) (* c (* a -4.0)))))
(t_2 (* c (/ -2.0 (+ b b)))))
(if (<= b -2.2e+116)
(if (>= b 0.0) (* (/ -0.5 a) (+ b (+ b t_0))) (/ (* -2.0 c) (+ b b)))
(if (<= b -1.6e-278)
(if (>= b 0.0) (* (/ -0.5 a) (fma b 2.0 t_0)) (* c (/ -2.0 (- b t_1))))
(if (<= b 4.4e+125)
(if (>= b 0.0) (* (/ -0.5 a) (+ b t_1)) t_2)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_2))))))
double code(double a, double b, double c) {
double t_0 = -2.0 * (c / (b / a));
double t_1 = sqrt(((b * b) + (c * (a * -4.0))));
double t_2 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= -2.2e+116) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + (b + t_0));
} else {
tmp_2 = (-2.0 * c) / (b + b);
}
tmp_1 = tmp_2;
} else if (b <= -1.6e-278) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-0.5 / a) * fma(b, 2.0, t_0);
} else {
tmp_3 = c * (-2.0 / (b - t_1));
}
tmp_1 = tmp_3;
} else if (b <= 4.4e+125) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-0.5 / a) * (b + t_1);
} else {
tmp_4 = t_2;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_2;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(-2.0 * Float64(c / Float64(b / a))) t_1 = sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0)))) t_2 = Float64(c * Float64(-2.0 / Float64(b + b))) tmp_1 = 0.0 if (b <= -2.2e+116) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-0.5 / a) * Float64(b + Float64(b + t_0))); else tmp_2 = Float64(Float64(-2.0 * c) / Float64(b + b)); end tmp_1 = tmp_2; elseif (b <= -1.6e-278) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(-0.5 / a) * fma(b, 2.0, t_0)); else tmp_3 = Float64(c * Float64(-2.0 / Float64(b - t_1))); end tmp_1 = tmp_3; elseif (b <= 4.4e+125) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(-0.5 / a) * Float64(b + t_1)); else tmp_4 = t_2; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_2; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-2.0 * N[(c / N[(b / a), $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[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.2e+116], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -1.6e-278], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b * 2.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4.4e+125], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \frac{c}{\frac{b}{a}}\\
t_1 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\
t_2 := c \cdot \frac{-2}{b + b}\\
\mathbf{if}\;b \leq -2.2 \cdot 10^{+116}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(b + t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot c}{b + b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1.6 \cdot 10^{-278}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \mathsf{fma}\left(b, 2, t_0\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b - t_1}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+125}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if b < -2.2e116Initial program 46.9%
Simplified46.8%
Taylor expanded in b around -inf 92.7%
Taylor expanded in b around inf 92.7%
associate-/l*92.7%
Simplified92.7%
associate-*r/93.0%
cancel-sign-sub-inv93.0%
metadata-eval93.0%
*-un-lft-identity93.0%
Applied egg-rr93.0%
if -2.2e116 < b < -1.60000000000000009e-278Initial program 89.3%
Simplified89.1%
Taylor expanded in b around inf 89.1%
+-commutative89.1%
*-commutative89.1%
fma-def89.1%
associate-/l*89.1%
Simplified89.1%
fma-udef89.1%
*-commutative89.1%
associate-*l*89.1%
*-commutative89.1%
Applied egg-rr89.1%
if -1.60000000000000009e-278 < b < 4.39999999999999982e125Initial program 79.8%
Simplified79.7%
Taylor expanded in b around -inf 80.7%
fma-udef46.6%
*-commutative46.6%
associate-*l*46.6%
*-commutative46.6%
Applied egg-rr80.7%
if 4.39999999999999982e125 < b Initial program 39.6%
Simplified39.5%
Taylor expanded in b around -inf 39.5%
Taylor expanded in a around 0 98.1%
mul-1-neg98.1%
unsub-neg98.1%
Simplified98.1%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -2e+125)
(if (>= b 0.0)
(* (/ -0.5 a) (+ b (+ b (* -2.0 (/ c (/ b a))))))
(/ (* -2.0 c) (+ b b)))
(if (<= b 4e+125)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (* c (/ -2.0 (+ b b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -2e+125) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp_2 = (-2.0 * c) / (b + b);
}
tmp_1 = tmp_2;
} else if (b <= 4e+125) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = c * (-2.0 / (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 * (a * 4.0d0))))
if (b <= (-2d+125)) then
if (b >= 0.0d0) then
tmp_2 = ((-0.5d0) / a) * (b + (b + ((-2.0d0) * (c / (b / a)))))
else
tmp_2 = ((-2.0d0) * c) / (b + b)
end if
tmp_1 = tmp_2
else if (b <= 4d+125) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (a * 2.0d0)
else
tmp_3 = (c * 2.0d0) / (t_0 - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = c * ((-2.0d0) / (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 * (a * 4.0))));
double tmp_1;
if (b <= -2e+125) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp_2 = (-2.0 * c) / (b + b);
}
tmp_1 = tmp_2;
} else if (b <= 4e+125) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = c * (-2.0 / (b + b));
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -2e+125: tmp_2 = 0 if b >= 0.0: tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))) else: tmp_2 = (-2.0 * c) / (b + b) tmp_1 = tmp_2 elif b <= 4e+125: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (a * 2.0) else: tmp_3 = (c * 2.0) / (t_0 - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = c * (-2.0 / (b + b)) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -2e+125) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-0.5 / a) * Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a)))))); else tmp_2 = Float64(Float64(-2.0 * c) / Float64(b + b)); end tmp_1 = tmp_2; elseif (b <= 4e+125) 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(c * 2.0) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(c * Float64(-2.0 / Float64(b + b))); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -2e+125) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))); else tmp_3 = (-2.0 * c) / (b + b); end tmp_2 = tmp_3; elseif (b <= 4e+125) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (a * 2.0); else tmp_4 = (c * 2.0) / (t_0 - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = c * (-2.0 / (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[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2e+125], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[(b + N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4e+125], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+125}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot c}{b + b}\\
\end{array}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+125}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\end{array}
\end{array}
if b < -1.9999999999999998e125Initial program 42.6%
Simplified42.6%
Taylor expanded in b around -inf 92.2%
Taylor expanded in b around inf 92.2%
associate-/l*92.2%
Simplified92.2%
associate-*r/92.4%
cancel-sign-sub-inv92.4%
metadata-eval92.4%
*-un-lft-identity92.4%
Applied egg-rr92.4%
if -1.9999999999999998e125 < b < 3.9999999999999997e125Initial program 84.9%
if 3.9999999999999997e125 < b Initial program 39.6%
Simplified39.5%
Taylor expanded in b around -inf 39.5%
Taylor expanded in a around 0 98.1%
mul-1-neg98.1%
unsub-neg98.1%
Simplified98.1%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (<= b -3.5e+103)
(if (>= b 0.0)
(* (/ -0.5 a) (+ b (+ b (* -2.0 (/ c (/ b a))))))
(/ (* -2.0 c) (+ b b)))
(if (<= b 4e+125)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ 2.0 (/ (- t_0 b) c)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (* c (/ -2.0 (+ b b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp_1;
if (b <= -3.5e+103) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp_2 = (-2.0 * c) / (b + b);
}
tmp_1 = tmp_2;
} else if (b <= 4e+125) {
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 = (c / b) - (b / a);
} else {
tmp_1 = c * (-2.0 / (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) - (4.0d0 * (a * c))))
if (b <= (-3.5d+103)) then
if (b >= 0.0d0) then
tmp_2 = ((-0.5d0) / a) * (b + (b + ((-2.0d0) * (c / (b / a)))))
else
tmp_2 = ((-2.0d0) * c) / (b + b)
end if
tmp_1 = tmp_2
else if (b <= 4d+125) 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 = (c / b) - (b / a)
else
tmp_1 = c * ((-2.0d0) / (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) - (4.0 * (a * c))));
double tmp_1;
if (b <= -3.5e+103) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp_2 = (-2.0 * c) / (b + b);
}
tmp_1 = tmp_2;
} else if (b <= 4e+125) {
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 = (c / b) - (b / a);
} else {
tmp_1 = c * (-2.0 / (b + b));
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp_1 = 0 if b <= -3.5e+103: tmp_2 = 0 if b >= 0.0: tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))) else: tmp_2 = (-2.0 * c) / (b + b) tmp_1 = tmp_2 elif b <= 4e+125: 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 = (c / b) - (b / a) else: tmp_1 = c * (-2.0 / (b + b)) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp_1 = 0.0 if (b <= -3.5e+103) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-0.5 / a) * Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a)))))); else tmp_2 = Float64(Float64(-2.0 * c) / Float64(b + b)); end tmp_1 = tmp_2; elseif (b <= 4e+125) 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(c / b) - Float64(b / a)); else tmp_1 = Float64(c * Float64(-2.0 / Float64(b + b))); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); tmp_2 = 0.0; if (b <= -3.5e+103) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))); else tmp_3 = (-2.0 * c) / (b + b); end tmp_2 = tmp_3; elseif (b <= 4e+125) 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 = (c / b) - (b / a); else tmp_2 = c * (-2.0 / (b + b)); 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]}, If[LessEqual[b, -3.5e+103], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[(b + N[(-2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4e+125], 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[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b \leq -3.5 \cdot 10^{+103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot c}{b + b}\\
\end{array}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+125}:\\
\;\;\;\;\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{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\end{array}
\end{array}
if b < -3.5e103Initial program 50.6%
Simplified50.6%
Taylor expanded in b around -inf 93.2%
Taylor expanded in b around inf 93.2%
associate-/l*93.2%
Simplified93.2%
associate-*r/93.5%
cancel-sign-sub-inv93.5%
metadata-eval93.5%
*-un-lft-identity93.5%
Applied egg-rr93.5%
if -3.5e103 < b < 3.9999999999999997e125Initial program 84.1%
associate-*l*84.1%
*-commutative84.1%
associate-/l*83.7%
associate-*l*83.7%
Simplified83.7%
if 3.9999999999999997e125 < b Initial program 39.6%
Simplified39.5%
Taylor expanded in b around -inf 39.5%
Taylor expanded in a around 0 98.1%
mul-1-neg98.1%
unsub-neg98.1%
Simplified98.1%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (/ -2.0 (+ b b)))))
(if (<= b -1.7e-94)
(if (>= b 0.0)
(/ (- (* a (/ c b)) b) a)
(* c (/ -2.0 (- (+ b b) (* (/ c b) (* a 2.0))))))
(if (<= b -1.6e-278)
(if (>= b 0.0)
(/ (* b -2.0) (* a 2.0))
(/ 2.0 (/ (- (sqrt (* (* a c) -4.0)) b) c)))
(if (<= b 8.4e-50)
(if (>= b 0.0) (* (/ -0.5 a) (+ b (sqrt (* c (* a -4.0))))) t_0)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_0))))))
double code(double a, double b, double c) {
double t_0 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= -1.7e-94) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = ((a * (c / b)) - b) / a;
} else {
tmp_2 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0))));
}
tmp_1 = tmp_2;
} else if (b <= -1.6e-278) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (b * -2.0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((sqrt(((a * c) * -4.0)) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 8.4e-50) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-0.5 / a) * (b + sqrt((c * (a * -4.0))));
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} 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
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = c * ((-2.0d0) / (b + b))
if (b <= (-1.7d-94)) then
if (b >= 0.0d0) then
tmp_2 = ((a * (c / b)) - b) / a
else
tmp_2 = c * ((-2.0d0) / ((b + b) - ((c / b) * (a * 2.0d0))))
end if
tmp_1 = tmp_2
else if (b <= (-1.6d-278)) then
if (b >= 0.0d0) then
tmp_3 = (b * (-2.0d0)) / (a * 2.0d0)
else
tmp_3 = 2.0d0 / ((sqrt(((a * c) * (-4.0d0))) - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 8.4d-50) then
if (b >= 0.0d0) then
tmp_4 = ((-0.5d0) / a) * (b + sqrt((c * (a * (-4.0d0)))))
else
tmp_4 = t_0
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
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 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= -1.7e-94) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = ((a * (c / b)) - b) / a;
} else {
tmp_2 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0))));
}
tmp_1 = tmp_2;
} else if (b <= -1.6e-278) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (b * -2.0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((Math.sqrt(((a * c) * -4.0)) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 8.4e-50) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-0.5 / a) * (b + Math.sqrt((c * (a * -4.0))));
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = c * (-2.0 / (b + b)) tmp_1 = 0 if b <= -1.7e-94: tmp_2 = 0 if b >= 0.0: tmp_2 = ((a * (c / b)) - b) / a else: tmp_2 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0)))) tmp_1 = tmp_2 elif b <= -1.6e-278: tmp_3 = 0 if b >= 0.0: tmp_3 = (b * -2.0) / (a * 2.0) else: tmp_3 = 2.0 / ((math.sqrt(((a * c) * -4.0)) - b) / c) tmp_1 = tmp_3 elif b <= 8.4e-50: tmp_4 = 0 if b >= 0.0: tmp_4 = (-0.5 / a) * (b + math.sqrt((c * (a * -4.0)))) else: tmp_4 = t_0 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(c * Float64(-2.0 / Float64(b + b))) tmp_1 = 0.0 if (b <= -1.7e-94) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(a * Float64(c / b)) - b) / a); else tmp_2 = Float64(c * Float64(-2.0 / Float64(Float64(b + b) - Float64(Float64(c / b) * Float64(a * 2.0))))); end tmp_1 = tmp_2; elseif (b <= -1.6e-278) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 8.4e-50) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(-0.5 / a) * Float64(b + sqrt(Float64(c * Float64(a * -4.0))))); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_0; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = c * (-2.0 / (b + b)); tmp_2 = 0.0; if (b <= -1.7e-94) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = ((a * (c / b)) - b) / a; else tmp_3 = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0)))); end tmp_2 = tmp_3; elseif (b <= -1.6e-278) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (b * -2.0) / (a * 2.0); else tmp_4 = 2.0 / ((sqrt(((a * c) * -4.0)) - b) / c); end tmp_2 = tmp_4; elseif (b <= 8.4e-50) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-0.5 / a) * (b + sqrt((c * (a * -4.0)))); else tmp_5 = t_0; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = t_0; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.7e-94], If[GreaterEqual[b, 0.0], N[(N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(-2.0 / N[(N[(b + b), $MachinePrecision] - N[(N[(c / b), $MachinePrecision] * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -1.6e-278], If[GreaterEqual[b, 0.0], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 8.4e-50], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \frac{-2}{b + b}\\
\mathbf{if}\;b \leq -1.7 \cdot 10^{-94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{a \cdot \frac{c}{b} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{\left(b + b\right) - \frac{c}{b} \cdot \left(a \cdot 2\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq -1.6 \cdot 10^{-278}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{\left(a \cdot c\right) \cdot -4} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 8.4 \cdot 10^{-50}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -1.6999999999999999e-94Initial program 69.9%
Simplified69.7%
Taylor expanded in b around inf 69.7%
+-commutative69.7%
*-commutative69.7%
fma-def69.7%
associate-/l*69.7%
Simplified69.7%
Taylor expanded in b around -inf 80.3%
fma-def80.3%
associate-/l*85.2%
mul-1-neg85.2%
Simplified85.2%
associate-*r/85.5%
Applied egg-rr85.5%
associate-*r/85.2%
fma-udef85.2%
associate-/l*80.3%
neg-mul-180.3%
+-commutative80.3%
associate--r+80.3%
cancel-sign-sub-inv80.3%
metadata-eval80.3%
*-lft-identity80.3%
*-commutative80.3%
associate-/l*85.2%
associate-/r/85.2%
associate-*l*85.2%
Simplified85.2%
associate-*l/85.2%
Applied egg-rr85.2%
fma-udef85.2%
*-commutative85.2%
count-285.2%
distribute-rgt-in85.2%
count-285.2%
*-commutative85.2%
associate-*l*85.2%
metadata-eval85.2%
*-commutative85.2%
neg-mul-185.2%
associate-/l*85.2%
*-commutative85.2%
associate-*l*85.2%
associate-/l*85.2%
associate-/r/85.2%
metadata-eval85.2%
Simplified85.2%
if -1.6999999999999999e-94 < b < -1.60000000000000009e-278Initial program 78.6%
associate-*l*78.6%
*-commutative78.6%
associate-/l*78.5%
associate-*l*78.5%
Simplified78.5%
Taylor expanded in b around inf 78.5%
*-commutative78.5%
Simplified78.5%
Taylor expanded in b around 0 67.4%
*-commutative67.4%
Simplified67.4%
if -1.60000000000000009e-278 < b < 8.4000000000000003e-50Initial program 72.1%
Simplified72.0%
Taylor expanded in b around -inf 73.8%
fma-udef22.4%
*-commutative22.4%
associate-*l*22.4%
*-commutative22.4%
Applied egg-rr73.8%
Taylor expanded in b around 0 63.8%
*-commutative63.8%
associate-*r*63.8%
Simplified63.8%
if 8.4000000000000003e-50 < b Initial program 59.8%
Simplified59.7%
Taylor expanded in b around -inf 59.7%
Taylor expanded in a around 0 91.7%
mul-1-neg91.7%
unsub-neg91.7%
Simplified91.7%
Final simplification81.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (/ -2.0 (+ b b)))))
(if (<= b 7.5e-56)
(if (>= b 0.0) (* (/ -0.5 a) (+ b (sqrt (* c (* a -4.0))))) t_0)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_0))))
double code(double a, double b, double c) {
double t_0 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= 7.5e-56) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + sqrt((c * (a * -4.0))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} 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 = c * ((-2.0d0) / (b + b))
if (b <= 7.5d-56) then
if (b >= 0.0d0) then
tmp_2 = ((-0.5d0) / a) * (b + sqrt((c * (a * (-4.0d0)))))
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
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 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= 7.5e-56) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-0.5 / a) * (b + Math.sqrt((c * (a * -4.0))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = c * (-2.0 / (b + b)) tmp_1 = 0 if b <= 7.5e-56: tmp_2 = 0 if b >= 0.0: tmp_2 = (-0.5 / a) * (b + math.sqrt((c * (a * -4.0)))) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(c * Float64(-2.0 / Float64(b + b))) tmp_1 = 0.0 if (b <= 7.5e-56) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-0.5 / a) * Float64(b + sqrt(Float64(c * Float64(a * -4.0))))); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = c * (-2.0 / (b + b)); tmp_2 = 0.0; if (b <= 7.5e-56) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-0.5 / a) * (b + sqrt((c * (a * -4.0)))); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 7.5e-56], If[GreaterEqual[b, 0.0], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \frac{-2}{b + b}\\
\mathbf{if}\;b \leq 7.5 \cdot 10^{-56}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 7.50000000000000041e-56Initial program 71.9%
Simplified71.8%
Taylor expanded in b around -inf 71.6%
fma-udef58.7%
*-commutative58.7%
associate-*l*58.7%
*-commutative58.7%
Applied egg-rr71.6%
Taylor expanded in b around 0 69.0%
*-commutative69.0%
associate-*r*69.0%
Simplified69.0%
if 7.50000000000000041e-56 < b Initial program 59.8%
Simplified59.7%
Taylor expanded in b around -inf 59.7%
Taylor expanded in a around 0 91.7%
mul-1-neg91.7%
unsub-neg91.7%
Simplified91.7%
Final simplification76.2%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (* a (/ c b)) b) a) (* c (/ -2.0 (- (+ b b) (* (/ c b) (* a 2.0)))))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = ((a * (c / b)) - b) / a;
} else {
tmp = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0))));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = ((a * (c / b)) - b) / a
else
tmp = c * ((-2.0d0) / ((b + b) - ((c / b) * (a * 2.0d0))))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = ((a * (c / b)) - b) / a;
} else {
tmp = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0))));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = ((a * (c / b)) - b) / a else: tmp = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0)))) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(a * Float64(c / b)) - b) / a); else tmp = Float64(c * Float64(-2.0 / Float64(Float64(b + b) - Float64(Float64(c / b) * Float64(a * 2.0))))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = ((a * (c / b)) - b) / a; else tmp = c * (-2.0 / ((b + b) - ((c / b) * (a * 2.0)))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(-2.0 / N[(N[(b + b), $MachinePrecision] - N[(N[(c / b), $MachinePrecision] * N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{a \cdot \frac{c}{b} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{\left(b + b\right) - \frac{c}{b} \cdot \left(a \cdot 2\right)}\\
\end{array}
\end{array}
Initial program 68.1%
Simplified68.0%
Taylor expanded in b around inf 67.6%
+-commutative67.6%
*-commutative67.6%
fma-def67.6%
associate-/l*69.1%
Simplified69.1%
Taylor expanded in b around -inf 67.2%
fma-def67.2%
associate-/l*69.2%
mul-1-neg69.2%
Simplified69.2%
associate-*r/69.3%
Applied egg-rr69.3%
associate-*r/69.2%
fma-udef69.2%
associate-/l*67.2%
neg-mul-167.2%
+-commutative67.2%
associate--r+67.2%
cancel-sign-sub-inv67.2%
metadata-eval67.2%
*-lft-identity67.2%
*-commutative67.2%
associate-/l*69.2%
associate-/r/69.2%
associate-*l*69.2%
Simplified69.2%
associate-*l/69.3%
Applied egg-rr69.3%
fma-udef69.3%
*-commutative69.3%
count-269.3%
distribute-rgt-in69.3%
count-269.3%
*-commutative69.3%
associate-*l*69.3%
metadata-eval69.3%
*-commutative69.3%
neg-mul-169.3%
associate-/l*67.8%
*-commutative67.8%
associate-*l*67.8%
associate-/l*69.3%
associate-/r/69.3%
metadata-eval69.3%
Simplified69.3%
Final simplification69.3%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* b -2.0) (* a 2.0)) (* c (/ 2.0 (* b -2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (b * -2.0) / (a * 2.0);
} else {
tmp = c * (2.0 / (b * -2.0));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (b * (-2.0d0)) / (a * 2.0d0)
else
tmp = c * (2.0d0 / (b * (-2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (b * -2.0) / (a * 2.0);
} else {
tmp = c * (2.0 / (b * -2.0));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (b * -2.0) / (a * 2.0) else: tmp = c * (2.0 / (b * -2.0)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(b * -2.0) / Float64(a * 2.0)); else tmp = Float64(c * Float64(2.0 / Float64(b * -2.0))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (b * -2.0) / (a * 2.0); else tmp = c * (2.0 / (b * -2.0)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b \cdot -2}\\
\end{array}
\end{array}
Initial program 68.1%
associate-*l*68.1%
*-commutative68.1%
associate-/l*67.9%
associate-*l*67.9%
Simplified67.9%
Taylor expanded in b around inf 68.9%
*-commutative68.9%
Simplified68.9%
Taylor expanded in b around -inf 68.6%
associate-*r/67.6%
*-commutative67.6%
Simplified68.6%
associate-/r/68.9%
*-commutative68.9%
Applied egg-rr68.9%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (- (/ c b) (/ b a)) (* c (/ -2.0 (+ b b)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c / b) - (b / a);
} else {
tmp = c * (-2.0 / (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 = (c / b) - (b / a)
else
tmp = c * ((-2.0d0) / (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 = (c / b) - (b / a);
} else {
tmp = c * (-2.0 / (b + b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c / b) - (b / a) else: tmp = c * (-2.0 / (b + b)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(c * Float64(-2.0 / Float64(b + b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c / b) - (b / a); else tmp = c * (-2.0 / (b + b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\end{array}
\end{array}
Initial program 68.1%
Simplified68.0%
Taylor expanded in b around -inf 67.9%
Taylor expanded in a around 0 69.1%
mul-1-neg69.1%
unsub-neg69.1%
Simplified69.1%
Final simplification69.1%
herbie shell --seed 2023171
(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)))))))