
(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 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) (/ (- (- 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 (if (>= b 0.0) (/ (- b) a) (- (/ c b)))))
(if (<= b -1.25e+154)
t_0
(if (<= b -4.2e-306)
(if (>= b 0.0)
(+ (- (/ c b) (/ b a)) (* a (/ c (/ (pow b 3.0) c))))
(/ (* c 2.0) (- (sqrt (- (* b b) (* c (* a 4.0)))) b)))
(if (<= b 5e+108)
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* a 2.0))
(/ 2.0 (/ (* b -2.0) c)))
t_0)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -b / a;
} else {
tmp = -(c / b);
}
double t_0 = tmp;
double tmp_1;
if (b <= -1.25e+154) {
tmp_1 = t_0;
} else if (b <= -4.2e-306) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = ((c / b) - (b / a)) + (a * (c / (pow(b, 3.0) / c)));
} else {
tmp_2 = (c * 2.0) / (sqrt(((b * b) - (c * (a * 4.0)))) - b);
}
tmp_1 = tmp_2;
} else if (b <= 5e+108) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((b * -2.0) / c);
}
tmp_1 = tmp_3;
} 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
if (b >= 0.0d0) then
tmp = -b / a
else
tmp = -(c / b)
end if
t_0 = tmp
if (b <= (-1.25d+154)) then
tmp_1 = t_0
else if (b <= (-4.2d-306)) then
if (b >= 0.0d0) then
tmp_2 = ((c / b) - (b / a)) + (a * (c / ((b ** 3.0d0) / c)))
else
tmp_2 = (c * 2.0d0) / (sqrt(((b * b) - (c * (a * 4.0d0)))) - b)
end if
tmp_1 = tmp_2
else if (b <= 5d+108) then
if (b >= 0.0d0) then
tmp_3 = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (a * 2.0d0)
else
tmp_3 = 2.0d0 / ((b * (-2.0d0)) / c)
end if
tmp_1 = tmp_3
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -b / a;
} else {
tmp = -(c / b);
}
double t_0 = tmp;
double tmp_1;
if (b <= -1.25e+154) {
tmp_1 = t_0;
} else if (b <= -4.2e-306) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = ((c / b) - (b / a)) + (a * (c / (Math.pow(b, 3.0) / c)));
} else {
tmp_2 = (c * 2.0) / (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b);
}
tmp_1 = tmp_2;
} else if (b <= 5e+108) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((b * -2.0) / c);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -b / a else: tmp = -(c / b) t_0 = tmp tmp_1 = 0 if b <= -1.25e+154: tmp_1 = t_0 elif b <= -4.2e-306: tmp_2 = 0 if b >= 0.0: tmp_2 = ((c / b) - (b / a)) + (a * (c / (math.pow(b, 3.0) / c))) else: tmp_2 = (c * 2.0) / (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) tmp_1 = tmp_2 elif b <= 5e+108: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0) else: tmp_3 = 2.0 / ((b * -2.0) / c) tmp_1 = tmp_3 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(-b) / a); else tmp = Float64(-Float64(c / b)); end t_0 = tmp tmp_1 = 0.0 if (b <= -1.25e+154) tmp_1 = t_0; elseif (b <= -4.2e-306) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(c / b) - Float64(b / a)) + Float64(a * Float64(c / Float64((b ^ 3.0) / c)))); else tmp_2 = Float64(Float64(c * 2.0) / Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b)); end tmp_1 = tmp_2; elseif (b <= 5e+108) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(a * 2.0)); else tmp_3 = Float64(2.0 / Float64(Float64(b * -2.0) / c)); end tmp_1 = tmp_3; else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -b / a; else tmp = -(c / b); end t_0 = tmp; tmp_2 = 0.0; if (b <= -1.25e+154) tmp_2 = t_0; elseif (b <= -4.2e-306) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = ((c / b) - (b / a)) + (a * (c / ((b ^ 3.0) / c))); else tmp_3 = (c * 2.0) / (sqrt(((b * b) - (c * (a * 4.0)))) - b); end tmp_2 = tmp_3; elseif (b <= 5e+108) tmp_4 = 0.0; 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); end tmp_2 = tmp_4; else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0.0], N[((-b) / a), $MachinePrecision], (-N[(c / b), $MachinePrecision])]}, If[LessEqual[b, -1.25e+154], t$95$0, If[LessEqual[b, -4.2e-306], If[GreaterEqual[b, 0.0], N[(N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(a * N[(c / N[(N[Power[b, 3.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5e+108], 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]], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{if}\;b \leq -1.25 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq -4.2 \cdot 10^{-306}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) + a \cdot \frac{c}{\frac{{b}^{3}}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+108}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -1.25000000000000001e154 or 4.99999999999999991e108 < b Initial program 49.6%
Simplified49.6%
Taylor expanded in b around -inf 71.7%
associate-*r/71.7%
neg-mul-171.7%
Simplified71.7%
Taylor expanded in b around inf 96.2%
Taylor expanded in a around 0 96.3%
associate-*r/96.3%
neg-mul-196.3%
Simplified96.3%
if -1.25000000000000001e154 < b < -4.2000000000000002e-306Initial program 89.9%
Taylor expanded in b around inf 89.9%
+-commutative89.9%
mul-1-neg89.9%
unsub-neg89.9%
associate-/l*89.9%
unpow289.9%
Simplified89.9%
Taylor expanded in c around 0 89.9%
associate-*l/89.9%
unpow289.9%
*-commutative89.9%
associate-/l*89.9%
Simplified89.9%
if -4.2000000000000002e-306 < b < 4.99999999999999991e108Initial program 83.4%
associate-*l*83.4%
*-commutative83.4%
associate-/l*83.4%
associate-*l*83.4%
Simplified83.4%
Taylor expanded in b around -inf 83.4%
*-commutative83.4%
Simplified83.4%
Final simplification90.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (or (<= b -1.25e+154) (not (<= b 2e+106)))
(if (>= b 0.0) (/ (- b) a) (- (/ c b)))
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if ((b <= -1.25e+154) || !(b <= 2e+106)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -b / a;
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - t_0) / (a * 2.0);
} else {
tmp_1 = (c * 2.0) / (t_0 - 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
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if ((b <= (-1.25d+154)) .or. (.not. (b <= 2d+106))) then
if (b >= 0.0d0) then
tmp_2 = -b / a
else
tmp_2 = -(c / b)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (-b - t_0) / (a * 2.0d0)
else
tmp_1 = (c * 2.0d0) / (t_0 - 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 <= -1.25e+154) || !(b <= 2e+106)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -b / a;
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - t_0) / (a * 2.0);
} else {
tmp_1 = (c * 2.0) / (t_0 - b);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if (b <= -1.25e+154) or not (b <= 2e+106): tmp_2 = 0 if b >= 0.0: tmp_2 = -b / a else: tmp_2 = -(c / b) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (-b - t_0) / (a * 2.0) else: tmp_1 = (c * 2.0) / (t_0 - 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 <= -1.25e+154) || !(b <= 2e+106)) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-b) / a); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_1 = Float64(Float64(c * 2.0) / Float64(t_0 - b)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if ((b <= -1.25e+154) || ~((b <= 2e+106))) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -b / a; else tmp_3 = -(c / b); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (-b - t_0) / (a * 2.0); else tmp_2 = (c * 2.0) / (t_0 - b); end tmp_4 = 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[Or[LessEqual[b, -1.25e+154], N[Not[LessEqual[b, 2e+106]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-b) / a), $MachinePrecision], (-N[(c / b), $MachinePrecision])], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -1.25 \cdot 10^{+154} \lor \neg \left(b \leq 2 \cdot 10^{+106}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}
\end{array}
if b < -1.25000000000000001e154 or 2.00000000000000018e106 < b Initial program 49.6%
Simplified49.6%
Taylor expanded in b around -inf 71.7%
associate-*r/71.7%
neg-mul-171.7%
Simplified71.7%
Taylor expanded in b around inf 96.2%
Taylor expanded in a around 0 96.3%
associate-*r/96.3%
neg-mul-196.3%
Simplified96.3%
if -1.25000000000000001e154 < b < 2.00000000000000018e106Initial program 86.9%
Final simplification90.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (or (<= b -3.6e+109) (not (<= b 8e+108)))
(if (>= b 0.0) (/ (- b) a) (- (/ c b)))
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ 2.0 (/ (- t_0 b) c))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp_1;
if ((b <= -3.6e+109) || !(b <= 8e+108)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -b / a;
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - t_0) / (a * 2.0);
} else {
tmp_1 = 2.0 / ((t_0 - b) / c);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
if ((b <= (-3.6d+109)) .or. (.not. (b <= 8d+108))) then
if (b >= 0.0d0) then
tmp_2 = -b / a
else
tmp_2 = -(c / b)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (-b - t_0) / (a * 2.0d0)
else
tmp_1 = 2.0d0 / ((t_0 - b) / c)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double tmp_1;
if ((b <= -3.6e+109) || !(b <= 8e+108)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -b / a;
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - t_0) / (a * 2.0);
} else {
tmp_1 = 2.0 / ((t_0 - b) / c);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp_1 = 0 if (b <= -3.6e+109) or not (b <= 8e+108): tmp_2 = 0 if b >= 0.0: tmp_2 = -b / a else: tmp_2 = -(c / b) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (-b - t_0) / (a * 2.0) else: tmp_1 = 2.0 / ((t_0 - b) / c) 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.6e+109) || !(b <= 8e+108)) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-b) / a); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_1 = Float64(2.0 / Float64(Float64(t_0 - b) / c)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); tmp_2 = 0.0; if ((b <= -3.6e+109) || ~((b <= 8e+108))) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -b / a; else tmp_3 = -(c / b); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (-b - t_0) / (a * 2.0); else tmp_2 = 2.0 / ((t_0 - b) / c); end tmp_4 = 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[Or[LessEqual[b, -3.6e+109], N[Not[LessEqual[b, 8e+108]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-b) / a), $MachinePrecision], (-N[(c / b), $MachinePrecision])], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b \leq -3.6 \cdot 10^{+109} \lor \neg \left(b \leq 8 \cdot 10^{+108}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_0 - b}{c}}\\
\end{array}
\end{array}
if b < -3.6e109 or 8.0000000000000003e108 < b Initial program 53.8%
Simplified53.7%
Taylor expanded in b around -inf 74.0%
associate-*r/74.0%
neg-mul-174.0%
Simplified74.0%
Taylor expanded in b around inf 96.6%
Taylor expanded in a around 0 96.6%
associate-*r/96.6%
neg-mul-196.6%
Simplified96.6%
if -3.6e109 < b < 8.0000000000000003e108Initial program 86.1%
associate-*l*86.1%
*-commutative86.1%
associate-/l*86.0%
associate-*l*86.0%
Simplified86.0%
Final simplification90.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (/ c b))))
(if (<= b -1.32e+154)
(if (>= b 0.0) (/ (- b) a) t_0)
(if (<= b -4.2e-306)
(if (>= b 0.0)
(+ (- (/ c b) (/ b a)) (* a (/ c (/ (pow b 3.0) c))))
(/ (* c 2.0) (- (sqrt (- (* b b) (* c (* a 4.0)))) b)))
(if (<= b 1.62e-114)
(if (>= b 0.0) (* -0.5 (/ (+ b (sqrt (* a (/ c -0.25)))) a)) t_0)
(if (>= b 0.0)
(/ (* -0.5 (+ b (fma -2.0 (* a (/ c b)) b))) a)
(* c (/ -2.0 (fma b 2.0 (/ (* (* a c) -2.0) b))))))))))
double code(double a, double b, double c) {
double t_0 = -(c / b);
double tmp_1;
if (b <= -1.32e+154) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -b / a;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -4.2e-306) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = ((c / b) - (b / a)) + (a * (c / (pow(b, 3.0) / c)));
} else {
tmp_3 = (c * 2.0) / (sqrt(((b * b) - (c * (a * 4.0)))) - b);
}
tmp_1 = tmp_3;
} else if (b <= 1.62e-114) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -0.5 * ((b + sqrt((a * (c / -0.25)))) / a);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-0.5 * (b + fma(-2.0, (a * (c / b)), b))) / a;
} else {
tmp_1 = c * (-2.0 / fma(b, 2.0, (((a * c) * -2.0) / b)));
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(-Float64(c / b)) tmp_1 = 0.0 if (b <= -1.32e+154) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-b) / a); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -4.2e-306) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(c / b) - Float64(b / a)) + Float64(a * Float64(c / Float64((b ^ 3.0) / c)))); else tmp_3 = Float64(Float64(c * 2.0) / Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b)); end tmp_1 = tmp_3; elseif (b <= 1.62e-114) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(a * Float64(c / -0.25)))) / a)); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(-0.5 * Float64(b + fma(-2.0, Float64(a * Float64(c / b)), b))) / a); else tmp_1 = Float64(c * Float64(-2.0 / fma(b, 2.0, Float64(Float64(Float64(a * c) * -2.0) / b)))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = (-N[(c / b), $MachinePrecision])}, If[LessEqual[b, -1.32e+154], If[GreaterEqual[b, 0.0], N[((-b) / a), $MachinePrecision], t$95$0], If[LessEqual[b, -4.2e-306], If[GreaterEqual[b, 0.0], N[(N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(a * N[(c / N[(N[Power[b, 3.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.62e-114], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + N[Sqrt[N[(a * N[(c / -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(-0.5 * N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(-2.0 / N[(b * 2.0 + N[(N[(N[(a * c), $MachinePrecision] * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{c}{b}\\
\mathbf{if}\;b \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq -4.2 \cdot 10^{-306}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) + a \cdot \frac{c}{\frac{{b}^{3}}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.62 \cdot 10^{-114}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{a \cdot \frac{c}{-0.25}}}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-0.5 \cdot \left(b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{\mathsf{fma}\left(b, 2, \frac{\left(a \cdot c\right) \cdot -2}{b}\right)}\\
\end{array}
\end{array}
if b < -1.31999999999999998e154Initial program 40.5%
Simplified40.5%
Taylor expanded in b around -inf 97.6%
associate-*r/97.6%
neg-mul-197.6%
Simplified97.6%
Taylor expanded in b around inf 97.6%
Taylor expanded in a around 0 97.6%
associate-*r/97.6%
neg-mul-197.6%
Simplified97.6%
if -1.31999999999999998e154 < b < -4.2000000000000002e-306Initial program 89.9%
Taylor expanded in b around inf 89.9%
+-commutative89.9%
mul-1-neg89.9%
unsub-neg89.9%
associate-/l*89.9%
unpow289.9%
Simplified89.9%
Taylor expanded in c around 0 89.9%
associate-*l/89.9%
unpow289.9%
*-commutative89.9%
associate-/l*89.9%
Simplified89.9%
if -4.2000000000000002e-306 < b < 1.62e-114Initial program 67.2%
Simplified67.1%
Taylor expanded in b around -inf 67.1%
associate-*r/67.1%
neg-mul-167.1%
Simplified67.1%
pow1/267.1%
pow-to-exp62.7%
Applied egg-rr62.7%
Taylor expanded in a around -inf 31.7%
mul-1-neg31.7%
unsub-neg31.7%
*-commutative31.7%
Simplified31.7%
Taylor expanded in a around 0 0.2%
Simplified61.2%
if 1.62e-114 < b Initial program 71.1%
Simplified71.0%
Taylor expanded in b around inf 83.8%
+-commutative83.8%
fma-def83.8%
associate-/l*85.8%
Simplified85.8%
associate-*l/85.9%
associate-/r/85.9%
Applied egg-rr85.9%
Taylor expanded in b around -inf 85.9%
+-commutative85.9%
*-commutative85.9%
fma-def85.9%
associate-*r/85.9%
Simplified85.9%
Final simplification86.4%
(FPCore (a b c)
:precision binary64
(if (<= b 1.62e-114)
(if (>= b 0.0) (* -0.5 (/ (+ b (sqrt (* a (/ c -0.25)))) a)) (- (/ c b)))
(if (>= b 0.0)
(/ (* -0.5 (+ b (fma -2.0 (* a (/ c b)) b))) a)
(* c (/ -2.0 (fma b 2.0 (/ (* (* a c) -2.0) b)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.62e-114) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * ((b + sqrt((a * (c / -0.25)))) / a);
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-0.5 * (b + fma(-2.0, (a * (c / b)), b))) / a;
} else {
tmp_1 = c * (-2.0 / fma(b, 2.0, (((a * c) * -2.0) / b)));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= 1.62e-114) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(a * Float64(c / -0.25)))) / a)); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(-0.5 * Float64(b + fma(-2.0, Float64(a * Float64(c / b)), b))) / a); else tmp_1 = Float64(c * Float64(-2.0 / fma(b, 2.0, Float64(Float64(Float64(a * c) * -2.0) / b)))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, 1.62e-114], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + N[Sqrt[N[(a * N[(c / -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])], If[GreaterEqual[b, 0.0], N[(N[(-0.5 * N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(-2.0 / N[(b * 2.0 + N[(N[(N[(a * c), $MachinePrecision] * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.62 \cdot 10^{-114}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{a \cdot \frac{c}{-0.25}}}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-0.5 \cdot \left(b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{\mathsf{fma}\left(b, 2, \frac{\left(a \cdot c\right) \cdot -2}{b}\right)}\\
\end{array}
\end{array}
if b < 1.62e-114Initial program 73.0%
Simplified72.2%
Taylor expanded in b around -inf 65.1%
associate-*r/65.1%
neg-mul-165.1%
Simplified65.1%
pow1/265.1%
pow-to-exp64.3%
Applied egg-rr64.3%
Taylor expanded in a around -inf 58.7%
mul-1-neg58.7%
unsub-neg58.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in a around 0 53.0%
Simplified64.0%
if 1.62e-114 < b Initial program 71.1%
Simplified71.0%
Taylor expanded in b around inf 83.8%
+-commutative83.8%
fma-def83.8%
associate-/l*85.8%
Simplified85.8%
associate-*l/85.9%
associate-/r/85.9%
Applied egg-rr85.9%
Taylor expanded in b around -inf 85.9%
+-commutative85.9%
*-commutative85.9%
fma-def85.9%
associate-*r/85.9%
Simplified85.9%
Final simplification73.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (/ c b))))
(if (<= b 1.62e-114)
(if (>= b 0.0) (* -0.5 (/ (+ b (sqrt (* a (/ c -0.25)))) a)) t_0)
(if (>= b 0.0) (* (/ -0.5 a) (+ b (+ b (* -2.0 (/ c (/ b a)))))) t_0))))
double code(double a, double b, double c) {
double t_0 = -(c / b);
double tmp_1;
if (b <= 1.62e-114) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * ((b + sqrt((a * (c / -0.25)))) / a);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-0.5 / a) * (b + (b + (-2.0 * (c / (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 / b)
if (b <= 1.62d-114) then
if (b >= 0.0d0) then
tmp_2 = (-0.5d0) * ((b + sqrt((a * (c / (-0.25d0))))) / a)
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = ((-0.5d0) / a) * (b + (b + ((-2.0d0) * (c / (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 / b);
double tmp_1;
if (b <= 1.62e-114) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * ((b + Math.sqrt((a * (c / -0.25)))) / a);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -(c / b) tmp_1 = 0 if b <= 1.62e-114: tmp_2 = 0 if b >= 0.0: tmp_2 = -0.5 * ((b + math.sqrt((a * (c / -0.25)))) / a) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(-Float64(c / b)) tmp_1 = 0.0 if (b <= 1.62e-114) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(a * Float64(c / -0.25)))) / a)); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(-0.5 / a) * Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a)))))); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = -(c / b); tmp_2 = 0.0; if (b <= 1.62e-114) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -0.5 * ((b + sqrt((a * (c / -0.25)))) / a); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = (-N[(c / b), $MachinePrecision])}, If[LessEqual[b, 1.62e-114], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + N[Sqrt[N[(a * N[(c / -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$0], 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], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{c}{b}\\
\mathbf{if}\;b \leq 1.62 \cdot 10^{-114}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{a \cdot \frac{c}{-0.25}}}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 1.62e-114Initial program 73.0%
Simplified72.2%
Taylor expanded in b around -inf 65.1%
associate-*r/65.1%
neg-mul-165.1%
Simplified65.1%
pow1/265.1%
pow-to-exp64.3%
Applied egg-rr64.3%
Taylor expanded in a around -inf 58.7%
mul-1-neg58.7%
unsub-neg58.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in a around 0 53.0%
Simplified64.0%
if 1.62e-114 < b Initial program 71.1%
Simplified71.0%
Taylor expanded in b around -inf 71.0%
associate-*r/71.0%
neg-mul-171.0%
Simplified71.0%
Taylor expanded in b around inf 83.8%
associate-/l*85.8%
Simplified85.8%
Final simplification73.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (/ c b))))
(if (<= b 2.25e-130)
(if (>= b 0.0) (* -0.5 (/ (sqrt (* a (/ c -0.25))) a)) t_0)
(if (>= b 0.0) (* (/ -0.5 a) (+ b (+ b (* -2.0 (/ c (/ b a)))))) t_0))))
double code(double a, double b, double c) {
double t_0 = -(c / b);
double tmp_1;
if (b <= 2.25e-130) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * (sqrt((a * (c / -0.25))) / a);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-0.5 / a) * (b + (b + (-2.0 * (c / (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 / b)
if (b <= 2.25d-130) then
if (b >= 0.0d0) then
tmp_2 = (-0.5d0) * (sqrt((a * (c / (-0.25d0)))) / a)
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = ((-0.5d0) / a) * (b + (b + ((-2.0d0) * (c / (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 / b);
double tmp_1;
if (b <= 2.25e-130) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * (Math.sqrt((a * (c / -0.25))) / a);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -(c / b) tmp_1 = 0 if b <= 2.25e-130: tmp_2 = 0 if b >= 0.0: tmp_2 = -0.5 * (math.sqrt((a * (c / -0.25))) / a) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(-Float64(c / b)) tmp_1 = 0.0 if (b <= 2.25e-130) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * Float64(sqrt(Float64(a * Float64(c / -0.25))) / a)); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(-0.5 / a) * Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a)))))); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = -(c / b); tmp_2 = 0.0; if (b <= 2.25e-130) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -0.5 * (sqrt((a * (c / -0.25))) / a); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = (-N[(c / b), $MachinePrecision])}, If[LessEqual[b, 2.25e-130], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[Sqrt[N[(a * N[(c / -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$0], 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], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{c}{b}\\
\mathbf{if}\;b \leq 2.25 \cdot 10^{-130}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{\sqrt{a \cdot \frac{c}{-0.25}}}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(b + -2 \cdot \frac{c}{\frac{b}{a}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 2.25e-130Initial program 72.3%
Simplified71.5%
Taylor expanded in b around -inf 64.1%
associate-*r/64.1%
neg-mul-164.1%
Simplified64.1%
pow1/264.1%
pow-to-exp63.5%
Applied egg-rr63.5%
Taylor expanded in a around -inf 59.5%
mul-1-neg59.5%
unsub-neg59.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in b around 0 59.4%
log-prod59.4%
+-commutative59.4%
log-prod59.4%
log-div63.1%
*-commutative63.1%
exp-to-pow63.7%
unpow1/263.7%
associate-/r/63.7%
*-commutative63.7%
associate-/l*63.7%
metadata-eval63.7%
Simplified63.7%
if 2.25e-130 < b Initial program 72.2%
Simplified72.0%
Taylor expanded in b around -inf 72.0%
associate-*r/72.0%
neg-mul-172.0%
Simplified72.0%
Taylor expanded in b around inf 82.7%
associate-/l*84.6%
Simplified84.6%
Final simplification72.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* (/ -0.5 a) (+ b (+ b (* -2.0 (/ c (/ b a)))))) (- (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp = -(c / 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 = ((-0.5d0) / a) * (b + (b + ((-2.0d0) * (c / (b / a)))))
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a)))));
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(-0.5 / a) * Float64(b + Float64(b + Float64(-2.0 * Float64(c / Float64(b / a)))))); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-0.5 / a) * (b + (b + (-2.0 * (c / (b / a))))); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := 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[(c / b), $MachinePrecision])]
\begin{array}{l}
\\
\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{c}{b}\\
\end{array}
\end{array}
Initial program 72.2%
Simplified71.7%
Taylor expanded in b around -inf 67.5%
associate-*r/67.5%
neg-mul-167.5%
Simplified67.5%
Taylor expanded in b around inf 67.9%
associate-/l*68.8%
Simplified68.8%
Final simplification68.8%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- b) a) (- (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -b / a;
} else {
tmp = -(c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = -b / a
else
tmp = -(c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -b / a;
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -b / a else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(-b) / a); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -b / a; else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[((-b) / a), $MachinePrecision], (-N[(c / b), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
Initial program 72.2%
Simplified71.7%
Taylor expanded in b around -inf 67.5%
associate-*r/67.5%
neg-mul-167.5%
Simplified67.5%
Taylor expanded in b around inf 68.6%
Taylor expanded in a around 0 68.6%
associate-*r/68.6%
neg-mul-168.6%
Simplified68.6%
Final simplification68.6%
herbie shell --seed 2023257
(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)))))))