
(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 8 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))))) (t_1 (- (- b) b)))
(if (<= b -4.8e+86)
(if (>= b 0.0) (/ t_1 (* a 2.0)) (/ (- c) b))
(if (<= b 6e+51)
(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 (/ t_1 c)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = -b - b;
double tmp_1;
if (b <= -4.8e+86) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 6e+51) {
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 / (t_1 / c);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = -b - b
if (b <= (-4.8d+86)) then
if (b >= 0.0d0) then
tmp_2 = t_1 / (a * 2.0d0)
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 6d+51) 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 / (t_1 / c)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = -b - b;
double tmp_1;
if (b <= -4.8e+86) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 6e+51) {
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 / (t_1 / c);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = -b - b tmp_1 = 0 if b <= -4.8e+86: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 / (a * 2.0) else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 6e+51: 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 / (t_1 / c) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(Float64(-b) - b) tmp_1 = 0.0 if (b <= -4.8e+86) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_1 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 6e+51) 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(t_1 / c)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = -b - b; tmp_2 = 0.0; if (b <= -4.8e+86) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1 / (a * 2.0); else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 6e+51) 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 / (t_1 / c); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, -4.8e+86], If[GreaterEqual[b, 0.0], N[(t$95$1 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 6e+51], 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[(t$95$1 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \left(-b\right) - b\\
\mathbf{if}\;b \leq -4.8 \cdot 10^{+86}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{+51}:\\
\;\;\;\;\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{t_1}{c}}\\
\end{array}
\end{array}
if b < -4.8000000000000001e86Initial program 53.6%
sqr-neg53.6%
sqr-neg53.6%
associate-*l*53.6%
*-commutative53.6%
associate-/l*53.5%
Simplified53.5%
Taylor expanded in b around inf 53.5%
Taylor expanded in b around -inf 95.4%
associate-*r/95.4%
neg-mul-195.4%
Simplified95.4%
if -4.8000000000000001e86 < b < 6e51Initial program 85.9%
if 6e51 < b Initial program 59.5%
sqr-neg59.5%
sqr-neg59.5%
associate-*l*59.5%
*-commutative59.5%
associate-/l*59.5%
Simplified59.5%
Taylor expanded in b around -inf 59.5%
Taylor expanded in b around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification91.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b))
(t_1 (/ 2.0 (/ t_0 c)))
(t_2 (sqrt (* a (* c -4.0)))))
(if (<= b -1.36e-30)
(if (>= b 0.0) (/ t_0 (* a 2.0)) (/ (- c) b))
(if (<= b -1e-311)
(if (>= b 0.0) (fma -1.0 (/ b a) (/ c b)) (* c (/ -2.0 (- b t_2))))
(if (<= b 6e-99)
(if (>= b 0.0) (/ (- (- b) t_2) (* a 2.0)) t_1)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_1))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = 2.0 / (t_0 / c);
double t_2 = sqrt((a * (c * -4.0)));
double tmp_1;
if (b <= -1.36e-30) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0 / (a * 2.0);
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= -1e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = fma(-1.0, (b / a), (c / b));
} else {
tmp_3 = c * (-2.0 / (b - t_2));
}
tmp_1 = tmp_3;
} else if (b <= 6e-99) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_2) / (a * 2.0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = Float64(2.0 / Float64(t_0 / c)) t_2 = sqrt(Float64(a * Float64(c * -4.0))) tmp_1 = 0.0 if (b <= -1.36e-30) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_0 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= -1e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_3 = Float64(c * Float64(-2.0 / Float64(b - t_2))); end tmp_1 = tmp_3; elseif (b <= 6e-99) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_2) / Float64(a * 2.0)); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.36e-30], If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, -1e-311], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6e-99], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$2), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \frac{2}{\frac{t_0}{c}}\\
t_2 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
\mathbf{if}\;b \leq -1.36 \cdot 10^{-30}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b - t_2}\\
\end{array}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-99}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_2}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -1.36e-30Initial program 65.9%
sqr-neg65.9%
sqr-neg65.9%
associate-*l*65.9%
*-commutative65.9%
associate-/l*65.8%
Simplified65.8%
Taylor expanded in b around inf 65.8%
Taylor expanded in b around -inf 87.5%
associate-*r/87.5%
neg-mul-187.5%
Simplified87.5%
if -1.36e-30 < b < -9.99999999999948e-312Initial program 88.9%
sqr-neg88.9%
sqr-neg88.9%
associate-*l*88.9%
*-commutative88.9%
associate-/l*88.5%
Simplified88.3%
Taylor expanded in b around inf 88.3%
fma-def88.3%
Simplified88.3%
Applied egg-rr88.6%
Taylor expanded in b around 0 78.2%
*-commutative78.2%
associate-*r*78.4%
Simplified78.4%
if -9.99999999999948e-312 < b < 6.00000000000000012e-99Initial program 81.1%
sqr-neg81.1%
sqr-neg81.1%
associate-*l*81.1%
*-commutative81.1%
associate-/l*81.1%
Simplified81.1%
Taylor expanded in b around -inf 81.1%
Taylor expanded in b around 0 72.4%
*-commutative72.4%
associate-*l*72.4%
Simplified72.4%
if 6.00000000000000012e-99 < b Initial program 66.5%
sqr-neg66.5%
sqr-neg66.5%
associate-*l*66.5%
*-commutative66.5%
associate-/l*66.5%
Simplified66.5%
Taylor expanded in b around -inf 66.5%
Taylor expanded in b around inf 84.5%
+-commutative84.5%
mul-1-neg84.5%
unsub-neg84.5%
Simplified84.5%
Final simplification83.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)) (t_1 (/ t_0 (* a 2.0))) (t_2 (/ 2.0 (/ t_0 c))))
(if (<= b -1.5e+73)
(if (>= b 0.0) t_1 (/ (- c) b))
(if (<= b -1e-311)
(if (>= b 0.0)
t_1
(/ 2.0 (/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) c)))
(if (<= b 2.55e-95)
(if (>= b 0.0) (/ (- (- b) (sqrt (* a (* c -4.0)))) (* a 2.0)) t_2)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_2))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = t_0 / (a * 2.0);
double t_2 = 2.0 / (t_0 / c);
double tmp_1;
if (b <= -1.5e+73) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= -1e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 2.0 / ((sqrt(((b * b) - (4.0 * (a * c)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.55e-95) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt((a * (c * -4.0)))) / (a * 2.0);
} 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;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = -b - b
t_1 = t_0 / (a * 2.0d0)
t_2 = 2.0d0 / (t_0 / c)
if (b <= (-1.5d+73)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= (-1d-311)) then
if (b >= 0.0d0) then
tmp_3 = t_1
else
tmp_3 = 2.0d0 / ((sqrt(((b * b) - (4.0d0 * (a * c)))) - b) / c)
end if
tmp_1 = tmp_3
else if (b <= 2.55d-95) then
if (b >= 0.0d0) then
tmp_4 = (-b - sqrt((a * (c * (-4.0d0))))) / (a * 2.0d0)
else
tmp_4 = t_2
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = t_2
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = t_0 / (a * 2.0);
double t_2 = 2.0 / (t_0 / c);
double tmp_1;
if (b <= -1.5e+73) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= -1e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 2.0 / ((Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.55e-95) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - Math.sqrt((a * (c * -4.0)))) / (a * 2.0);
} 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;
}
def code(a, b, c): t_0 = -b - b t_1 = t_0 / (a * 2.0) t_2 = 2.0 / (t_0 / c) tmp_1 = 0 if b <= -1.5e+73: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= -1e-311: tmp_3 = 0 if b >= 0.0: tmp_3 = t_1 else: tmp_3 = 2.0 / ((math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / c) tmp_1 = tmp_3 elif b <= 2.55e-95: tmp_4 = 0 if b >= 0.0: tmp_4 = (-b - math.sqrt((a * (c * -4.0)))) / (a * 2.0) else: tmp_4 = t_2 tmp_1 = tmp_4 elif 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(Float64(-b) - b) t_1 = Float64(t_0 / Float64(a * 2.0)) t_2 = Float64(2.0 / Float64(t_0 / c)) tmp_1 = 0.0 if (b <= -1.5e+73) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= -1e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 2.55e-95) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a * 2.0)); 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
function tmp_6 = code(a, b, c) t_0 = -b - b; t_1 = t_0 / (a * 2.0); t_2 = 2.0 / (t_0 / c); tmp_2 = 0.0; if (b <= -1.5e+73) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= -1e-311) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_1; else tmp_4 = 2.0 / ((sqrt(((b * b) - (4.0 * (a * c)))) - b) / c); end tmp_2 = tmp_4; elseif (b <= 2.55e-95) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-b - sqrt((a * (c * -4.0)))) / (a * 2.0); else tmp_5 = t_2; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = t_2; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.5e+73], If[GreaterEqual[b, 0.0], t$95$1, N[((-c) / b), $MachinePrecision]], If[LessEqual[b, -1e-311], If[GreaterEqual[b, 0.0], t$95$1, N[(2.0 / N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.55e-95], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $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 := \left(-b\right) - b\\
t_1 := \frac{t_0}{a \cdot 2}\\
t_2 := \frac{2}{\frac{t_0}{c}}\\
\mathbf{if}\;b \leq -1.5 \cdot 10^{+73}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.55 \cdot 10^{-95}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\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 < -1.50000000000000005e73Initial program 57.1%
sqr-neg57.1%
sqr-neg57.1%
associate-*l*57.1%
*-commutative57.1%
associate-/l*57.0%
Simplified57.0%
Taylor expanded in b around inf 57.0%
Taylor expanded in b around -inf 95.7%
associate-*r/95.7%
neg-mul-195.7%
Simplified95.7%
if -1.50000000000000005e73 < b < -9.99999999999948e-312Initial program 89.8%
sqr-neg89.8%
sqr-neg89.8%
associate-*l*89.8%
*-commutative89.8%
associate-/l*89.5%
Simplified89.3%
Taylor expanded in b around inf 89.3%
if -9.99999999999948e-312 < b < 2.55e-95Initial program 81.1%
sqr-neg81.1%
sqr-neg81.1%
associate-*l*81.1%
*-commutative81.1%
associate-/l*81.1%
Simplified81.1%
Taylor expanded in b around -inf 81.1%
Taylor expanded in b around 0 72.4%
*-commutative72.4%
associate-*l*72.4%
Simplified72.4%
if 2.55e-95 < b Initial program 66.5%
sqr-neg66.5%
sqr-neg66.5%
associate-*l*66.5%
*-commutative66.5%
associate-/l*66.5%
Simplified66.5%
Taylor expanded in b around -inf 66.5%
Taylor expanded in b around inf 84.5%
+-commutative84.5%
mul-1-neg84.5%
unsub-neg84.5%
Simplified84.5%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))) (t_1 (- (- b) b)))
(if (<= b -7.5e+71)
(if (>= b 0.0) (/ t_1 (* a 2.0)) (/ (- c) b))
(if (<= b 5.6e+51)
(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 (/ t_1 c)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double t_1 = -b - b;
double tmp_1;
if (b <= -7.5e+71) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 5.6e+51) {
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 / (t_1 / c);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
t_1 = -b - b
if (b <= (-7.5d+71)) then
if (b >= 0.0d0) then
tmp_2 = t_1 / (a * 2.0d0)
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 5.6d+51) 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 / (t_1 / c)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double t_1 = -b - b;
double tmp_1;
if (b <= -7.5e+71) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 5.6e+51) {
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 / (t_1 / c);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) t_1 = -b - b tmp_1 = 0 if b <= -7.5e+71: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 / (a * 2.0) else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 5.6e+51: 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 / (t_1 / c) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) t_1 = Float64(Float64(-b) - b) tmp_1 = 0.0 if (b <= -7.5e+71) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_1 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 5.6e+51) 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(t_1 / c)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); t_1 = -b - b; tmp_2 = 0.0; if (b <= -7.5e+71) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1 / (a * 2.0); else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 5.6e+51) 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 / (t_1 / c); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, -7.5e+71], If[GreaterEqual[b, 0.0], N[(t$95$1 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 5.6e+51], 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[(t$95$1 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
t_1 := \left(-b\right) - b\\
\mathbf{if}\;b \leq -7.5 \cdot 10^{+71}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{+51}:\\
\;\;\;\;\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{t_1}{c}}\\
\end{array}
\end{array}
if b < -7.50000000000000007e71Initial program 57.1%
sqr-neg57.1%
sqr-neg57.1%
associate-*l*57.1%
*-commutative57.1%
associate-/l*57.0%
Simplified57.0%
Taylor expanded in b around inf 57.0%
Taylor expanded in b around -inf 95.7%
associate-*r/95.7%
neg-mul-195.7%
Simplified95.7%
if -7.50000000000000007e71 < b < 5.60000000000000009e51Initial program 85.4%
sqr-neg85.4%
sqr-neg85.4%
associate-*l*85.4%
*-commutative85.4%
associate-/l*85.2%
Simplified85.2%
if 5.60000000000000009e51 < b Initial program 59.5%
sqr-neg59.5%
sqr-neg59.5%
associate-*l*59.5%
*-commutative59.5%
associate-/l*59.5%
Simplified59.5%
Taylor expanded in b around -inf 59.5%
Taylor expanded in b around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3.5e-30)
(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 (- b (sqrt (* a (* c -4.0)))))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.5e-30) {
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 / (b - sqrt((a * (c * -4.0)))));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.5e-30) 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(b - sqrt(Float64(a * Float64(c * -4.0)))))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3.5e-30], 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[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{-30}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - 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}{b - \sqrt{a \cdot \left(c \cdot -4\right)}}\\
\end{array}
\end{array}
if b < -3.5000000000000003e-30Initial program 65.9%
sqr-neg65.9%
sqr-neg65.9%
associate-*l*65.9%
*-commutative65.9%
associate-/l*65.8%
Simplified65.8%
Taylor expanded in b around inf 65.8%
Taylor expanded in b around -inf 87.5%
associate-*r/87.5%
neg-mul-187.5%
Simplified87.5%
if -3.5000000000000003e-30 < b Initial program 74.6%
sqr-neg74.6%
sqr-neg74.6%
associate-*l*74.6%
*-commutative74.6%
associate-/l*74.6%
Simplified74.5%
Taylor expanded in b around inf 73.1%
fma-def73.1%
Simplified73.1%
Applied egg-rr73.2%
Taylor expanded in b around 0 70.7%
*-commutative70.7%
associate-*r*70.8%
Simplified70.8%
Final simplification76.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (fma -1.0 (/ b a) (/ c b)) (* c (/ -2.0 (+ b (- b (* 2.0 (/ a (/ b c)))))))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = fma(-1.0, (b / a), (c / b));
} else {
tmp = c * (-2.0 / (b + (b - (2.0 * (a / (b / c))))));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp = Float64(c * Float64(-2.0 / Float64(b + Float64(b - Float64(2.0 * Float64(a / Float64(b / c))))))); end return tmp end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(c * N[(-2.0 / N[(b + N[(b - N[(2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b - 2 \cdot \frac{a}{\frac{b}{c}}\right)}\\
\end{array}
\end{array}
Initial program 71.6%
sqr-neg71.6%
sqr-neg71.6%
associate-*l*71.6%
*-commutative71.6%
associate-/l*71.5%
Simplified71.5%
Taylor expanded in b around inf 70.6%
fma-def70.6%
Simplified70.6%
Applied egg-rr70.6%
Taylor expanded in b around -inf 66.7%
+-commutative66.7%
associate-/l*67.5%
mul-1-neg67.5%
unsub-neg67.5%
Simplified67.5%
Final simplification67.5%
(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{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b \cdot -2}\\
\end{array}
\end{array}
Initial program 71.6%
sqr-neg71.6%
sqr-neg71.6%
associate-*l*71.6%
*-commutative71.6%
associate-/l*71.5%
Simplified71.5%
Taylor expanded in b around inf 69.9%
Taylor expanded in b around -inf 66.2%
associate-*r/66.2%
*-commutative66.2%
Simplified66.2%
associate-/r/66.9%
Applied egg-rr66.9%
Final simplification66.9%
(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{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 71.6%
sqr-neg71.6%
sqr-neg71.6%
associate-*l*71.6%
*-commutative71.6%
associate-/l*71.5%
Simplified71.5%
Taylor expanded in b around inf 69.9%
Taylor expanded in b around -inf 67.0%
associate-*r/67.0%
neg-mul-167.0%
Simplified67.0%
Final simplification67.0%
herbie shell --seed 2024019
(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)))))))