
(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 (* 4.0 a))))) (t_1 (/ (- c) b)))
(if (<= b -5.2e+140)
(if (>= b 0.0) (/ c b) t_1)
(if (<= b 1.7e+103)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b)))
(if (>= b 0.0) (- (/ c b) (/ b a)) t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = -c / b;
double tmp_1;
if (b <= -5.2e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1.7e+103) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_1;
}
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 * (4.0d0 * a))))
t_1 = -c / b
if (b <= (-5.2d+140)) then
if (b >= 0.0d0) then
tmp_2 = c / b
else
tmp_2 = t_1
end if
tmp_1 = tmp_2
else if (b <= 1.7d+103) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (a * 2.0d0)
else
tmp_3 = (c * 2.0d0) / (t_0 - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = -c / b;
double tmp_1;
if (b <= -5.2e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1.7e+103) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) t_1 = -c / b tmp_1 = 0 if b <= -5.2e+140: tmp_2 = 0 if b >= 0.0: tmp_2 = c / b else: tmp_2 = t_1 tmp_1 = tmp_2 elif b <= 1.7e+103: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (a * 2.0) else: tmp_3 = (c * 2.0) / (t_0 - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(-c) / b) tmp_1 = 0.0 if (b <= -5.2e+140) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= 1.7e+103) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(c * 2.0) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); t_1 = -c / b; tmp_2 = 0.0; if (b <= -5.2e+140) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / b; else tmp_3 = t_1; end tmp_2 = tmp_3; elseif (b <= 1.7e+103) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (a * 2.0); else tmp_4 = (c * 2.0) / (t_0 - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-c) / b), $MachinePrecision]}, If[LessEqual[b, -5.2e+140], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], t$95$1], If[LessEqual[b, 1.7e+103], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{-c}{b}\\
\mathbf{if}\;b \leq -5.2 \cdot 10^{+140}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{+103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -5.2000000000000002e140Initial program 54.0%
Taylor expanded in b around -inf 97.5%
associate-*r/97.5%
neg-mul-197.5%
Simplified97.5%
Taylor expanded in b around inf 97.5%
Taylor expanded in b around 0 97.5%
if -5.2000000000000002e140 < b < 1.6999999999999999e103Initial program 87.5%
if 1.6999999999999999e103 < b Initial program 50.8%
Taylor expanded in b around -inf 50.8%
associate-*r/50.8%
neg-mul-150.8%
Simplified50.8%
Taylor expanded in b around inf 92.8%
Taylor expanded in b around 0 96.7%
+-commutative96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
Final simplification90.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* c a))))) (t_1 (/ (- c) b)))
(if (<= b -1.25e+127)
(if (>= b 0.0) (/ c b) t_1)
(if (<= b 1.1e+103)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ 2.0 (/ (- t_0 b) c)))
(if (>= b 0.0) (- (/ c b) (/ b a)) t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (c * a))));
double t_1 = -c / b;
double tmp_1;
if (b <= -1.25e+127) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+103) {
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 = t_1;
}
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 * (c * a))))
t_1 = -c / b
if (b <= (-1.25d+127)) then
if (b >= 0.0d0) then
tmp_2 = c / b
else
tmp_2 = t_1
end if
tmp_1 = tmp_2
else if (b <= 1.1d+103) 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 = t_1
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 * (c * a))));
double t_1 = -c / b;
double tmp_1;
if (b <= -1.25e+127) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+103) {
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 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (c * a)))) t_1 = -c / b tmp_1 = 0 if b <= -1.25e+127: tmp_2 = 0 if b >= 0.0: tmp_2 = c / b else: tmp_2 = t_1 tmp_1 = tmp_2 elif b <= 1.1e+103: 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 = t_1 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a)))) t_1 = Float64(Float64(-c) / b) tmp_1 = 0.0 if (b <= -1.25e+127) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= 1.1e+103) 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 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (c * a)))); t_1 = -c / b; tmp_2 = 0.0; if (b <= -1.25e+127) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / b; else tmp_3 = t_1; end tmp_2 = tmp_3; elseif (b <= 1.1e+103) 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 = t_1; 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[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-c) / b), $MachinePrecision]}, If[LessEqual[b, -1.25e+127], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], t$95$1], If[LessEqual[b, 1.1e+103], 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], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\\
t_1 := \frac{-c}{b}\\
\mathbf{if}\;b \leq -1.25 \cdot 10^{+127}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+103}:\\
\;\;\;\;\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}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -1.2500000000000001e127Initial program 57.5%
Taylor expanded in b around -inf 97.7%
associate-*r/97.7%
neg-mul-197.7%
Simplified97.7%
Taylor expanded in b around inf 97.7%
Taylor expanded in b around 0 97.7%
if -1.2500000000000001e127 < b < 1.09999999999999996e103Initial program 87.2%
Simplified87.1%
if 1.09999999999999996e103 < b Initial program 50.8%
Taylor expanded in b around -inf 50.8%
associate-*r/50.8%
neg-mul-150.8%
Simplified50.8%
Taylor expanded in b around inf 92.8%
Taylor expanded in b around 0 96.7%
+-commutative96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
Final simplification90.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b)))
(if (<= b -3.4e+127)
(if (>= b 0.0) (/ c b) t_0)
(if (<= b -1.35e-308)
(if (>= b 0.0)
(/ (- b (fma -2.0 (* c (/ a b)) b)) (* a 2.0))
(/ 2.0 (/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) c)))
(if (<= b 1.06e-21)
(if (>= b 0.0)
(/ (- (- b) (sqrt (* c (* a -4.0)))) (* a 2.0))
(/ 2.0 (fma 2.0 (/ a b) (* -2.0 (/ b c)))))
(if (>= b 0.0) (- (/ c b) (/ b a)) t_0))))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double tmp_1;
if (b <= -3.4e+127) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1.35e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (b - fma(-2.0, (c * (a / b)), b)) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((sqrt(((b * b) - (4.0 * (c * a)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 1.06e-21) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt((c * (a * -4.0)))) / (a * 2.0);
} else {
tmp_4 = 2.0 / fma(2.0, (a / b), (-2.0 * (b / c)));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-c) / b) tmp_1 = 0.0 if (b <= -3.4e+127) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -1.35e-308) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(b - fma(-2.0, Float64(c * Float64(a / b)), b)) / Float64(a * 2.0)); else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a)))) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 1.06e-21) 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 / fma(2.0, Float64(a / b), Float64(-2.0 * Float64(b / c)))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, If[LessEqual[b, -3.4e+127], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], t$95$0], If[LessEqual[b, -1.35e-308], If[GreaterEqual[b, 0.0], N[(N[(b - N[(-2.0 * N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.06e-21], 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[(2.0 * N[(a / b), $MachinePrecision] + N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
\mathbf{if}\;b \leq -3.4 \cdot 10^{+127}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \leq -1.35 \cdot 10^{-308}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b - \mathsf{fma}\left(-2, c \cdot \frac{a}{b}, b\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.06 \cdot 10^{-21}:\\
\;\;\;\;\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}{\mathsf{fma}\left(2, \frac{a}{b}, -2 \cdot \frac{b}{c}\right)}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -3.39999999999999977e127Initial program 57.5%
Taylor expanded in b around -inf 97.7%
associate-*r/97.7%
neg-mul-197.7%
Simplified97.7%
Taylor expanded in b around inf 97.7%
Taylor expanded in b around 0 97.7%
if -3.39999999999999977e127 < b < -1.3499999999999998e-308Initial program 90.8%
Simplified90.5%
Taylor expanded in b around inf 90.5%
+-commutative90.5%
fma-def90.5%
associate-/l*90.5%
Simplified90.5%
div-sub90.5%
add-sqr-sqrt90.5%
sqrt-unprod90.5%
sqr-neg90.5%
sqrt-prod90.5%
add-sqr-sqrt90.5%
associate-/r/90.5%
Applied egg-rr90.5%
div-sub90.5%
*-commutative90.5%
Simplified90.5%
if -1.3499999999999998e-308 < b < 1.05999999999999994e-21Initial program 78.1%
Simplified78.1%
Taylor expanded in b around -inf 78.1%
+-commutative78.1%
fma-def78.1%
Simplified78.1%
Taylor expanded in b around 0 64.9%
*-commutative21.3%
*-commutative21.3%
associate-*r*21.3%
Simplified64.9%
if 1.05999999999999994e-21 < b Initial program 66.8%
Taylor expanded in b around -inf 66.8%
associate-*r/66.8%
neg-mul-166.8%
Simplified66.8%
Taylor expanded in b around inf 90.8%
Taylor expanded in b around 0 93.3%
+-commutative93.3%
mul-1-neg93.3%
unsub-neg93.3%
Simplified93.3%
Final simplification86.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -2.0 (/ b c)))
(t_1 (/ (- (- b) b) (* a 2.0)))
(t_2 (sqrt (* c (* a -4.0)))))
(if (<= b -2.9e-99)
(if (>= b 0.0) t_1 (/ 2.0 (+ t_0 (* 2.0 (/ a b)))))
(if (<= b -9.5e-297)
(if (>= b 0.0) t_1 (/ 2.0 (/ (- t_2 b) c)))
(if (<= b 6.5e-21)
(if (>= b 0.0)
(/ (- (- b) t_2) (* a 2.0))
(/ 2.0 (fma 2.0 (/ a b) t_0)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (/ (- c) b)))))))
double code(double a, double b, double c) {
double t_0 = -2.0 * (b / c);
double t_1 = (-b - b) / (a * 2.0);
double t_2 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -2.9e-99) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = 2.0 / (t_0 + (2.0 * (a / b)));
}
tmp_1 = tmp_2;
} else if (b <= -9.5e-297) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 2.0 / ((t_2 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 6.5e-21) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_2) / (a * 2.0);
} else {
tmp_4 = 2.0 / fma(2.0, (a / b), t_0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = -c / b;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(-2.0 * Float64(b / c)) t_1 = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)) t_2 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -2.9e-99) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(2.0 / Float64(t_0 + Float64(2.0 * Float64(a / b)))); end tmp_1 = tmp_2; elseif (b <= -9.5e-297) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(2.0 / Float64(Float64(t_2 - b) / c)); end tmp_1 = tmp_3; elseif (b <= 6.5e-21) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_2) / Float64(a * 2.0)); else tmp_4 = Float64(2.0 / fma(2.0, Float64(a / b), t_0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(Float64(-c) / b); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.9e-99], If[GreaterEqual[b, 0.0], t$95$1, N[(2.0 / N[(t$95$0 + N[(2.0 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -9.5e-297], If[GreaterEqual[b, 0.0], t$95$1, N[(2.0 / N[(N[(t$95$2 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6.5e-21], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$2), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(2.0 * N[(a / b), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \frac{b}{c}\\
t_1 := \frac{\left(-b\right) - b}{a \cdot 2}\\
t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -2.9 \cdot 10^{-99}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{t_0 + 2 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{elif}\;b \leq -9.5 \cdot 10^{-297}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_2 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-21}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_2}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(2, \frac{a}{b}, t_0\right)}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.89999999999999985e-99Initial program 75.6%
Simplified75.5%
Taylor expanded in b around inf 75.5%
Taylor expanded in b around -inf 85.1%
if -2.89999999999999985e-99 < b < -9.5000000000000005e-297Initial program 91.0%
Simplified90.6%
Taylor expanded in b around inf 90.6%
Taylor expanded in b around 0 82.7%
*-commutative82.7%
*-commutative82.7%
associate-*r*82.7%
Simplified82.7%
if -9.5000000000000005e-297 < b < 6.49999999999999987e-21Initial program 76.9%
Simplified76.9%
Taylor expanded in b around -inf 76.9%
+-commutative76.9%
fma-def76.9%
Simplified76.9%
Taylor expanded in b around 0 63.9%
*-commutative21.0%
*-commutative21.0%
associate-*r*21.0%
Simplified63.9%
if 6.49999999999999987e-21 < b Initial program 66.8%
Taylor expanded in b around -inf 66.8%
associate-*r/66.8%
neg-mul-166.8%
Simplified66.8%
Taylor expanded in b around inf 90.8%
Taylor expanded in b around 0 93.3%
+-commutative93.3%
mul-1-neg93.3%
unsub-neg93.3%
Simplified93.3%
Final simplification82.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e-111)
(if (>= b 0.0)
(/ (- (- b) b) (* a 2.0))
(/ 2.0 (+ (* -2.0 (/ b c)) (* 2.0 (/ a b)))))
(if (>= b 0.0)
(fma -1.0 (/ b a) (/ c b))
(* c (/ 2.0 (+ b (sqrt (* (* c a) -4.0))))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.45e-111) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - b) / (a * 2.0);
} else {
tmp_2 = 2.0 / ((-2.0 * (b / c)) + (2.0 * (a / 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(((c * a) * -4.0))));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.45e-111) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp_2 = Float64(2.0 / Float64(Float64(-2.0 * Float64(b / c)) + Float64(2.0 * Float64(a / 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(Float64(c * a) * -4.0))))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1.45e-111], If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-111}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{-2 \cdot \frac{b}{c} + 2 \cdot \frac{a}{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{\left(c \cdot a\right) \cdot -4}}\\
\end{array}
\end{array}
if b < -1.45000000000000001e-111Initial program 76.8%
Simplified76.6%
Taylor expanded in b around inf 76.6%
Taylor expanded in b around -inf 83.6%
if -1.45000000000000001e-111 < b Initial program 74.2%
Simplified74.1%
Taylor expanded in b around inf 66.0%
+-commutative66.0%
fma-def66.0%
associate-/l*66.9%
Simplified66.9%
Taylor expanded in b around 0 67.4%
fma-def67.4%
Simplified67.4%
Taylor expanded in b around 0 67.0%
*-commutative67.0%
*-commutative67.0%
associate-*r*67.0%
Simplified67.0%
associate-/r/67.0%
add-sqr-sqrt67.0%
sqrt-unprod66.9%
sqr-neg66.9%
sqrt-unprod52.3%
add-sqr-sqrt66.4%
associate-*r*66.4%
*-commutative66.4%
*-commutative66.4%
Applied egg-rr66.4%
Final simplification72.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (fma -1.0 (/ b a) (/ c b)) (/ 2.0 (/ (- (- (* (/ c b) (* a 2.0)) b) 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 = 2.0 / (((((c / b) * (a * 2.0)) - b) - 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(2.0 / Float64(Float64(Float64(Float64(Float64(c / b) * Float64(a * 2.0)) - b) - 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[(2.0 / N[(N[(N[(N[(N[(c / b), $MachinePrecision] * N[(a * 2.0), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / c), $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}:\\
\;\;\;\;\frac{2}{\frac{\left(\frac{c}{b} \cdot \left(a \cdot 2\right) - b\right) - b}{c}}\\
\end{array}
\end{array}
Initial program 75.0%
Simplified74.9%
Taylor expanded in b around inf 69.5%
+-commutative69.5%
fma-def69.5%
associate-/l*70.0%
Simplified70.0%
Taylor expanded in b around 0 70.4%
fma-def70.4%
Simplified70.4%
add-cube-cbrt70.3%
pow270.3%
cancel-sign-sub-inv70.3%
fma-def70.3%
metadata-eval70.3%
cancel-sign-sub-inv70.3%
fma-def70.3%
metadata-eval70.3%
Applied egg-rr70.3%
Taylor expanded in b around -inf 62.8%
+-commutative62.8%
mul-1-neg62.8%
unsub-neg62.8%
associate-*r/63.5%
*-commutative63.5%
*-commutative63.5%
associate-*l*63.5%
Simplified63.5%
Final simplification63.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c / b) - (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 = (c / b) - (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 = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 75.0%
Taylor expanded in b around -inf 68.0%
associate-*r/68.0%
neg-mul-168.0%
Simplified68.0%
Taylor expanded in b around inf 62.5%
Taylor expanded in b around 0 63.5%
+-commutative63.5%
mul-1-neg63.5%
unsub-neg63.5%
Simplified63.5%
Final simplification63.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c b) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / b;
} 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 = c / b
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 = c / b;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / b else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / b); 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 = c / b; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 75.0%
Taylor expanded in b around -inf 68.0%
associate-*r/68.0%
neg-mul-168.0%
Simplified68.0%
Taylor expanded in b around inf 62.5%
Taylor expanded in b around 0 30.5%
Final simplification30.5%
(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 75.0%
Taylor expanded in b around -inf 68.0%
associate-*r/68.0%
neg-mul-168.0%
Simplified68.0%
Taylor expanded in b around inf 62.9%
*-commutative62.9%
Simplified62.9%
Taylor expanded in b around 0 63.2%
associate-*r/63.2%
mul-1-neg63.2%
Simplified63.2%
Final simplification63.2%
herbie shell --seed 2023331
(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)))))))