
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
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 = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
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 = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
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 = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) 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(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); 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 = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); 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[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $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{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
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 = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
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 = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
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 = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) 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(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); 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 = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); 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[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $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{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (/ c (- b))))
(if (<= b -1e+153)
(if (>= b 0.0) t_1 (- (/ c b) (/ b a)))
(if (<= b 3.2e-308)
(if (>= b 0.0)
(+ (* 2.0 (sqrt (/ c (* a -4.0)))) (/ (* b -0.5) a))
(/ (- t_0 b) (* a 2.0)))
(if (<= b 9.5e+114)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (* b -2.0) (* a 2.0)))
(if (>= b 0.0) t_1 (/ c b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = c / -b;
double tmp_1;
if (b <= -1e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 3.2e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * sqrt((c / (a * -4.0)))) + ((b * -0.5) / a);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 9.5e+114) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_0);
} else {
tmp_4 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_1;
} else {
tmp_1 = c / 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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = c / -b
if (b <= (-1d+153)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 3.2d-308) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * sqrt((c / (a * (-4.0d0))))) + ((b * (-0.5d0)) / a)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b <= 9.5d+114) then
if (b >= 0.0d0) then
tmp_4 = (c * 2.0d0) / (-b - t_0)
else
tmp_4 = (b * (-2.0d0)) / (a * 2.0d0)
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = t_1
else
tmp_1 = c / b
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = c / -b;
double tmp_1;
if (b <= -1e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 3.2e-308) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * Math.sqrt((c / (a * -4.0)))) + ((b * -0.5) / a);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 9.5e+114) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_0);
} else {
tmp_4 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_1;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = c / -b tmp_1 = 0 if b <= -1e+153: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 3.2e-308: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * math.sqrt((c / (a * -4.0)))) + ((b * -0.5) / a) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b <= 9.5e+114: tmp_4 = 0 if b >= 0.0: tmp_4 = (c * 2.0) / (-b - t_0) else: tmp_4 = (b * -2.0) / (a * 2.0) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = t_1 else: tmp_1 = c / b return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(c / Float64(-b)) tmp_1 = 0.0 if (b <= -1e+153) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 3.2e-308) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * sqrt(Float64(c / Float64(a * -4.0)))) + Float64(Float64(b * -0.5) / a)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 9.5e+114) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_4 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = t_1; else tmp_1 = Float64(c / b); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = c / -b; tmp_2 = 0.0; if (b <= -1e+153) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 3.2e-308) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * sqrt((c / (a * -4.0)))) + ((b * -0.5) / a); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b <= 9.5e+114) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (c * 2.0) / (-b - t_0); else tmp_5 = (b * -2.0) / (a * 2.0); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = t_1; else tmp_2 = c / b; end tmp_6 = 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[(c / (-b)), $MachinePrecision]}, If[LessEqual[b, -1e+153], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.2e-308], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[Sqrt[N[(c / N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(b * -0.5), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 9.5e+114], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$1, N[(c / b), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{c}{-b}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-308}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;2 \cdot \sqrt{\frac{c}{a \cdot -4}} + \frac{b \cdot -0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{+114}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < -1e153Initial program 43.8%
Simplified43.9%
add-sqr-sqrt43.9%
pow243.9%
pow1/243.9%
sqrt-pow143.9%
pow243.9%
metadata-eval43.9%
Applied egg-rr43.9%
Taylor expanded in b around -inf 94.6%
associate-*r*94.6%
neg-mul-194.6%
fma-define94.6%
Simplified94.6%
Taylor expanded in c around 0 94.6%
associate-*r/94.6%
mul-1-neg94.6%
Simplified94.6%
Taylor expanded in c around 0 95.4%
+-commutative95.4%
mul-1-neg95.4%
unsub-neg95.4%
Simplified95.4%
if -1e153 < b < 3.2000000000000001e-308Initial program 90.7%
add-cbrt-cube89.7%
pow389.7%
*-commutative89.7%
Applied egg-rr89.7%
Taylor expanded in c around 0 90.7%
*-commutative90.7%
Simplified90.7%
add-cube-cbrt90.7%
pow390.7%
*-commutative90.7%
Applied egg-rr90.7%
Taylor expanded in c around -inf 89.6%
+-commutative89.6%
rem-cube-cbrt89.6%
associate-*r/89.6%
*-commutative89.6%
times-frac89.6%
unpow289.6%
rem-square-sqrt90.7%
rem-cube-cbrt90.7%
metadata-eval90.7%
metadata-eval90.7%
associate-*r/90.7%
Simplified90.7%
if 3.2000000000000001e-308 < b < 9.5000000000000001e114Initial program 90.5%
Taylor expanded in b around -inf 90.5%
*-commutative90.5%
Simplified90.5%
if 9.5000000000000001e114 < b Initial program 56.0%
Simplified56.1%
add-sqr-sqrt56.1%
pow256.1%
pow1/256.1%
sqrt-pow156.1%
pow256.1%
metadata-eval56.1%
Applied egg-rr56.1%
Taylor expanded in b around -inf 56.1%
associate-*r*56.1%
neg-mul-156.1%
fma-define56.1%
Simplified56.1%
Taylor expanded in c around 0 98.1%
associate-*r/98.1%
mul-1-neg98.1%
Simplified98.1%
Taylor expanded in b around 0 98.1%
Final simplification92.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (/ c (- b))))
(if (<= b -2e+152)
(if (>= b 0.0) t_1 (- (/ c b) (/ b a)))
(if (<= b 7e+114)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0) t_1 (/ c b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = c / -b;
double tmp_1;
if (b <= -2e+152) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 7e+114) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = t_1;
} else {
tmp_1 = c / 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) :: 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 = c / -b
if (b <= (-2d+152)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 7d+114) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = t_1
else
tmp_1 = c / b
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = c / -b;
double tmp_1;
if (b <= -2e+152) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 7e+114) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = t_1;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = c / -b tmp_1 = 0 if b <= -2e+152: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 7e+114: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) / (-b - t_0) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = t_1 else: tmp_1 = c / b return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(c / Float64(-b)) tmp_1 = 0.0 if (b <= -2e+152) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 7e+114) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = t_1; else tmp_1 = Float64(c / b); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = c / -b; tmp_2 = 0.0; if (b <= -2e+152) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 7e+114) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) / (-b - t_0); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = t_1; else tmp_2 = c / b; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c / (-b)), $MachinePrecision]}, If[LessEqual[b, -2e+152], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7e+114], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$1, N[(c / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{c}{-b}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+152}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{+114}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.0000000000000001e152Initial program 43.8%
Simplified43.9%
add-sqr-sqrt43.9%
pow243.9%
pow1/243.9%
sqrt-pow143.9%
pow243.9%
metadata-eval43.9%
Applied egg-rr43.9%
Taylor expanded in b around -inf 94.6%
associate-*r*94.6%
neg-mul-194.6%
fma-define94.6%
Simplified94.6%
Taylor expanded in c around 0 94.6%
associate-*r/94.6%
mul-1-neg94.6%
Simplified94.6%
Taylor expanded in c around 0 95.4%
+-commutative95.4%
mul-1-neg95.4%
unsub-neg95.4%
Simplified95.4%
if -2.0000000000000001e152 < b < 7.0000000000000001e114Initial program 90.6%
if 7.0000000000000001e114 < b Initial program 56.0%
Simplified56.1%
add-sqr-sqrt56.1%
pow256.1%
pow1/256.1%
sqrt-pow156.1%
pow256.1%
metadata-eval56.1%
Applied egg-rr56.1%
Taylor expanded in b around -inf 56.1%
associate-*r*56.1%
neg-mul-156.1%
fma-define56.1%
Simplified56.1%
Taylor expanded in c around 0 98.1%
associate-*r/98.1%
mul-1-neg98.1%
Simplified98.1%
Taylor expanded in b around 0 98.1%
Final simplification92.8%
(FPCore (a b c)
:precision binary64
(if (<= b -6e+149)
(if (>= b 0.0) (/ c (- b)) (- (/ c b) (/ b a)))
(if (<= b 1.15e-225)
(if (>= b 0.0)
(+ (* 2.0 (sqrt (/ c (* a -4.0)))) (/ (* b -0.5) a))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (>= b 0.0) (/ c (- (* (/ c b) a) b)) (/ (* b -2.0) (* a 2.0))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -6e+149) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.15e-225) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * sqrt((c / (a * -4.0)))) + ((b * -0.5) / a);
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / (((c / b) * a) - b);
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b <= (-6d+149)) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 1.15d-225) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * sqrt((c / (a * (-4.0d0))))) + ((b * (-0.5d0)) / a)
else
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = c / (((c / b) * a) - b)
else
tmp_1 = (b * (-2.0d0)) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -6e+149) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.15e-225) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * Math.sqrt((c / (a * -4.0)))) + ((b * -0.5) / a);
} else {
tmp_3 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / (((c / b) * a) - b);
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -6e+149: tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 1.15e-225: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * math.sqrt((c / (a * -4.0)))) + ((b * -0.5) / a) else: tmp_3 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = c / (((c / b) * a) - b) else: tmp_1 = (b * -2.0) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -6e+149) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 1.15e-225) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * sqrt(Float64(c / Float64(a * -4.0)))) + Float64(Float64(b * -0.5) / a)); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(Float64(Float64(c / b) * a) - b)); else tmp_1 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end return tmp_1 end
function tmp_5 = code(a, b, c) tmp_2 = 0.0; if (b <= -6e+149) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 1.15e-225) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * sqrt((c / (a * -4.0)))) + ((b * -0.5) / a); else tmp_4 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = c / (((c / b) * a) - b); else tmp_2 = (b * -2.0) / (a * 2.0); end tmp_5 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -6e+149], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.15e-225], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[Sqrt[N[(c / N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(b * -0.5), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / N[(N[(N[(c / b), $MachinePrecision] * a), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+149}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-225}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;2 \cdot \sqrt{\frac{c}{a \cdot -4}} + \frac{b \cdot -0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{\frac{c}{b} \cdot a - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
if b < -6.00000000000000007e149Initial program 43.8%
Simplified43.9%
add-sqr-sqrt43.9%
pow243.9%
pow1/243.9%
sqrt-pow143.9%
pow243.9%
metadata-eval43.9%
Applied egg-rr43.9%
Taylor expanded in b around -inf 94.6%
associate-*r*94.6%
neg-mul-194.6%
fma-define94.6%
Simplified94.6%
Taylor expanded in c around 0 94.6%
associate-*r/94.6%
mul-1-neg94.6%
Simplified94.6%
Taylor expanded in c around 0 95.4%
+-commutative95.4%
mul-1-neg95.4%
unsub-neg95.4%
Simplified95.4%
if -6.00000000000000007e149 < b < 1.1499999999999999e-225Initial program 91.4%
add-cbrt-cube85.6%
pow385.6%
*-commutative85.6%
Applied egg-rr85.6%
Taylor expanded in c around 0 91.4%
*-commutative91.4%
Simplified91.4%
add-cube-cbrt91.4%
pow391.4%
*-commutative91.4%
Applied egg-rr91.4%
Taylor expanded in c around -inf 82.2%
+-commutative82.2%
rem-cube-cbrt82.2%
associate-*r/82.2%
*-commutative82.2%
times-frac82.2%
unpow282.2%
rem-square-sqrt85.5%
rem-cube-cbrt85.5%
metadata-eval85.5%
metadata-eval85.5%
associate-*r/85.5%
Simplified85.5%
if 1.1499999999999999e-225 < b Initial program 75.5%
Taylor expanded in a around 0 76.8%
distribute-lft-out--76.8%
associate-/l*81.1%
fma-neg81.1%
Simplified81.1%
Taylor expanded in b around -inf 81.1%
*-commutative75.5%
Simplified81.1%
associate-/l*81.1%
Applied egg-rr81.1%
associate-*r/81.1%
times-frac81.1%
metadata-eval81.1%
*-lft-identity81.1%
fma-neg81.1%
Simplified81.1%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+150)
(if (>= b 0.0) (/ c (- b)) (- (/ c b) (/ b a)))
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.6e+150) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.6e+150) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+150], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+150}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.60000000000000008e150Initial program 43.8%
Simplified43.9%
add-sqr-sqrt43.9%
pow243.9%
pow1/243.9%
sqrt-pow143.9%
pow243.9%
metadata-eval43.9%
Applied egg-rr43.9%
Taylor expanded in b around -inf 94.6%
associate-*r*94.6%
neg-mul-194.6%
fma-define94.6%
Simplified94.6%
Taylor expanded in c around 0 94.6%
associate-*r/94.6%
mul-1-neg94.6%
Simplified94.6%
Taylor expanded in c around 0 95.4%
+-commutative95.4%
mul-1-neg95.4%
unsub-neg95.4%
Simplified95.4%
if -1.60000000000000008e150 < b Initial program 82.8%
Taylor expanded in a around 0 79.4%
distribute-lft-out--79.4%
associate-/l*81.8%
fma-neg81.8%
Simplified81.8%
Final simplification84.1%
(FPCore (a b c) :precision binary64 (if (<= b 8.2e-280) (if (>= b 0.0) (/ b a) (/ b (- a))) (if (>= b 0.0) (/ c (- b)) (/ c b))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 8.2e-280) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / 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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= 8.2d-280) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = c / -b
else
tmp_1 = c / b
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= 8.2e-280) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = c / b;
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 8.2e-280: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = b / -a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = c / -b else: tmp_1 = c / b return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 8.2e-280) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(c / b); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 8.2e-280) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = c / -b; else tmp_2 = c / b; end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 8.2e-280], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(c / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.2 \cdot 10^{-280}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 8.2000000000000003e-280Initial program 75.6%
Taylor expanded in a around 0 73.4%
distribute-lft-out--73.4%
associate-/l*73.4%
fma-neg73.4%
Simplified73.4%
Taylor expanded in b around -inf 70.4%
*-commutative72.5%
Simplified70.4%
Taylor expanded in c around inf 70.4%
Taylor expanded in b around 0 70.4%
associate-*r/70.4%
neg-mul-170.4%
Simplified70.4%
if 8.2000000000000003e-280 < b Initial program 76.7%
Simplified76.6%
add-sqr-sqrt76.6%
pow276.6%
pow1/276.6%
sqrt-pow176.6%
pow276.6%
metadata-eval76.6%
Applied egg-rr76.6%
Taylor expanded in b around -inf 76.6%
associate-*r*76.6%
neg-mul-176.6%
fma-define76.6%
Simplified76.6%
Taylor expanded in c around 0 77.1%
associate-*r/77.1%
mul-1-neg77.1%
Simplified77.1%
Taylor expanded in b around 0 77.1%
Final simplification73.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c (- b)) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = (c / b) - (b / a);
}
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) - (b / a)
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) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); else tmp = Float64(Float64(c / b) - Float64(b / a)); 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) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
Initial program 76.1%
Simplified76.1%
add-sqr-sqrt75.9%
pow275.9%
pow1/275.9%
sqrt-pow176.0%
pow276.0%
metadata-eval76.0%
Applied egg-rr76.0%
Taylor expanded in b around -inf 74.0%
associate-*r*74.0%
neg-mul-174.0%
fma-define74.0%
Simplified74.0%
Taylor expanded in c around 0 73.1%
associate-*r/73.1%
mul-1-neg73.1%
Simplified73.1%
Taylor expanded in c around 0 73.7%
+-commutative73.7%
mul-1-neg73.7%
unsub-neg73.7%
Simplified73.7%
Final simplification73.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ b a) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = b / -a;
}
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 = b / -a
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 = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = b / a else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(b / a); else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = b / a; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 76.1%
Taylor expanded in a around 0 73.3%
distribute-lft-out--73.3%
associate-/l*75.2%
fma-neg75.2%
Simplified75.2%
Taylor expanded in b around -inf 73.6%
*-commutative74.5%
Simplified73.6%
Taylor expanded in c around inf 38.9%
Taylor expanded in b around 0 38.9%
associate-*r/38.9%
neg-mul-138.9%
Simplified38.9%
Final simplification38.9%
herbie shell --seed 2024141
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))