
(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 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -1.5e+163)
(if (>= b 0.0) (- (/ (+ b b) (* a 2.0))) (/ (- c) b))
(if (<= b 1.45e+115)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (/ 2.0 (/ (- (- b) b) c)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -1.5e+163) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -((b + b) / (a * 2.0));
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 1.45e+115) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = 2.0 / ((-b - 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
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-1.5d+163)) then
if (b >= 0.0d0) then
tmp_2 = -((b + b) / (a * 2.0d0))
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 1.45d+115) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (a * 2.0d0)
else
tmp_3 = (2.0d0 * c) / (t_0 - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = 2.0d0 / ((-b - 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) - (c * (a * 4.0))));
double tmp_1;
if (b <= -1.5e+163) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -((b + b) / (a * 2.0));
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 1.45e+115) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = 2.0 / ((-b - b) / c);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -1.5e+163: tmp_2 = 0 if b >= 0.0: tmp_2 = -((b + b) / (a * 2.0)) else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 1.45e+115: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (a * 2.0) else: tmp_3 = (2.0 * c) / (t_0 - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = 2.0 / ((-b - b) / c) 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.5e+163) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 1.45e+115) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)); 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 <= -1.5e+163) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -((b + b) / (a * 2.0)); else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 1.45e+115) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (a * 2.0); else tmp_4 = (2.0 * c) / (t_0 - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = 2.0 / ((-b - b) / c); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.5e+163], If[GreaterEqual[b, 0.0], (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 1.45e+115], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $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.5 \cdot 10^{+163}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\frac{b + b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{+115}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\end{array}
\end{array}
if b < -1.50000000000000007e163Initial program 38.2%
sqr-neg38.2%
sqr-neg38.2%
associate-*l*38.2%
*-commutative38.2%
associate-/l*38.2%
Simplified38.2%
Taylor expanded in b around inf 38.2%
Taylor expanded in b around -inf 93.4%
associate-*r/93.4%
*-commutative93.4%
Simplified93.4%
Taylor expanded in b around 0 95.0%
associate-*r/95.0%
mul-1-neg95.0%
Simplified95.0%
if -1.50000000000000007e163 < b < 1.45000000000000002e115Initial program 86.1%
if 1.45000000000000002e115 < b Initial program 51.5%
sqr-neg51.5%
sqr-neg51.5%
associate-*l*51.5%
*-commutative51.5%
associate-/l*51.5%
Simplified51.5%
Taylor expanded in b around -inf 51.5%
Taylor expanded in b around inf 96.4%
+-commutative96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (/ (+ b b) (* a 2.0))))
(t_1 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (<= b -2.1e+131)
(if (>= b 0.0) t_0 (/ (- c) b))
(if (<= b 4.1e-306)
(if (>= b 0.0) t_0 (/ 2.0 (/ (- t_1 b) c)))
(if (<= b 1.45e+116)
(if (>= b 0.0)
(/ (- (- b) t_1) (* a 2.0))
(/ 2.0 (* (+ b (+ b (/ (* a 2.0) (/ b c)))) (/ 1.0 c))))
(if (>= b 0.0) (- (/ c b) (/ b a)) (/ 2.0 (/ (- (- b) b) c))))))))
double code(double a, double b, double c) {
double t_0 = -((b + b) / (a * 2.0));
double t_1 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp_1;
if (b <= -2.1e+131) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 4.1e-306) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = 2.0 / ((t_1 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 1.45e+116) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_1) / (a * 2.0);
} else {
tmp_4 = 2.0 / ((b + (b + ((a * 2.0) / (b / c)))) * (1.0 / c));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = 2.0 / ((-b - 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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -((b + b) / (a * 2.0d0))
t_1 = sqrt(((b * b) - (4.0d0 * (a * c))))
if (b <= (-2.1d+131)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 4.1d-306) then
if (b >= 0.0d0) then
tmp_3 = t_0
else
tmp_3 = 2.0d0 / ((t_1 - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 1.45d+116) then
if (b >= 0.0d0) then
tmp_4 = (-b - t_1) / (a * 2.0d0)
else
tmp_4 = 2.0d0 / ((b + (b + ((a * 2.0d0) / (b / c)))) * (1.0d0 / c))
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = 2.0d0 / ((-b - b) / c)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -((b + b) / (a * 2.0));
double t_1 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double tmp_1;
if (b <= -2.1e+131) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 4.1e-306) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = 2.0 / ((t_1 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 1.45e+116) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_1) / (a * 2.0);
} else {
tmp_4 = 2.0 / ((b + (b + ((a * 2.0) / (b / c)))) * (1.0 / c));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = 2.0 / ((-b - b) / c);
}
return tmp_1;
}
def code(a, b, c): t_0 = -((b + b) / (a * 2.0)) t_1 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp_1 = 0 if b <= -2.1e+131: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 4.1e-306: tmp_3 = 0 if b >= 0.0: tmp_3 = t_0 else: tmp_3 = 2.0 / ((t_1 - b) / c) tmp_1 = tmp_3 elif b <= 1.45e+116: tmp_4 = 0 if b >= 0.0: tmp_4 = (-b - t_1) / (a * 2.0) else: tmp_4 = 2.0 / ((b + (b + ((a * 2.0) / (b / c)))) * (1.0 / c)) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = 2.0 / ((-b - b) / c) return tmp_1
function code(a, b, c) t_0 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))) t_1 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp_1 = 0.0 if (b <= -2.1e+131) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 4.1e-306) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(2.0 / Float64(Float64(t_1 - b) / c)); end tmp_1 = tmp_3; elseif (b <= 1.45e+116) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp_4 = Float64(2.0 / Float64(Float64(b + Float64(b + Float64(Float64(a * 2.0) / Float64(b / c)))) * Float64(1.0 / c))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = -((b + b) / (a * 2.0)); t_1 = sqrt(((b * b) - (4.0 * (a * c)))); tmp_2 = 0.0; if (b <= -2.1e+131) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 4.1e-306) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_0; else tmp_4 = 2.0 / ((t_1 - b) / c); end tmp_2 = tmp_4; elseif (b <= 1.45e+116) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-b - t_1) / (a * 2.0); else tmp_5 = 2.0 / ((b + (b + ((a * 2.0) / (b / c)))) * (1.0 / c)); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = 2.0 / ((-b - b) / c); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision])}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.1e+131], If[GreaterEqual[b, 0.0], t$95$0, N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 4.1e-306], If[GreaterEqual[b, 0.0], t$95$0, N[(2.0 / N[(N[(t$95$1 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.45e+116], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(b + N[(b + N[(N[(a * 2.0), $MachinePrecision] / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{b + b}{a \cdot 2}\\
t_1 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b \leq -2.1 \cdot 10^{+131}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-306}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_1 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{+116}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(b + \left(b + \frac{a \cdot 2}{\frac{b}{c}}\right)\right) \cdot \frac{1}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\end{array}
\end{array}
if b < -2.09999999999999985e131Initial program 44.1%
sqr-neg44.1%
sqr-neg44.1%
associate-*l*44.1%
*-commutative44.1%
associate-/l*43.9%
Simplified43.9%
Taylor expanded in b around inf 43.9%
Taylor expanded in b around -inf 93.9%
associate-*r/93.9%
*-commutative93.9%
Simplified93.9%
Taylor expanded in b around 0 95.4%
associate-*r/95.4%
mul-1-neg95.4%
Simplified95.4%
if -2.09999999999999985e131 < b < 4.09999999999999985e-306Initial program 87.4%
sqr-neg87.4%
sqr-neg87.4%
associate-*l*87.4%
*-commutative87.4%
associate-/l*87.1%
Simplified87.1%
Taylor expanded in b around inf 87.1%
if 4.09999999999999985e-306 < b < 1.4500000000000001e116Initial program 83.6%
sqr-neg83.6%
sqr-neg83.6%
associate-*l*83.6%
*-commutative83.6%
associate-/l*83.6%
Simplified83.6%
Taylor expanded in b around -inf 83.6%
fma-def83.6%
associate-/l*83.6%
Simplified83.6%
div-inv83.6%
add-sqr-sqrt83.6%
sqrt-unprod83.6%
sqr-neg83.6%
sqrt-prod83.6%
add-sqr-sqrt83.6%
fma-udef83.6%
neg-mul-183.6%
add-sqr-sqrt83.6%
sqrt-unprod83.6%
sqr-neg83.6%
sqrt-prod83.6%
add-sqr-sqrt83.6%
associate-*r/83.6%
Applied egg-rr83.6%
if 1.4500000000000001e116 < b Initial program 51.5%
sqr-neg51.5%
sqr-neg51.5%
associate-*l*51.5%
*-commutative51.5%
associate-/l*51.5%
Simplified51.5%
Taylor expanded in b around -inf 51.5%
Taylor expanded in b around inf 96.4%
+-commutative96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
Final simplification89.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (/ (+ b b) (* a 2.0)))))
(if (<= b -7.4e-53)
(if (>= b 0.0) t_0 (/ (- c) b))
(if (<= b 4.1e-306)
(if (>= b 0.0)
(fma -1.0 (/ b a) (/ c b))
(/ (* 2.0 c) (- (sqrt (* a (* c -4.0))) b)))
(if (<= b 3.5e-32)
(if (>= b 0.0)
(/ (- (- b) (sqrt (* c (* a -4.0)))) (* a 2.0))
(/ 2.0 (/ (- (- b) b) c)))
(if (>= b 0.0) t_0 (/ 2.0 (/ (* a -2.0) b))))))))
double code(double a, double b, double c) {
double t_0 = -((b + b) / (a * 2.0));
double tmp_1;
if (b <= -7.4e-53) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 4.1e-306) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = fma(-1.0, (b / a), (c / b));
} else {
tmp_3 = (2.0 * c) / (sqrt((a * (c * -4.0))) - b);
}
tmp_1 = tmp_3;
} else if (b <= 3.5e-32) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp_4 = 2.0 / ((-b - b) / c);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = 2.0 / ((a * -2.0) / b);
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))) tmp_1 = 0.0 if (b <= -7.4e-53) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 4.1e-306) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(sqrt(Float64(a * Float64(c * -4.0))) - b)); end tmp_1 = tmp_3; elseif (b <= 3.5e-32) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - sqrt(Float64(c * Float64(a * -4.0)))) / Float64(a * 2.0)); else tmp_4 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(2.0 / Float64(Float64(a * -2.0) / b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[b, -7.4e-53], If[GreaterEqual[b, 0.0], t$95$0, N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 4.1e-306], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.5e-32], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(2.0 / N[(N[(a * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{b + b}{a \cdot 2}\\
\mathbf{if}\;b \leq -7.4 \cdot 10^{-53}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-306}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{a \cdot \left(c \cdot -4\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-32}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{a \cdot -2}{b}}\\
\end{array}
\end{array}
if b < -7.39999999999999965e-53Initial program 67.4%
sqr-neg67.4%
sqr-neg67.4%
associate-*l*67.4%
*-commutative67.4%
associate-/l*67.2%
Simplified67.2%
Taylor expanded in b around inf 67.2%
Taylor expanded in b around -inf 87.9%
associate-*r/87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in b around 0 88.8%
associate-*r/88.8%
mul-1-neg88.8%
Simplified88.8%
if -7.39999999999999965e-53 < b < 4.09999999999999985e-306Initial program 84.7%
sqr-neg84.7%
sqr-neg84.7%
associate-*l*84.7%
*-commutative84.7%
associate-/l*84.5%
Simplified84.4%
Taylor expanded in b around inf 84.4%
fma-def84.4%
Simplified84.4%
associate-*r*84.5%
*-commutative84.5%
*-commutative84.5%
prod-diff84.2%
*-commutative84.2%
associate-*r*84.2%
*-commutative84.2%
*-commutative84.2%
fma-neg84.2%
pow284.2%
cancel-sign-sub-inv84.2%
pow284.2%
fma-def84.2%
metadata-eval84.2%
*-commutative84.2%
associate-*l*84.2%
Applied egg-rr84.2%
Taylor expanded in b around 0 76.2%
neg-mul-176.2%
unsub-neg76.2%
associate-*r*76.2%
associate-*r*76.3%
distribute-rgt-in76.5%
distribute-rgt-out76.5%
metadata-eval76.5%
Simplified76.5%
expm1-log1p-u57.1%
expm1-udef19.4%
associate-/r/19.4%
*-commutative19.4%
Applied egg-rr19.4%
expm1-def57.2%
expm1-log1p76.6%
*-commutative76.6%
associate-*r/76.7%
associate-*r*76.7%
*-commutative76.7%
Simplified76.7%
if 4.09999999999999985e-306 < b < 3.4999999999999999e-32Initial program 80.5%
sqr-neg80.5%
sqr-neg80.5%
associate-*l*80.5%
*-commutative80.5%
associate-/l*80.5%
Simplified80.5%
Taylor expanded in b around -inf 80.5%
Taylor expanded in b around 0 70.0%
*-commutative70.0%
*-commutative70.0%
associate-*l*70.0%
Simplified70.0%
if 3.4999999999999999e-32 < b Initial program 65.1%
sqr-neg65.1%
sqr-neg65.1%
associate-*l*65.1%
*-commutative65.1%
associate-/l*65.1%
Simplified65.1%
Taylor expanded in b around inf 88.6%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
Simplified88.6%
Final simplification83.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (/ (+ b b) (* a 2.0)))))
(if (<= b -5e+130)
(if (>= b 0.0) t_0 (/ (- c) b))
(if (<= b 4.1e-306)
(if (>= b 0.0)
t_0
(/ 2.0 (/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) c)))
(if (<= b 3.2e-39)
(if (>= b 0.0)
(/ (- (- b) (sqrt (* c (* a -4.0)))) (* a 2.0))
(/ 2.0 (/ (- (- b) b) c)))
(if (>= b 0.0) t_0 (/ 2.0 (/ (* a -2.0) b))))))))
double code(double a, double b, double c) {
double t_0 = -((b + b) / (a * 2.0));
double tmp_1;
if (b <= -5e+130) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 4.1e-306) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = 2.0 / ((sqrt(((b * b) - (4.0 * (a * c)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 3.2e-39) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp_4 = 2.0 / ((-b - b) / c);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = 2.0 / ((a * -2.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
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -((b + b) / (a * 2.0d0))
if (b <= (-5d+130)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 4.1d-306) then
if (b >= 0.0d0) then
tmp_3 = t_0
else
tmp_3 = 2.0d0 / ((sqrt(((b * b) - (4.0d0 * (a * c)))) - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 3.2d-39) then
if (b >= 0.0d0) then
tmp_4 = (-b - sqrt((c * (a * (-4.0d0))))) / (a * 2.0d0)
else
tmp_4 = 2.0d0 / ((-b - b) / c)
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = 2.0d0 / ((a * (-2.0d0)) / b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -((b + b) / (a * 2.0));
double tmp_1;
if (b <= -5e+130) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 4.1e-306) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = 2.0 / ((Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 3.2e-39) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - Math.sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp_4 = 2.0 / ((-b - b) / c);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = 2.0 / ((a * -2.0) / b);
}
return tmp_1;
}
def code(a, b, c): t_0 = -((b + b) / (a * 2.0)) tmp_1 = 0 if b <= -5e+130: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 4.1e-306: tmp_3 = 0 if b >= 0.0: tmp_3 = t_0 else: tmp_3 = 2.0 / ((math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / c) tmp_1 = tmp_3 elif b <= 3.2e-39: tmp_4 = 0 if b >= 0.0: tmp_4 = (-b - math.sqrt((c * (a * -4.0)))) / (a * 2.0) else: tmp_4 = 2.0 / ((-b - b) / c) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = 2.0 / ((a * -2.0) / b) return tmp_1
function code(a, b, c) t_0 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))) tmp_1 = 0.0 if (b <= -5e+130) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 4.1e-306) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 3.2e-39) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - sqrt(Float64(c * Float64(a * -4.0)))) / Float64(a * 2.0)); else tmp_4 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(2.0 / Float64(Float64(a * -2.0) / b)); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = -((b + b) / (a * 2.0)); tmp_2 = 0.0; if (b <= -5e+130) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 4.1e-306) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_0; else tmp_4 = 2.0 / ((sqrt(((b * b) - (4.0 * (a * c)))) - b) / c); end tmp_2 = tmp_4; elseif (b <= 3.2e-39) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0); else tmp_5 = 2.0 / ((-b - b) / c); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = 2.0 / ((a * -2.0) / b); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[b, -5e+130], If[GreaterEqual[b, 0.0], t$95$0, N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 4.1e-306], If[GreaterEqual[b, 0.0], t$95$0, N[(2.0 / N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.2e-39], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(2.0 / N[(N[(a * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{b + b}{a \cdot 2}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+130}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-306}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-39}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{a \cdot -2}{b}}\\
\end{array}
\end{array}
if b < -4.9999999999999996e130Initial program 44.1%
sqr-neg44.1%
sqr-neg44.1%
associate-*l*44.1%
*-commutative44.1%
associate-/l*43.9%
Simplified43.9%
Taylor expanded in b around inf 43.9%
Taylor expanded in b around -inf 93.9%
associate-*r/93.9%
*-commutative93.9%
Simplified93.9%
Taylor expanded in b around 0 95.4%
associate-*r/95.4%
mul-1-neg95.4%
Simplified95.4%
if -4.9999999999999996e130 < b < 4.09999999999999985e-306Initial program 87.4%
sqr-neg87.4%
sqr-neg87.4%
associate-*l*87.4%
*-commutative87.4%
associate-/l*87.1%
Simplified87.1%
Taylor expanded in b around inf 87.1%
if 4.09999999999999985e-306 < b < 3.1999999999999998e-39Initial program 80.5%
sqr-neg80.5%
sqr-neg80.5%
associate-*l*80.5%
*-commutative80.5%
associate-/l*80.5%
Simplified80.5%
Taylor expanded in b around -inf 80.5%
Taylor expanded in b around 0 70.0%
*-commutative70.0%
*-commutative70.0%
associate-*l*70.0%
Simplified70.0%
if 3.1999999999999998e-39 < b Initial program 65.1%
sqr-neg65.1%
sqr-neg65.1%
associate-*l*65.1%
*-commutative65.1%
associate-/l*65.1%
Simplified65.1%
Taylor expanded in b around inf 88.6%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
Simplified88.6%
Final simplification86.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (<= b -2.2e+131)
(if (>= b 0.0) (- (/ (+ b b) (* a 2.0))) (/ (- c) b))
(if (<= b 7.5e+116)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ 2.0 (/ (- t_0 b) c)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (/ 2.0 (/ (- (- b) 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 <= -2.2e+131) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -((b + b) / (a * 2.0));
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 7.5e+116) {
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 = 2.0 / ((-b - 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
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
if (b <= (-2.2d+131)) then
if (b >= 0.0d0) then
tmp_2 = -((b + b) / (a * 2.0d0))
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 7.5d+116) 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 = 2.0d0 / ((-b - 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 <= -2.2e+131) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -((b + b) / (a * 2.0));
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 7.5e+116) {
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 = 2.0 / ((-b - 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 <= -2.2e+131: tmp_2 = 0 if b >= 0.0: tmp_2 = -((b + b) / (a * 2.0)) else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 7.5e+116: 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 = 2.0 / ((-b - 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 <= -2.2e+131) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 7.5e+116) 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(2.0 / Float64(Float64(Float64(-b) - b) / c)); 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 <= -2.2e+131) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -((b + b) / (a * 2.0)); else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 7.5e+116) 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 = 2.0 / ((-b - b) / c); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.2e+131], If[GreaterEqual[b, 0.0], (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 7.5e+116], 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[(2.0 / N[(N[((-b) - 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 -2.2 \cdot 10^{+131}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\frac{b + b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{+116}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\end{array}
\end{array}
if b < -2.1999999999999999e131Initial program 44.1%
sqr-neg44.1%
sqr-neg44.1%
associate-*l*44.1%
*-commutative44.1%
associate-/l*43.9%
Simplified43.9%
Taylor expanded in b around inf 43.9%
Taylor expanded in b around -inf 93.9%
associate-*r/93.9%
*-commutative93.9%
Simplified93.9%
Taylor expanded in b around 0 95.4%
associate-*r/95.4%
mul-1-neg95.4%
Simplified95.4%
if -2.1999999999999999e131 < b < 7.5e116Initial program 85.8%
sqr-neg85.8%
sqr-neg85.8%
associate-*l*85.8%
*-commutative85.8%
associate-/l*85.6%
Simplified85.6%
if 7.5e116 < b Initial program 51.5%
sqr-neg51.5%
sqr-neg51.5%
associate-*l*51.5%
*-commutative51.5%
associate-/l*51.5%
Simplified51.5%
Taylor expanded in b around -inf 51.5%
Taylor expanded in b around inf 96.4%
+-commutative96.4%
mul-1-neg96.4%
unsub-neg96.4%
Simplified96.4%
Final simplification89.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.95e-52)
(if (>= b 0.0) (- (/ (+ b b) (* a 2.0))) (/ (- c) b))
(if (>= b 0.0)
(fma -1.0 (/ b a) (/ c b))
(* c (/ 2.0 (- (sqrt (* c (* a -4.0))) b))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.95e-52) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -((b + b) / (a * 2.0));
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = fma(-1.0, (b / a), (c / b));
} else {
tmp_1 = c * (2.0 / (sqrt((c * (a * -4.0))) - b));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.95e-52) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_1 = Float64(c * Float64(2.0 / Float64(sqrt(Float64(c * Float64(a * -4.0))) - b))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1.95e-52], If[GreaterEqual[b, 0.0], (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), N[((-c) / b), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.95 \cdot 10^{-52}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\frac{b + b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{c \cdot \left(a \cdot -4\right)} - b}\\
\end{array}
\end{array}
if b < -1.95000000000000009e-52Initial program 67.4%
sqr-neg67.4%
sqr-neg67.4%
associate-*l*67.4%
*-commutative67.4%
associate-/l*67.2%
Simplified67.2%
Taylor expanded in b around inf 67.2%
Taylor expanded in b around -inf 87.9%
associate-*r/87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in b around 0 88.8%
associate-*r/88.8%
mul-1-neg88.8%
Simplified88.8%
if -1.95000000000000009e-52 < b Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.4%
*-commutative74.4%
associate-/l*74.3%
Simplified74.3%
Taylor expanded in b around inf 71.7%
fma-def71.7%
Simplified71.7%
associate-*r*71.7%
*-commutative71.7%
*-commutative71.7%
prod-diff71.7%
*-commutative71.7%
associate-*r*71.6%
*-commutative71.6%
*-commutative71.6%
fma-neg71.6%
pow271.6%
cancel-sign-sub-inv71.6%
pow271.6%
fma-def71.6%
metadata-eval71.6%
*-commutative71.6%
associate-*l*71.6%
Applied egg-rr71.6%
Taylor expanded in b around 0 69.3%
neg-mul-169.3%
unsub-neg69.3%
associate-*r*69.3%
associate-*r*69.3%
distribute-rgt-in69.4%
distribute-rgt-out69.4%
metadata-eval69.4%
Simplified69.4%
associate-/r/69.4%
*-commutative69.4%
Applied egg-rr69.4%
Final simplification75.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.08e-52)
(if (>= b 0.0) (- (/ (+ b b) (* a 2.0))) (/ (- c) b))
(if (>= b 0.0)
(fma -1.0 (/ b a) (/ c b))
(/ (* 2.0 c) (- (sqrt (* a (* c -4.0))) b)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.08e-52) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -((b + b) / (a * 2.0));
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = fma(-1.0, (b / a), (c / b));
} else {
tmp_1 = (2.0 * c) / (sqrt((a * (c * -4.0))) - b);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.08e-52) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(sqrt(Float64(a * Float64(c * -4.0))) - b)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1.08e-52], If[GreaterEqual[b, 0.0], (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), N[((-c) / b), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.08 \cdot 10^{-52}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\frac{b + b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{a \cdot \left(c \cdot -4\right)} - b}\\
\end{array}
\end{array}
if b < -1.08e-52Initial program 67.4%
sqr-neg67.4%
sqr-neg67.4%
associate-*l*67.4%
*-commutative67.4%
associate-/l*67.2%
Simplified67.2%
Taylor expanded in b around inf 67.2%
Taylor expanded in b around -inf 87.9%
associate-*r/87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in b around 0 88.8%
associate-*r/88.8%
mul-1-neg88.8%
Simplified88.8%
if -1.08e-52 < b Initial program 74.4%
sqr-neg74.4%
sqr-neg74.4%
associate-*l*74.4%
*-commutative74.4%
associate-/l*74.3%
Simplified74.3%
Taylor expanded in b around inf 71.7%
fma-def71.7%
Simplified71.7%
associate-*r*71.7%
*-commutative71.7%
*-commutative71.7%
prod-diff71.7%
*-commutative71.7%
associate-*r*71.6%
*-commutative71.6%
*-commutative71.6%
fma-neg71.6%
pow271.6%
cancel-sign-sub-inv71.6%
pow271.6%
fma-def71.6%
metadata-eval71.6%
*-commutative71.6%
associate-*l*71.6%
Applied egg-rr71.6%
Taylor expanded in b around 0 69.3%
neg-mul-169.3%
unsub-neg69.3%
associate-*r*69.3%
associate-*r*69.3%
distribute-rgt-in69.4%
distribute-rgt-out69.4%
metadata-eval69.4%
Simplified69.4%
expm1-log1p-u63.6%
expm1-udef52.5%
associate-/r/52.5%
*-commutative52.5%
Applied egg-rr52.5%
expm1-def63.6%
expm1-log1p69.4%
*-commutative69.4%
associate-*r/69.4%
associate-*r*69.4%
*-commutative69.4%
Simplified69.4%
Final simplification75.8%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (- (/ (+ b b) (* 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 + b) / (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 + b) / (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 + b) / (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 + b) / (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(Float64(b + b) / 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 + b) / (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 + b), $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 + b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b \cdot -2}\\
\end{array}
\end{array}
Initial program 72.1%
sqr-neg72.1%
sqr-neg72.1%
associate-*l*72.1%
*-commutative72.1%
associate-/l*72.0%
Simplified72.0%
Taylor expanded in b around inf 70.3%
Taylor expanded in b around -inf 63.1%
associate-*r/63.1%
*-commutative63.1%
Simplified63.1%
associate-/r/63.3%
Applied egg-rr63.3%
Final simplification63.3%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (- (/ (+ b b) (* a 2.0))) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -((b + b) / (a * 2.0));
} 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 + b) / (a * 2.0d0))
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 + b) / (a * 2.0));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -((b + b) / (a * 2.0)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-Float64(Float64(b + b) / Float64(a * 2.0))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -((b + b) / (a * 2.0)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], (-N[(N[(b + b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\frac{b + b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 72.1%
sqr-neg72.1%
sqr-neg72.1%
associate-*l*72.1%
*-commutative72.1%
associate-/l*72.0%
Simplified72.0%
Taylor expanded in b around inf 70.3%
Taylor expanded in b around -inf 63.1%
associate-*r/63.1%
*-commutative63.1%
Simplified63.1%
Taylor expanded in b around 0 63.4%
associate-*r/63.4%
mul-1-neg63.4%
Simplified63.4%
Final simplification63.4%
herbie shell --seed 2024021
(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)))))))