
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -7.6e-68)
(/ (* c (+ 0.5 (* 0.125 (* c (/ a (pow b_2 2.0)))))) (- b_2))
(if (<= b_2 6e+110)
(/ (- (/ (pow b_2 2.0) (- b_2)) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.6e-68) {
tmp = (c * (0.5 + (0.125 * (c * (a / pow(b_2, 2.0)))))) / -b_2;
} else if (b_2 <= 6e+110) {
tmp = ((pow(b_2, 2.0) / -b_2) - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-7.6d-68)) then
tmp = (c * (0.5d0 + (0.125d0 * (c * (a / (b_2 ** 2.0d0)))))) / -b_2
else if (b_2 <= 6d+110) then
tmp = (((b_2 ** 2.0d0) / -b_2) - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.6e-68) {
tmp = (c * (0.5 + (0.125 * (c * (a / Math.pow(b_2, 2.0)))))) / -b_2;
} else if (b_2 <= 6e+110) {
tmp = ((Math.pow(b_2, 2.0) / -b_2) - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7.6e-68: tmp = (c * (0.5 + (0.125 * (c * (a / math.pow(b_2, 2.0)))))) / -b_2 elif b_2 <= 6e+110: tmp = ((math.pow(b_2, 2.0) / -b_2) - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7.6e-68) tmp = Float64(Float64(c * Float64(0.5 + Float64(0.125 * Float64(c * Float64(a / (b_2 ^ 2.0)))))) / Float64(-b_2)); elseif (b_2 <= 6e+110) tmp = Float64(Float64(Float64((b_2 ^ 2.0) / Float64(-b_2)) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -7.6e-68) tmp = (c * (0.5 + (0.125 * (c * (a / (b_2 ^ 2.0)))))) / -b_2; elseif (b_2 <= 6e+110) tmp = (((b_2 ^ 2.0) / -b_2) - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7.6e-68], N[(N[(c * N[(0.5 + N[(0.125 * N[(c * N[(a / N[Power[b$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-b$95$2)), $MachinePrecision], If[LessEqual[b$95$2, 6e+110], N[(N[(N[(N[Power[b$95$2, 2.0], $MachinePrecision] / (-b$95$2)), $MachinePrecision] - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -7.6 \cdot 10^{-68}:\\
\;\;\;\;\frac{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \frac{a}{{b\_2}^{2}}\right)\right)}{-b\_2}\\
\mathbf{elif}\;b\_2 \leq 6 \cdot 10^{+110}:\\
\;\;\;\;\frac{\frac{{b\_2}^{2}}{-b\_2} - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -7.60000000000000075e-68Initial program 15.3%
prod-diff15.0%
*-commutative15.0%
fmm-def15.0%
prod-diff15.0%
*-commutative15.0%
fmm-def15.0%
associate-+l+15.0%
sub-neg15.0%
+-commutative15.0%
distribute-rgt-neg-in15.0%
fma-define15.0%
pow215.0%
*-commutative15.0%
fma-undefine15.0%
distribute-lft-neg-in15.0%
*-commutative15.0%
distribute-rgt-neg-in15.0%
fma-define15.0%
*-commutative15.0%
Applied egg-rr15.0%
fma-define15.0%
+-commutative15.0%
*-commutative15.0%
cancel-sign-sub-inv15.0%
count-215.0%
*-commutative15.0%
Simplified15.0%
Taylor expanded in b_2 around -inf 69.3%
Taylor expanded in c around 0 68.9%
Simplified85.4%
if -7.60000000000000075e-68 < b_2 < 6.00000000000000014e110Initial program 79.9%
neg-sub079.9%
flip--79.9%
metadata-eval79.9%
pow279.9%
add-sqr-sqrt54.1%
sqrt-prod52.7%
sqr-neg52.7%
sqrt-unprod25.7%
add-sqr-sqrt49.5%
sub-neg49.5%
neg-sub049.5%
add-sqr-sqrt25.7%
sqrt-unprod52.7%
sqr-neg52.7%
sqrt-prod54.1%
add-sqr-sqrt79.9%
Applied egg-rr79.9%
sub0-neg79.9%
Simplified79.9%
if 6.00000000000000014e110 < b_2 Initial program 51.4%
Taylor expanded in c around 0 98.0%
Final simplification85.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.2e-69)
(/ (* c (+ 0.5 (* 0.125 (* c (/ a (pow b_2 2.0)))))) (- b_2))
(if (<= b_2 2.25e+108)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-69) {
tmp = (c * (0.5 + (0.125 * (c * (a / pow(b_2, 2.0)))))) / -b_2;
} else if (b_2 <= 2.25e+108) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3.2d-69)) then
tmp = (c * (0.5d0 + (0.125d0 * (c * (a / (b_2 ** 2.0d0)))))) / -b_2
else if (b_2 <= 2.25d+108) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-69) {
tmp = (c * (0.5 + (0.125 * (c * (a / Math.pow(b_2, 2.0)))))) / -b_2;
} else if (b_2 <= 2.25e+108) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.2e-69: tmp = (c * (0.5 + (0.125 * (c * (a / math.pow(b_2, 2.0)))))) / -b_2 elif b_2 <= 2.25e+108: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e-69) tmp = Float64(Float64(c * Float64(0.5 + Float64(0.125 * Float64(c * Float64(a / (b_2 ^ 2.0)))))) / Float64(-b_2)); elseif (b_2 <= 2.25e+108) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.2e-69) tmp = (c * (0.5 + (0.125 * (c * (a / (b_2 ^ 2.0)))))) / -b_2; elseif (b_2 <= 2.25e+108) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-69], N[(N[(c * N[(0.5 + N[(0.125 * N[(c * N[(a / N[Power[b$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-b$95$2)), $MachinePrecision], If[LessEqual[b$95$2, 2.25e+108], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.2 \cdot 10^{-69}:\\
\;\;\;\;\frac{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \frac{a}{{b\_2}^{2}}\right)\right)}{-b\_2}\\
\mathbf{elif}\;b\_2 \leq 2.25 \cdot 10^{+108}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -3.19999999999999999e-69Initial program 15.3%
prod-diff15.0%
*-commutative15.0%
fmm-def15.0%
prod-diff15.0%
*-commutative15.0%
fmm-def15.0%
associate-+l+15.0%
sub-neg15.0%
+-commutative15.0%
distribute-rgt-neg-in15.0%
fma-define15.0%
pow215.0%
*-commutative15.0%
fma-undefine15.0%
distribute-lft-neg-in15.0%
*-commutative15.0%
distribute-rgt-neg-in15.0%
fma-define15.0%
*-commutative15.0%
Applied egg-rr15.0%
fma-define15.0%
+-commutative15.0%
*-commutative15.0%
cancel-sign-sub-inv15.0%
count-215.0%
*-commutative15.0%
Simplified15.0%
Taylor expanded in b_2 around -inf 69.3%
Taylor expanded in c around 0 68.9%
Simplified85.4%
if -3.19999999999999999e-69 < b_2 < 2.25e108Initial program 79.9%
if 2.25e108 < b_2 Initial program 51.4%
Taylor expanded in c around 0 98.0%
Final simplification85.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.35e+154)
(* c (+ (* 0.125 (/ (* c a) (pow b_2 3.0))) (* 0.5 (/ 1.0 b_2))))
(if (<= b_2 1.3e+112)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.35e+154) {
tmp = c * ((0.125 * ((c * a) / pow(b_2, 3.0))) + (0.5 * (1.0 / b_2)));
} else if (b_2 <= 1.3e+112) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1.35d+154)) then
tmp = c * ((0.125d0 * ((c * a) / (b_2 ** 3.0d0))) + (0.5d0 * (1.0d0 / b_2)))
else if (b_2 <= 1.3d+112) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.35e+154) {
tmp = c * ((0.125 * ((c * a) / Math.pow(b_2, 3.0))) + (0.5 * (1.0 / b_2)));
} else if (b_2 <= 1.3e+112) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.35e+154: tmp = c * ((0.125 * ((c * a) / math.pow(b_2, 3.0))) + (0.5 * (1.0 / b_2))) elif b_2 <= 1.3e+112: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.35e+154) tmp = Float64(c * Float64(Float64(0.125 * Float64(Float64(c * a) / (b_2 ^ 3.0))) + Float64(0.5 * Float64(1.0 / b_2)))); elseif (b_2 <= 1.3e+112) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.35e+154) tmp = c * ((0.125 * ((c * a) / (b_2 ^ 3.0))) + (0.5 * (1.0 / b_2))); elseif (b_2 <= 1.3e+112) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.35e+154], N[(c * N[(N[(0.125 * N[(N[(c * a), $MachinePrecision] / N[Power[b$95$2, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.3e+112], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;c \cdot \left(0.125 \cdot \frac{c \cdot a}{{b\_2}^{3}} + 0.5 \cdot \frac{1}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 1.3 \cdot 10^{+112}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -1.35000000000000003e154Initial program 1.7%
add-sqr-sqrt1.7%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-prod0.0%
add-sqr-sqrt1.7%
add-cube-cbrt1.7%
pow31.7%
Applied egg-rr1.7%
Taylor expanded in c around 0 44.1%
if -1.35000000000000003e154 < b_2 < 1.3e112Initial program 60.1%
if 1.3e112 < b_2 Initial program 51.4%
Taylor expanded in c around 0 98.0%
Final simplification64.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.35e+154)
(* c (- (/ (* b_2 2.0) (* c a)) (/ 0.5 b_2)))
(if (<= b_2 2e+109)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.35e+154) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else if (b_2 <= 2e+109) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1.35d+154)) then
tmp = c * (((b_2 * 2.0d0) / (c * a)) - (0.5d0 / b_2))
else if (b_2 <= 2d+109) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.35e+154) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else if (b_2 <= 2e+109) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.35e+154: tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)) elif b_2 <= 2e+109: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.35e+154) tmp = Float64(c * Float64(Float64(Float64(b_2 * 2.0) / Float64(c * a)) - Float64(0.5 / b_2))); elseif (b_2 <= 2e+109) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.35e+154) tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)); elseif (b_2 <= 2e+109) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.35e+154], N[(c * N[(N[(N[(b$95$2 * 2.0), $MachinePrecision] / N[(c * a), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2e+109], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 2 \cdot 10^{+109}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -1.35000000000000003e154Initial program 1.7%
add-sqr-sqrt1.7%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-prod0.0%
add-sqr-sqrt1.7%
add-cube-cbrt1.7%
pow31.7%
Applied egg-rr1.7%
Taylor expanded in b_2 around -inf 1.8%
associate-*r*1.8%
neg-mul-11.8%
rem-cube-cbrt1.8%
associate--l+1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in c around inf 16.0%
associate-*r/16.0%
associate-*r/16.0%
metadata-eval16.0%
Simplified16.0%
if -1.35000000000000003e154 < b_2 < 1.99999999999999996e109Initial program 60.1%
if 1.99999999999999996e109 < b_2 Initial program 51.4%
Taylor expanded in c around 0 98.0%
Final simplification59.8%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -2.6e+131)
(* c (- (/ (* b_2 2.0) (* c a)) (/ 0.5 b_2)))
(if (<= b_2 1.35e-81)
(/ (- b_2 (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.6e+131) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else if (b_2 <= 1.35e-81) {
tmp = (b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-2.6d+131)) then
tmp = c * (((b_2 * 2.0d0) / (c * a)) - (0.5d0 / b_2))
else if (b_2 <= 1.35d-81) then
tmp = (b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.6e+131) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else if (b_2 <= 1.35e-81) {
tmp = (b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.6e+131: tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)) elif b_2 <= 1.35e-81: tmp = (b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.6e+131) tmp = Float64(c * Float64(Float64(Float64(b_2 * 2.0) / Float64(c * a)) - Float64(0.5 / b_2))); elseif (b_2 <= 1.35e-81) tmp = Float64(Float64(b_2 - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.6e+131) tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)); elseif (b_2 <= 1.35e-81) tmp = (b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.6e+131], N[(c * N[(N[(N[(b$95$2 * 2.0), $MachinePrecision] / N[(c * a), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.35e-81], N[(N[(b$95$2 - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -2.6 \cdot 10^{+131}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 1.35 \cdot 10^{-81}:\\
\;\;\;\;\frac{b\_2 - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -2.6e131Initial program 6.3%
add-sqr-sqrt4.0%
sqrt-unprod4.8%
sqr-neg4.8%
sqrt-prod0.0%
add-sqr-sqrt1.9%
add-cube-cbrt1.9%
pow31.9%
Applied egg-rr1.9%
Taylor expanded in b_2 around -inf 1.9%
associate-*r*1.9%
neg-mul-11.9%
rem-cube-cbrt1.9%
associate--l+1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in c around inf 13.9%
associate-*r/13.9%
associate-*r/13.9%
metadata-eval13.9%
Simplified13.9%
if -2.6e131 < b_2 < 1.34999999999999995e-81Initial program 50.8%
neg-sub050.8%
sub-neg50.8%
add-sqr-sqrt32.1%
sqrt-unprod49.2%
sqr-neg49.2%
sqrt-prod15.9%
add-sqr-sqrt46.7%
Applied egg-rr46.7%
+-lft-identity46.7%
Simplified46.7%
if 1.34999999999999995e-81 < b_2 Initial program 71.1%
Taylor expanded in c around 0 89.3%
Final simplification54.6%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -9.5e+131)
(* c (- (/ (* b_2 2.0) (* c a)) (/ 0.5 b_2)))
(if (<= b_2 2.5e-80)
(- (/ b_2 (- a)) (/ (sqrt (* c (- a))) a))
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9.5e+131) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else if (b_2 <= 2.5e-80) {
tmp = (b_2 / -a) - (sqrt((c * -a)) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-9.5d+131)) then
tmp = c * (((b_2 * 2.0d0) / (c * a)) - (0.5d0 / b_2))
else if (b_2 <= 2.5d-80) then
tmp = (b_2 / -a) - (sqrt((c * -a)) / a)
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9.5e+131) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else if (b_2 <= 2.5e-80) {
tmp = (b_2 / -a) - (Math.sqrt((c * -a)) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -9.5e+131: tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)) elif b_2 <= 2.5e-80: tmp = (b_2 / -a) - (math.sqrt((c * -a)) / a) else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9.5e+131) tmp = Float64(c * Float64(Float64(Float64(b_2 * 2.0) / Float64(c * a)) - Float64(0.5 / b_2))); elseif (b_2 <= 2.5e-80) tmp = Float64(Float64(b_2 / Float64(-a)) - Float64(sqrt(Float64(c * Float64(-a))) / a)); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -9.5e+131) tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)); elseif (b_2 <= 2.5e-80) tmp = (b_2 / -a) - (sqrt((c * -a)) / a); else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -9.5e+131], N[(c * N[(N[(N[(b$95$2 * 2.0), $MachinePrecision] / N[(c * a), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.5e-80], N[(N[(b$95$2 / (-a)), $MachinePrecision] - N[(N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -9.5 \cdot 10^{+131}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\
\mathbf{elif}\;b\_2 \leq 2.5 \cdot 10^{-80}:\\
\;\;\;\;\frac{b\_2}{-a} - \frac{\sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -9.50000000000000015e131Initial program 6.3%
add-sqr-sqrt4.0%
sqrt-unprod4.8%
sqr-neg4.8%
sqrt-prod0.0%
add-sqr-sqrt1.9%
add-cube-cbrt1.9%
pow31.9%
Applied egg-rr1.9%
Taylor expanded in b_2 around -inf 1.9%
associate-*r*1.9%
neg-mul-11.9%
rem-cube-cbrt1.9%
associate--l+1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in c around inf 13.9%
associate-*r/13.9%
associate-*r/13.9%
metadata-eval13.9%
Simplified13.9%
if -9.50000000000000015e131 < b_2 < 2.5e-80Initial program 50.8%
prod-diff50.4%
*-commutative50.4%
fmm-def50.4%
prod-diff50.4%
*-commutative50.4%
fmm-def50.4%
associate-+l+50.3%
sub-neg50.3%
+-commutative50.3%
distribute-rgt-neg-in50.3%
fma-define50.3%
pow250.3%
*-commutative50.3%
fma-undefine50.4%
distribute-lft-neg-in50.4%
*-commutative50.4%
distribute-rgt-neg-in50.4%
fma-define50.3%
*-commutative50.3%
Applied egg-rr50.3%
fma-define50.3%
+-commutative50.3%
*-commutative50.3%
cancel-sign-sub-inv50.3%
count-250.3%
*-commutative50.3%
Simplified50.3%
Taylor expanded in c around inf 21.3%
Taylor expanded in c around 0 45.8%
+-commutative45.8%
mul-1-neg45.8%
unsub-neg45.8%
associate-*r/45.8%
mul-1-neg45.8%
associate-*l/45.9%
*-lft-identity45.9%
distribute-rgt1-in45.9%
metadata-eval45.9%
mul0-lft45.9%
metadata-eval45.9%
neg-sub045.9%
Simplified45.9%
if 2.5e-80 < b_2 Initial program 71.1%
Taylor expanded in c around 0 89.3%
Final simplification54.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (* c (- (/ (* b_2 2.0) (* c a)) (/ 0.5 b_2))) (+ (* -2.0 (/ b_2 a)) (* 0.5 (* c (/ 1.0 b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c * (1.0 / b_2)));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = c * (((b_2 * 2.0d0) / (c * a)) - (0.5d0 / b_2))
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c * (1.0d0 / b_2)))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c * (1.0 / b_2)));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)) else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c * (1.0 / b_2))) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(c * Float64(Float64(Float64(b_2 * 2.0) / Float64(c * a)) - Float64(0.5 / b_2))); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c * Float64(1.0 / b_2)))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)); else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c * (1.0 / b_2))); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], N[(c * N[(N[(N[(b$95$2 * 2.0), $MachinePrecision] / N[(c * a), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c * N[(1.0 / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \left(c \cdot \frac{1}{b\_2}\right)\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 29.5%
add-sqr-sqrt27.8%
sqrt-unprod29.0%
sqr-neg29.0%
sqrt-prod0.0%
add-sqr-sqrt25.9%
add-cube-cbrt25.9%
pow325.9%
Applied egg-rr25.9%
Taylor expanded in b_2 around -inf 3.1%
associate-*r*3.1%
neg-mul-13.1%
rem-cube-cbrt3.1%
associate--l+3.1%
metadata-eval3.1%
Simplified3.1%
Taylor expanded in c around inf 7.3%
associate-*r/7.3%
associate-*r/7.3%
metadata-eval7.3%
Simplified7.3%
if -4.999999999999985e-310 < b_2 Initial program 74.7%
Taylor expanded in c around 0 72.6%
div-inv72.6%
Applied egg-rr72.6%
Final simplification35.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (* c (- (/ (* b_2 2.0) (* c a)) (/ 0.5 b_2))) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = c * (((b_2 * 2.0d0) / (c * a)) - (0.5d0 / b_2))
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2));
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)) else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(c * Float64(Float64(Float64(b_2 * 2.0) / Float64(c * a)) - Float64(0.5 / b_2))); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = c * (((b_2 * 2.0) / (c * a)) - (0.5 / b_2)); else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], N[(c * N[(N[(N[(b$95$2 * 2.0), $MachinePrecision] / N[(c * a), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 29.5%
add-sqr-sqrt27.8%
sqrt-unprod29.0%
sqr-neg29.0%
sqrt-prod0.0%
add-sqr-sqrt25.9%
add-cube-cbrt25.9%
pow325.9%
Applied egg-rr25.9%
Taylor expanded in b_2 around -inf 3.1%
associate-*r*3.1%
neg-mul-13.1%
rem-cube-cbrt3.1%
associate--l+3.1%
metadata-eval3.1%
Simplified3.1%
Taylor expanded in c around inf 7.3%
associate-*r/7.3%
associate-*r/7.3%
metadata-eval7.3%
Simplified7.3%
if -4.999999999999985e-310 < b_2 Initial program 74.7%
Taylor expanded in c around 0 72.6%
Final simplification35.4%
(FPCore (a b_2 c) :precision binary64 (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
return (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end function
public static double code(double a, double b_2, double c) {
return (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
def code(a, b_2, c): return (-2.0 * (b_2 / a)) + (0.5 * (c / b_2))
function code(a, b_2, c) return Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))) end
function tmp = code(a, b_2, c) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end
code[a_, b$95$2_, c_] := N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}
\end{array}
Initial program 48.9%
Taylor expanded in c around 0 32.4%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_1
(if (== (copysign a c) a)
(* (sqrt (- (fabs b_2) t_0)) (sqrt (+ (fabs b_2) t_0)))
(hypot b_2 t_0))))
(if (< b_2 0.0) (/ c (- t_1 b_2)) (/ (+ b_2 t_1) (- a)))))
double code(double a, double b_2, double c) {
double t_0 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp;
if (copysign(a, c) == a) {
tmp = sqrt((fabs(b_2) - t_0)) * sqrt((fabs(b_2) + t_0));
} else {
tmp = hypot(b_2, t_0);
}
double t_1 = tmp;
double tmp_1;
if (b_2 < 0.0) {
tmp_1 = c / (t_1 - b_2);
} else {
tmp_1 = (b_2 + t_1) / -a;
}
return tmp_1;
}
public static double code(double a, double b_2, double c) {
double t_0 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp;
if (Math.copySign(a, c) == a) {
tmp = Math.sqrt((Math.abs(b_2) - t_0)) * Math.sqrt((Math.abs(b_2) + t_0));
} else {
tmp = Math.hypot(b_2, t_0);
}
double t_1 = tmp;
double tmp_1;
if (b_2 < 0.0) {
tmp_1 = c / (t_1 - b_2);
} else {
tmp_1 = (b_2 + t_1) / -a;
}
return tmp_1;
}
def code(a, b_2, c): t_0 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp = 0 if math.copysign(a, c) == a: tmp = math.sqrt((math.fabs(b_2) - t_0)) * math.sqrt((math.fabs(b_2) + t_0)) else: tmp = math.hypot(b_2, t_0) t_1 = tmp tmp_1 = 0 if b_2 < 0.0: tmp_1 = c / (t_1 - b_2) else: tmp_1 = (b_2 + t_1) / -a return tmp_1
function code(a, b_2, c) t_0 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp = 0.0 if (copysign(a, c) == a) tmp = Float64(sqrt(Float64(abs(b_2) - t_0)) * sqrt(Float64(abs(b_2) + t_0))); else tmp = hypot(b_2, t_0); end t_1 = tmp tmp_1 = 0.0 if (b_2 < 0.0) tmp_1 = Float64(c / Float64(t_1 - b_2)); else tmp_1 = Float64(Float64(b_2 + t_1) / Float64(-a)); end return tmp_1 end
function tmp_3 = code(a, b_2, c) t_0 = sqrt(abs(a)) * sqrt(abs(c)); tmp = 0.0; if ((sign(c) * abs(a)) == a) tmp = sqrt((abs(b_2) - t_0)) * sqrt((abs(b_2) + t_0)); else tmp = hypot(b_2, t_0); end t_1 = tmp; tmp_2 = 0.0; if (b_2 < 0.0) tmp_2 = c / (t_1 - b_2); else tmp_2 = (b_2 + t_1) / -a; end tmp_3 = tmp_2; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[b$95$2 ^ 2 + t$95$0 ^ 2], $MachinePrecision]]}, If[Less[b$95$2, 0.0], N[(c / N[(t$95$1 - b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(b$95$2 + t$95$1), $MachinePrecision] / (-a)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_1 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{\left|b\_2\right| - t\_0} \cdot \sqrt{\left|b\_2\right| + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(b\_2, t\_0\right)\\
\end{array}\\
\mathbf{if}\;b\_2 < 0:\\
\;\;\;\;\frac{c}{t\_1 - b\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b\_2 + t\_1}{-a}\\
\end{array}
\end{array}
herbie shell --seed 2024179
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
:herbie-expected 10
:alt
(! :herbie-platform default (let ((sqtD (let ((x (* (sqrt (fabs a)) (sqrt (fabs c))))) (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) x)) (sqrt (+ (fabs b_2) x))) (hypot b_2 x))))) (if (< b_2 0) (/ c (- sqtD b_2)) (/ (+ b_2 sqtD) (- a)))))
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))