
(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 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) (/ (* 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 (/ b (- a))))
(if (<= b -5.2e+151)
t_1
(if (<= b 8e+96)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = b / -a;
double tmp;
if (b <= -5.2e+151) {
tmp = t_1;
} else if (b <= 8e+96) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = b / -a
if (b <= (-5.2d+151)) then
tmp = t_1
else if (b <= 8d+96) then
if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (-b - t_0)
else
tmp_1 = (t_0 - b) / (a * 2.0d0)
end if
tmp = tmp_1
else if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = t_1
end if
code = tmp
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 / -a;
double tmp;
if (b <= -5.2e+151) {
tmp = t_1;
} else if (b <= 8e+96) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = b / -a tmp = 0 if b <= -5.2e+151: tmp = t_1 elif b <= 8e+96: tmp_1 = 0 if b >= 0.0: tmp_1 = (2.0 * c) / (-b - t_0) else: tmp_1 = (t_0 - b) / (a * 2.0) tmp = tmp_1 elif b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = t_1 return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(b / Float64(-a)) tmp = 0.0 if (b <= -5.2e+151) tmp = t_1; elseif (b <= 8e+96) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_1 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp = tmp_1; elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp = t_1; end return tmp end
function tmp_3 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = b / -a; tmp = 0.0; if (b <= -5.2e+151) tmp = t_1; elseif (b <= 8e+96) tmp_2 = 0.0; if (b >= 0.0) tmp_2 = (2.0 * c) / (-b - t_0); else tmp_2 = (t_0 - b) / (a * 2.0); end tmp = tmp_2; elseif (b >= 0.0) tmp = (2.0 * c) / (b * -2.0); else tmp = t_1; end tmp_3 = tmp; 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 / (-a)), $MachinePrecision]}, If[LessEqual[b, -5.2e+151], t$95$1, If[LessEqual[b, 8e+96], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $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], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{b}{-a}\\
\mathbf{if}\;b \leq -5.2 \cdot 10^{+151}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 8 \cdot 10^{+96}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -5.20000000000000026e151Initial program 41.5%
frac-2neg41.5%
div-inv41.5%
Applied egg-rr41.5%
Taylor expanded in b around -inf 95.8%
Taylor expanded in b around -inf 95.8%
neg-mul-195.8%
distribute-neg-frac295.8%
Simplified95.8%
if -5.20000000000000026e151 < b < 8.0000000000000004e96Initial program 84.6%
if 8.0000000000000004e96 < b Initial program 57.6%
frac-2neg57.6%
div-inv57.6%
Applied egg-rr57.6%
Taylor expanded in b around -inf 57.6%
Taylor expanded in b around inf 98.3%
*-commutative98.3%
Simplified98.3%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (/ b (- a))))
(if (<= b -1e+154)
t_1
(if (<= b -4e-310)
(if (>= b 0.0) (/ b a) (/ (- t_0 b) (* a 2.0)))
(if (<= b 4.5e+96)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) t_0))
(/ (* -2.0 (* a (/ c b))) (* a 2.0)))
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) t_1))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = b / -a;
double tmp;
if (b <= -1e+154) {
tmp = t_1;
} else if (b <= -4e-310) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = b / a;
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b <= 4.5e+96) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_0);
} else {
tmp_2 = (-2.0 * (a * (c / b))) / (a * 2.0);
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = b / -a
if (b <= (-1d+154)) then
tmp = t_1
else if (b <= (-4d-310)) then
if (b >= 0.0d0) then
tmp_1 = b / a
else
tmp_1 = (t_0 - b) / (a * 2.0d0)
end if
tmp = tmp_1
else if (b <= 4.5d+96) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - t_0)
else
tmp_2 = ((-2.0d0) * (a * (c / b))) / (a * 2.0d0)
end if
tmp = tmp_2
else if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = t_1
end if
code = tmp
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 / -a;
double tmp;
if (b <= -1e+154) {
tmp = t_1;
} else if (b <= -4e-310) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = b / a;
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b <= 4.5e+96) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_0);
} else {
tmp_2 = (-2.0 * (a * (c / b))) / (a * 2.0);
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = b / -a tmp = 0 if b <= -1e+154: tmp = t_1 elif b <= -4e-310: tmp_1 = 0 if b >= 0.0: tmp_1 = b / a else: tmp_1 = (t_0 - b) / (a * 2.0) tmp = tmp_1 elif b <= 4.5e+96: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - t_0) else: tmp_2 = (-2.0 * (a * (c / b))) / (a * 2.0) tmp = tmp_2 elif b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = t_1 return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(b / Float64(-a)) tmp = 0.0 if (b <= -1e+154) tmp = t_1; elseif (b <= -4e-310) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(b / a); else tmp_1 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp = tmp_1; elseif (b <= 4.5e+96) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_2 = Float64(Float64(-2.0 * Float64(a * Float64(c / b))) / Float64(a * 2.0)); end tmp = tmp_2; elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp = t_1; end return tmp end
function tmp_4 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = b / -a; tmp = 0.0; if (b <= -1e+154) tmp = t_1; elseif (b <= -4e-310) tmp_2 = 0.0; if (b >= 0.0) tmp_2 = b / a; else tmp_2 = (t_0 - b) / (a * 2.0); end tmp = tmp_2; elseif (b <= 4.5e+96) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - t_0); else tmp_3 = (-2.0 * (a * (c / b))) / (a * 2.0); end tmp = tmp_3; elseif (b >= 0.0) tmp = (2.0 * c) / (b * -2.0); else tmp = t_1; end tmp_4 = tmp; 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 / (-a)), $MachinePrecision]}, If[LessEqual[b, -1e+154], t$95$1, If[LessEqual[b, -4e-310], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4.5e+96], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{b}{-a}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{+96}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \left(a \cdot \frac{c}{b}\right)}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.00000000000000004e154Initial program 41.5%
frac-2neg41.5%
div-inv41.5%
Applied egg-rr41.5%
Taylor expanded in b around -inf 95.8%
Taylor expanded in b around -inf 95.8%
neg-mul-195.8%
distribute-neg-frac295.8%
Simplified95.8%
if -1.00000000000000004e154 < b < -3.999999999999988e-310Initial program 88.5%
flip--88.5%
div-inv88.5%
sqr-neg88.5%
pow288.5%
add-sqr-sqrt88.5%
fmm-def88.5%
*-commutative88.5%
distribute-rgt-neg-in88.5%
distribute-lft-neg-in88.5%
metadata-eval88.5%
*-commutative88.5%
Applied egg-rr88.5%
Taylor expanded in c around 0 88.5%
if -3.999999999999988e-310 < b < 4.49999999999999957e96Initial program 79.9%
add-cbrt-cube79.9%
pow379.9%
sqrt-pow279.9%
fmm-def79.9%
*-commutative79.9%
distribute-rgt-neg-in79.9%
distribute-lft-neg-in79.9%
metadata-eval79.9%
*-commutative79.9%
metadata-eval79.9%
Applied egg-rr79.9%
Taylor expanded in b around inf 79.9%
associate-/l*79.9%
Simplified79.9%
if 4.49999999999999957e96 < b Initial program 57.6%
frac-2neg57.6%
div-inv57.6%
Applied egg-rr57.6%
Taylor expanded in b around -inf 57.6%
Taylor expanded in b around inf 98.3%
*-commutative98.3%
Simplified98.3%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (/ b (- a))))
(if (<= b -5.5e+151)
t_1
(if (<= b -4e-310)
(if (>= b 0.0) (/ b a) (/ (- t_0 b) (* a 2.0)))
(if (<= b 7.8e+96)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) t_1)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) t_1))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = b / -a;
double tmp;
if (b <= -5.5e+151) {
tmp = t_1;
} else if (b <= -4e-310) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = b / a;
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b <= 7.8e+96) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_0);
} else {
tmp_2 = t_1;
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = b / -a
if (b <= (-5.5d+151)) then
tmp = t_1
else if (b <= (-4d-310)) then
if (b >= 0.0d0) then
tmp_1 = b / a
else
tmp_1 = (t_0 - b) / (a * 2.0d0)
end if
tmp = tmp_1
else if (b <= 7.8d+96) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - t_0)
else
tmp_2 = t_1
end if
tmp = tmp_2
else if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = t_1
end if
code = tmp
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 / -a;
double tmp;
if (b <= -5.5e+151) {
tmp = t_1;
} else if (b <= -4e-310) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = b / a;
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b <= 7.8e+96) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_0);
} else {
tmp_2 = t_1;
}
tmp = tmp_2;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = b / -a tmp = 0 if b <= -5.5e+151: tmp = t_1 elif b <= -4e-310: tmp_1 = 0 if b >= 0.0: tmp_1 = b / a else: tmp_1 = (t_0 - b) / (a * 2.0) tmp = tmp_1 elif b <= 7.8e+96: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - t_0) else: tmp_2 = t_1 tmp = tmp_2 elif b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = t_1 return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(b / Float64(-a)) tmp = 0.0 if (b <= -5.5e+151) tmp = t_1; elseif (b <= -4e-310) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(b / a); else tmp_1 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp = tmp_1; elseif (b <= 7.8e+96) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_2 = t_1; end tmp = tmp_2; elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp = t_1; end return tmp end
function tmp_4 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = b / -a; tmp = 0.0; if (b <= -5.5e+151) tmp = t_1; elseif (b <= -4e-310) tmp_2 = 0.0; if (b >= 0.0) tmp_2 = b / a; else tmp_2 = (t_0 - b) / (a * 2.0); end tmp = tmp_2; elseif (b <= 7.8e+96) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - t_0); else tmp_3 = t_1; end tmp = tmp_3; elseif (b >= 0.0) tmp = (2.0 * c) / (b * -2.0); else tmp = t_1; end tmp_4 = tmp; 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 / (-a)), $MachinePrecision]}, If[LessEqual[b, -5.5e+151], t$95$1, If[LessEqual[b, -4e-310], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7.8e+96], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{b}{-a}\\
\mathbf{if}\;b \leq -5.5 \cdot 10^{+151}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{+96}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -5.4999999999999994e151Initial program 41.5%
frac-2neg41.5%
div-inv41.5%
Applied egg-rr41.5%
Taylor expanded in b around -inf 95.8%
Taylor expanded in b around -inf 95.8%
neg-mul-195.8%
distribute-neg-frac295.8%
Simplified95.8%
if -5.4999999999999994e151 < b < -3.999999999999988e-310Initial program 88.5%
flip--88.5%
div-inv88.5%
sqr-neg88.5%
pow288.5%
add-sqr-sqrt88.5%
fmm-def88.5%
*-commutative88.5%
distribute-rgt-neg-in88.5%
distribute-lft-neg-in88.5%
metadata-eval88.5%
*-commutative88.5%
Applied egg-rr88.5%
Taylor expanded in c around 0 88.5%
if -3.999999999999988e-310 < b < 7.8e96Initial program 79.9%
frac-2neg79.9%
div-inv79.9%
Applied egg-rr79.9%
Taylor expanded in b around -inf 79.9%
if 7.8e96 < b Initial program 57.6%
frac-2neg57.6%
div-inv57.6%
Applied egg-rr57.6%
Taylor expanded in b around -inf 57.6%
Taylor expanded in b around inf 98.3%
*-commutative98.3%
Simplified98.3%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ b (- a))))
(if (<= b -5.6e+153)
t_0
(if (<= b 5e-92)
(if (>= b 0.0)
(/
(expm1 (* c (+ 2.0 (* c (- (* c 2.6666666666666665) 2.0)))))
(* b -2.0))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b))) t_0)))))
double code(double a, double b, double c) {
double t_0 = b / -a;
double tmp;
if (b <= -5.6e+153) {
tmp = t_0;
} else if (b <= 5e-92) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = expm1((c * (2.0 + (c * ((c * 2.6666666666666665) - 2.0))))) / (b * -2.0);
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b, double c) {
double t_0 = b / -a;
double tmp;
if (b <= -5.6e+153) {
tmp = t_0;
} else if (b <= 5e-92) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = Math.expm1((c * (2.0 + (c * ((c * 2.6666666666666665) - 2.0))))) / (b * -2.0);
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = b / -a tmp = 0 if b <= -5.6e+153: tmp = t_0 elif b <= 5e-92: tmp_1 = 0 if b >= 0.0: tmp_1 = math.expm1((c * (2.0 + (c * ((c * 2.6666666666666665) - 2.0))))) / (b * -2.0) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp = tmp_1 elif b >= 0.0: tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(b / Float64(-a)) tmp = 0.0 if (b <= -5.6e+153) tmp = t_0; elseif (b <= 5e-92) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(expm1(Float64(c * Float64(2.0 + Float64(c * Float64(Float64(c * 2.6666666666666665) - 2.0))))) / Float64(b * -2.0)); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp = tmp_1; elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = t_0; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(b / (-a)), $MachinePrecision]}, If[LessEqual[b, -5.6e+153], t$95$0, If[LessEqual[b, 5e-92], If[GreaterEqual[b, 0.0], N[(N[(Exp[N[(c * N[(2.0 + N[(c * N[(N[(c * 2.6666666666666665), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(b * -2.0), $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[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{-a}\\
\mathbf{if}\;b \leq -5.6 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-92}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(c \cdot \left(2 + c \cdot \left(c \cdot 2.6666666666666665 - 2\right)\right)\right)}{b \cdot -2}\\
\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{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -5.5999999999999997e153Initial program 41.5%
frac-2neg41.5%
div-inv41.5%
Applied egg-rr41.5%
Taylor expanded in b around -inf 95.8%
Taylor expanded in b around -inf 95.8%
neg-mul-195.8%
distribute-neg-frac295.8%
Simplified95.8%
if -5.5999999999999997e153 < b < 5.00000000000000011e-92Initial program 82.4%
Taylor expanded in b around inf 69.9%
*-commutative41.3%
Simplified69.9%
expm1-log1p-u69.7%
expm1-undefine67.0%
*-commutative67.0%
Applied egg-rr67.0%
expm1-define69.7%
Simplified69.7%
Taylor expanded in c around 0 69.9%
if 5.00000000000000011e-92 < b Initial program 72.0%
frac-2neg72.0%
div-inv72.0%
Applied egg-rr72.0%
Taylor expanded in b around -inf 72.0%
Taylor expanded in a around 0 76.9%
distribute-lft-out--76.9%
associate-/l*82.8%
Simplified82.8%
Final simplification79.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ b (- a))))
(if (<= b -8.5e+153)
t_0
(if (<= b 1.26e-244)
(if (>= b 0.0)
(/ b a)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b))) t_0)))))
double code(double a, double b, double c) {
double t_0 = b / -a;
double tmp;
if (b <= -8.5e+153) {
tmp = t_0;
} else if (b <= 1.26e-244) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = b / a;
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = 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
real(8) :: tmp_1
t_0 = b / -a
if (b <= (-8.5d+153)) then
tmp = t_0
else if (b <= 1.26d-244) then
if (b >= 0.0d0) then
tmp_1 = b / a
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
tmp = tmp_1
else if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (2.0d0 * ((a * (c / b)) - b))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = b / -a;
double tmp;
if (b <= -8.5e+153) {
tmp = t_0;
} else if (b <= 1.26e-244) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = b / a;
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c): t_0 = b / -a tmp = 0 if b <= -8.5e+153: tmp = t_0 elif b <= 1.26e-244: tmp_1 = 0 if b >= 0.0: tmp_1 = b / a else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp = tmp_1 elif b >= 0.0: tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp = t_0 return tmp
function code(a, b, c) t_0 = Float64(b / Float64(-a)) tmp = 0.0 if (b <= -8.5e+153) tmp = t_0; elseif (b <= 1.26e-244) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(b / a); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp = tmp_1; elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = t_0; end return tmp end
function tmp_3 = code(a, b, c) t_0 = b / -a; tmp = 0.0; if (b <= -8.5e+153) tmp = t_0; elseif (b <= 1.26e-244) tmp_2 = 0.0; if (b >= 0.0) tmp_2 = b / a; else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp = tmp_2; elseif (b >= 0.0) tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)); else tmp = t_0; end tmp_3 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(b / (-a)), $MachinePrecision]}, If[LessEqual[b, -8.5e+153], t$95$0, If[LessEqual[b, 1.26e-244], If[GreaterEqual[b, 0.0], N[(b / a), $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[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{-a}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-244}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{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{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -8.49999999999999935e153Initial program 41.5%
frac-2neg41.5%
div-inv41.5%
Applied egg-rr41.5%
Taylor expanded in b around -inf 95.8%
Taylor expanded in b around -inf 95.8%
neg-mul-195.8%
distribute-neg-frac295.8%
Simplified95.8%
if -8.49999999999999935e153 < b < 1.25999999999999998e-244Initial program 85.5%
flip--85.4%
div-inv85.4%
sqr-neg85.4%
pow285.4%
add-sqr-sqrt85.4%
fmm-def85.4%
*-commutative85.4%
distribute-rgt-neg-in85.4%
distribute-lft-neg-in85.4%
metadata-eval85.4%
*-commutative85.4%
Applied egg-rr85.4%
Taylor expanded in c around 0 79.7%
if 1.25999999999999998e-244 < b Initial program 71.1%
frac-2neg71.1%
div-inv71.1%
Applied egg-rr71.1%
Taylor expanded in b around -inf 71.1%
Taylor expanded in a around 0 67.6%
distribute-lft-out--67.6%
associate-/l*72.5%
Simplified72.5%
Final simplification79.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+153)
(/ b (- a))
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+153) {
tmp = b / -a;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 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 <= (-5d+153)) then
tmp = b / -a
else if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+153) {
tmp = b / -a;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+153: tmp = b / -a elif b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+153) tmp = Float64(b / Float64(-a)); elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+153) tmp = b / -a; elseif (b >= 0.0) tmp = (2.0 * c) / (b * -2.0); else tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+153], N[(b / (-a)), $MachinePrecision], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $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 -5 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -5.00000000000000018e153Initial program 41.5%
frac-2neg41.5%
div-inv41.5%
Applied egg-rr41.5%
Taylor expanded in b around -inf 95.8%
Taylor expanded in b around -inf 95.8%
neg-mul-195.8%
distribute-neg-frac295.8%
Simplified95.8%
if -5.00000000000000018e153 < b Initial program 77.6%
Taylor expanded in b around inf 75.4%
*-commutative59.9%
Simplified75.4%
Final simplification78.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b))) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} 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 = (2.0d0 * c) / (2.0d0 * ((a * (c / b)) - b))
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 = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); 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 = (2.0 * c) / (2.0 * ((a * (c / b)) - b)); else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 71.4%
frac-2neg71.4%
div-inv71.3%
Applied egg-rr71.3%
Taylor expanded in b around -inf 67.9%
Taylor expanded in a around 0 64.1%
distribute-lft-out--64.1%
associate-/l*66.4%
Simplified66.4%
Final simplification66.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} 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 = (2.0d0 * c) / (b * (-2.0d0))
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 = (2.0 * c) / (b * -2.0);
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); 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 = (2.0 * c) / (b * -2.0); else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 71.4%
frac-2neg71.4%
div-inv71.3%
Applied egg-rr71.3%
Taylor expanded in b around -inf 67.9%
Taylor expanded in b around inf 66.1%
*-commutative66.1%
Simplified66.1%
Final simplification66.1%
(FPCore (a b c) :precision binary64 (/ b (- a)))
double code(double a, double b, double c) {
return b / -a;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b / -a
end function
public static double code(double a, double b, double c) {
return b / -a;
}
def code(a, b, c): return b / -a
function code(a, b, c) return Float64(b / Float64(-a)) end
function tmp = code(a, b, c) tmp = b / -a; end
code[a_, b_, c_] := N[(b / (-a)), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{-a}
\end{array}
Initial program 71.4%
frac-2neg71.4%
div-inv71.3%
Applied egg-rr71.3%
Taylor expanded in b around -inf 67.9%
Taylor expanded in b around -inf 34.7%
neg-mul-134.7%
distribute-neg-frac234.7%
Simplified34.7%
Final simplification34.7%
herbie shell --seed 2024150
(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))))