
(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 8 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 -2e+145)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.8e-19)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e+145) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.8e-19) {
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (c * -0.5) / 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 <= (-2d+145)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 1.8d-19) then
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a
else
tmp = (c * (-0.5d0)) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e+145) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.8e-19) {
tmp = (Math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e+145: tmp = (b_2 * -2.0) / a elif b_2 <= 1.8e-19: tmp = (math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e+145) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.8e-19) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e+145) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.8e-19) tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e+145], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.8e-19], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{+145}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.8 \cdot 10^{-19}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -2e145Initial program 43.7%
+-commutative43.7%
unsub-neg43.7%
Simplified43.7%
Taylor expanded in b_2 around -inf 95.3%
*-commutative95.3%
Simplified95.3%
if -2e145 < b_2 < 1.8000000000000001e-19Initial program 77.7%
+-commutative77.7%
unsub-neg77.7%
Simplified77.7%
if 1.8000000000000001e-19 < b_2 Initial program 13.0%
+-commutative13.0%
unsub-neg13.0%
Simplified13.0%
*-un-lft-identity13.0%
*-un-lft-identity13.0%
prod-diff13.0%
*-commutative13.0%
*-un-lft-identity13.0%
fma-neg13.0%
*-un-lft-identity13.0%
sub-neg13.0%
add-sqr-sqrt8.7%
hypot-def24.7%
*-commutative24.7%
distribute-rgt-neg-in24.7%
*-commutative24.7%
*-un-lft-identity24.7%
Applied egg-rr24.7%
fma-udef24.7%
*-rgt-identity24.7%
associate-+r+24.7%
+-commutative24.7%
unsub-neg24.7%
Simplified24.7%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt88.6%
associate-*r*88.6%
metadata-eval88.6%
Simplified88.6%
Final simplification84.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.3e-110) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 2.05e-35) (/ (- (sqrt (* a (- c))) b_2) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.3e-110) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 2.05e-35) {
tmp = (sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c * -0.5) / 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.3d-110)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 2.05d-35) then
tmp = (sqrt((a * -c)) - b_2) / a
else
tmp = (c * (-0.5d0)) / 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.3e-110) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 2.05e-35) {
tmp = (Math.sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.3e-110: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 2.05e-35: tmp = (math.sqrt((a * -c)) - b_2) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.3e-110) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 2.05e-35) tmp = Float64(Float64(sqrt(Float64(a * Float64(-c))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.3e-110) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 2.05e-35) tmp = (sqrt((a * -c)) - b_2) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.3e-110], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.05e-35], N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.3 \cdot 10^{-110}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 2.05 \cdot 10^{-35}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -2.3000000000000001e-110Initial program 70.5%
+-commutative70.5%
unsub-neg70.5%
Simplified70.5%
Taylor expanded in b_2 around -inf 82.5%
if -2.3000000000000001e-110 < b_2 < 2.05000000000000013e-35Initial program 69.5%
+-commutative69.5%
unsub-neg69.5%
Simplified69.5%
Taylor expanded in b_2 around 0 65.0%
mul-1-neg65.0%
distribute-rgt-neg-out65.0%
Simplified65.0%
if 2.05000000000000013e-35 < b_2 Initial program 13.9%
+-commutative13.9%
unsub-neg13.9%
Simplified13.9%
*-un-lft-identity13.9%
*-un-lft-identity13.9%
prod-diff13.9%
*-commutative13.9%
*-un-lft-identity13.9%
fma-neg13.9%
*-un-lft-identity13.9%
sub-neg13.9%
add-sqr-sqrt9.7%
hypot-def25.3%
*-commutative25.3%
distribute-rgt-neg-in25.3%
*-commutative25.3%
*-un-lft-identity25.3%
Applied egg-rr25.3%
fma-udef25.3%
*-rgt-identity25.3%
associate-+r+25.3%
+-commutative25.3%
unsub-neg25.3%
Simplified25.3%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt87.8%
associate-*r*87.8%
metadata-eval87.8%
Simplified87.8%
Final simplification79.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.55e-110) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 1.4e-18) (/ (sqrt (* a (- c))) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.55e-110) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.4e-18) {
tmp = sqrt((a * -c)) / a;
} else {
tmp = (c * -0.5) / 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.55d-110)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 1.4d-18) then
tmp = sqrt((a * -c)) / a
else
tmp = (c * (-0.5d0)) / 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.55e-110) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.4e-18) {
tmp = Math.sqrt((a * -c)) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.55e-110: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 1.4e-18: tmp = math.sqrt((a * -c)) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.55e-110) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 1.4e-18) tmp = Float64(sqrt(Float64(a * Float64(-c))) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.55e-110) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 1.4e-18) tmp = sqrt((a * -c)) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.55e-110], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.4e-18], N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.55 \cdot 10^{-110}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.4 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -2.5500000000000001e-110Initial program 70.5%
+-commutative70.5%
unsub-neg70.5%
Simplified70.5%
Taylor expanded in b_2 around -inf 82.5%
if -2.5500000000000001e-110 < b_2 < 1.40000000000000006e-18Initial program 69.1%
+-commutative69.1%
unsub-neg69.1%
Simplified69.1%
prod-diff68.7%
*-commutative68.7%
fma-def68.7%
associate-+l+68.7%
distribute-rgt-neg-in68.7%
fma-def68.7%
*-commutative68.7%
fma-udef68.7%
distribute-lft-neg-in68.7%
*-commutative68.7%
distribute-rgt-neg-in68.7%
fma-def68.7%
Applied egg-rr68.7%
Taylor expanded in b_2 around 0 62.6%
associate-*l/62.7%
*-lft-identity62.7%
distribute-rgt1-in63.1%
metadata-eval63.1%
*-commutative63.1%
mul-1-neg63.1%
Simplified63.1%
if 1.40000000000000006e-18 < b_2 Initial program 13.0%
+-commutative13.0%
unsub-neg13.0%
Simplified13.0%
*-un-lft-identity13.0%
*-un-lft-identity13.0%
prod-diff13.0%
*-commutative13.0%
*-un-lft-identity13.0%
fma-neg13.0%
*-un-lft-identity13.0%
sub-neg13.0%
add-sqr-sqrt8.7%
hypot-def24.7%
*-commutative24.7%
distribute-rgt-neg-in24.7%
*-commutative24.7%
*-un-lft-identity24.7%
Applied egg-rr24.7%
fma-udef24.7%
*-rgt-identity24.7%
associate-+r+24.7%
+-commutative24.7%
unsub-neg24.7%
Simplified24.7%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt88.6%
associate-*r*88.6%
metadata-eval88.6%
Simplified88.6%
Final simplification78.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-309) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-309) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c * -0.5) / 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 <= (-1d-309)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else
tmp = (c * (-0.5d0)) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-309) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-309: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-309) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1e-309) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-309], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.000000000000002e-309Initial program 69.1%
+-commutative69.1%
unsub-neg69.1%
Simplified69.1%
Taylor expanded in b_2 around -inf 66.9%
if -1.000000000000002e-309 < b_2 Initial program 33.3%
+-commutative33.3%
unsub-neg33.3%
Simplified33.3%
*-un-lft-identity33.3%
*-un-lft-identity33.3%
prod-diff33.3%
*-commutative33.3%
*-un-lft-identity33.3%
fma-neg33.3%
*-un-lft-identity33.3%
sub-neg33.3%
add-sqr-sqrt30.5%
hypot-def40.9%
*-commutative40.9%
distribute-rgt-neg-in40.9%
*-commutative40.9%
*-un-lft-identity40.9%
Applied egg-rr40.9%
fma-udef40.9%
*-rgt-identity40.9%
associate-+r+40.9%
+-commutative40.9%
unsub-neg40.9%
Simplified40.9%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt65.3%
associate-*r*65.3%
metadata-eval65.3%
Simplified65.3%
Final simplification66.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 1.2e-294) (/ (- b_2) a) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1.2e-294) {
tmp = -b_2 / a;
} else {
tmp = -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.2d-294) then
tmp = -b_2 / a
else
tmp = (-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.2e-294) {
tmp = -b_2 / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 1.2e-294: tmp = -b_2 / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 1.2e-294) tmp = Float64(Float64(-b_2) / a); else tmp = 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.2e-294) tmp = -b_2 / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1.2e-294], N[((-b$95$2) / a), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 1.2 \cdot 10^{-294}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < 1.19999999999999999e-294Initial program 69.6%
+-commutative69.6%
unsub-neg69.6%
Simplified69.6%
Taylor expanded in b_2 around 0 38.4%
mul-1-neg38.4%
distribute-rgt-neg-out38.4%
Simplified38.4%
Taylor expanded in c around 0 26.3%
associate-*r/26.3%
neg-mul-126.3%
Simplified26.3%
if 1.19999999999999999e-294 < b_2 Initial program 32.3%
+-commutative32.3%
unsub-neg32.3%
Simplified32.3%
Taylor expanded in b_2 around inf 66.2%
Final simplification46.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 1.2e-294) (/ (- b_2) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1.2e-294) {
tmp = -b_2 / a;
} else {
tmp = (c * -0.5) / 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.2d-294) then
tmp = -b_2 / a
else
tmp = (c * (-0.5d0)) / 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.2e-294) {
tmp = -b_2 / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 1.2e-294: tmp = -b_2 / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 1.2e-294) tmp = Float64(Float64(-b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 1.2e-294) tmp = -b_2 / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1.2e-294], N[((-b$95$2) / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 1.2 \cdot 10^{-294}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < 1.19999999999999999e-294Initial program 69.6%
+-commutative69.6%
unsub-neg69.6%
Simplified69.6%
Taylor expanded in b_2 around 0 38.4%
mul-1-neg38.4%
distribute-rgt-neg-out38.4%
Simplified38.4%
Taylor expanded in c around 0 26.3%
associate-*r/26.3%
neg-mul-126.3%
Simplified26.3%
if 1.19999999999999999e-294 < b_2 Initial program 32.3%
+-commutative32.3%
unsub-neg32.3%
Simplified32.3%
*-un-lft-identity32.3%
*-un-lft-identity32.3%
prod-diff32.3%
*-commutative32.3%
*-un-lft-identity32.3%
fma-neg32.3%
*-un-lft-identity32.3%
sub-neg32.3%
add-sqr-sqrt29.4%
hypot-def40.0%
*-commutative40.0%
distribute-rgt-neg-in40.0%
*-commutative40.0%
*-un-lft-identity40.0%
Applied egg-rr40.0%
fma-udef40.0%
*-rgt-identity40.0%
associate-+r+40.0%
+-commutative40.0%
unsub-neg40.0%
Simplified40.0%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt66.2%
associate-*r*66.2%
metadata-eval66.2%
Simplified66.2%
Final simplification46.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 1.2e-294) (/ (* b_2 -2.0) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1.2e-294) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c * -0.5) / 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.2d-294) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = (c * (-0.5d0)) / 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.2e-294) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 1.2e-294: tmp = (b_2 * -2.0) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 1.2e-294) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 1.2e-294) tmp = (b_2 * -2.0) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1.2e-294], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 1.2 \cdot 10^{-294}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < 1.19999999999999999e-294Initial program 69.6%
+-commutative69.6%
unsub-neg69.6%
Simplified69.6%
Taylor expanded in b_2 around -inf 65.4%
*-commutative65.4%
Simplified65.4%
if 1.19999999999999999e-294 < b_2 Initial program 32.3%
+-commutative32.3%
unsub-neg32.3%
Simplified32.3%
*-un-lft-identity32.3%
*-un-lft-identity32.3%
prod-diff32.3%
*-commutative32.3%
*-un-lft-identity32.3%
fma-neg32.3%
*-un-lft-identity32.3%
sub-neg32.3%
add-sqr-sqrt29.4%
hypot-def40.0%
*-commutative40.0%
distribute-rgt-neg-in40.0%
*-commutative40.0%
*-un-lft-identity40.0%
Applied egg-rr40.0%
fma-udef40.0%
*-rgt-identity40.0%
associate-+r+40.0%
+-commutative40.0%
unsub-neg40.0%
Simplified40.0%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt66.2%
associate-*r*66.2%
metadata-eval66.2%
Simplified66.2%
Final simplification65.8%
(FPCore (a b_2 c) :precision binary64 (/ (- b_2) a))
double code(double a, double b_2, double c) {
return -b_2 / 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 / a
end function
public static double code(double a, double b_2, double c) {
return -b_2 / a;
}
def code(a, b_2, c): return -b_2 / a
function code(a, b_2, c) return Float64(Float64(-b_2) / a) end
function tmp = code(a, b_2, c) tmp = -b_2 / a; end
code[a_, b$95$2_, c_] := N[((-b$95$2) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b_2}{a}
\end{array}
Initial program 50.5%
+-commutative50.5%
unsub-neg50.5%
Simplified50.5%
Taylor expanded in b_2 around 0 32.4%
mul-1-neg32.4%
distribute-rgt-neg-out32.4%
Simplified32.4%
Taylor expanded in c around 0 14.3%
associate-*r/14.3%
neg-mul-114.3%
Simplified14.3%
Final simplification14.3%
herbie shell --seed 2023264
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))