
(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 7 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.4e+81)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 1.4e-31)
(/ (- (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 <= -7.4e+81) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.4e-31) {
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 <= (-7.4d+81)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 1.4d-31) 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 <= -7.4e+81) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.4e-31) {
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 <= -7.4e+81: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 1.4e-31: 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 <= -7.4e+81) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 1.4e-31) 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 <= -7.4e+81) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 1.4e-31) 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, -7.4e+81], 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-31], 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 -7.4 \cdot 10^{+81}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.4 \cdot 10^{-31}:\\
\;\;\;\;\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 < -7.4000000000000001e81Initial program 63.9%
+-commutative63.9%
unsub-neg63.9%
Simplified63.9%
Taylor expanded in b_2 around -inf 93.2%
if -7.4000000000000001e81 < b_2 < 1.3999999999999999e-31Initial program 81.8%
+-commutative81.8%
unsub-neg81.8%
Simplified81.8%
if 1.3999999999999999e-31 < b_2 Initial program 11.1%
+-commutative11.1%
unsub-neg11.1%
Simplified11.1%
Taylor expanded in b_2 around inf 94.6%
associate-*r/94.6%
Applied egg-rr94.6%
Final simplification87.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.7e-110) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 1.8e-31) (/ (- (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 <= -1.7e-110) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.8e-31) {
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 <= (-1.7d-110)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 1.8d-31) 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 <= -1.7e-110) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.8e-31) {
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 <= -1.7e-110: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 1.8e-31: 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 <= -1.7e-110) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 1.8e-31) 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 <= -1.7e-110) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 1.8e-31) 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, -1.7e-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.8e-31], 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 -1.7 \cdot 10^{-110}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.8 \cdot 10^{-31}:\\
\;\;\;\;\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 < -1.7000000000000001e-110Initial program 76.0%
+-commutative76.0%
unsub-neg76.0%
Simplified76.0%
Taylor expanded in b_2 around -inf 82.4%
if -1.7000000000000001e-110 < b_2 < 1.80000000000000002e-31Initial program 77.4%
+-commutative77.4%
unsub-neg77.4%
Simplified77.4%
Taylor expanded in b_2 around 0 76.3%
associate-*r*76.3%
neg-mul-176.3%
*-commutative76.3%
Simplified76.3%
if 1.80000000000000002e-31 < b_2 Initial program 11.1%
+-commutative11.1%
unsub-neg11.1%
Simplified11.1%
Taylor expanded in b_2 around inf 94.6%
associate-*r/94.6%
Applied egg-rr94.6%
Final simplification83.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -3.5e-172) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 1.4e-31) (/ (sqrt (* a (- c))) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.5e-172) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.4e-31) {
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 <= (-3.5d-172)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 1.4d-31) 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 <= -3.5e-172) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.4e-31) {
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 <= -3.5e-172: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 1.4e-31: 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 <= -3.5e-172) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 1.4e-31) 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 <= -3.5e-172) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 1.4e-31) 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, -3.5e-172], 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-31], 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 -3.5 \cdot 10^{-172}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.4 \cdot 10^{-31}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.50000000000000029e-172Initial program 75.7%
+-commutative75.7%
unsub-neg75.7%
Simplified75.7%
Taylor expanded in b_2 around -inf 81.8%
if -3.50000000000000029e-172 < b_2 < 1.3999999999999999e-31Initial program 77.9%
+-commutative77.9%
unsub-neg77.9%
Simplified77.9%
prod-diff77.5%
*-commutative77.5%
fma-def77.5%
associate-+l+77.5%
distribute-rgt-neg-in77.5%
fma-def77.4%
*-commutative77.4%
fma-udef77.5%
distribute-lft-neg-in77.5%
*-commutative77.5%
distribute-rgt-neg-in77.5%
fma-def77.4%
Applied egg-rr77.4%
Taylor expanded in b_2 around 0 75.7%
associate-*l/75.8%
*-lft-identity75.8%
distribute-lft1-in76.2%
metadata-eval76.2%
neg-mul-176.2%
distribute-rgt-neg-out76.2%
Simplified76.2%
if 1.3999999999999999e-31 < b_2 Initial program 11.1%
+-commutative11.1%
unsub-neg11.1%
Simplified11.1%
Taylor expanded in b_2 around inf 94.6%
associate-*r/94.6%
Applied egg-rr94.6%
Final simplification83.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (/ (- b_2) a) (* (/ c b_2) -0.5)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = (c / b_2) * -0.5;
}
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-310)) then
tmp = -b_2 / a
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = -b_2 / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(-b_2) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e-310) tmp = -b_2 / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[((-b$95$2) / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 76.3%
+-commutative76.3%
unsub-neg76.3%
Simplified76.3%
add-cbrt-cube63.9%
pow363.9%
pow1/361.5%
sqrt-pow261.4%
fma-neg61.4%
*-commutative61.4%
distribute-rgt-neg-in61.4%
metadata-eval61.4%
Applied egg-rr61.4%
unpow1/363.9%
fma-def63.9%
+-commutative63.9%
fma-def63.9%
Simplified63.9%
Taylor expanded in c around 0 3.5%
Taylor expanded in a around inf 30.3%
neg-mul-130.3%
Simplified30.3%
if -1.999999999999994e-310 < b_2 Initial program 41.5%
+-commutative41.5%
unsub-neg41.5%
Simplified41.5%
Taylor expanded in b_2 around inf 59.1%
Final simplification44.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 9.6e-306) (/ (- b_2) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 9.6e-306) {
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 <= 9.6d-306) 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 <= 9.6e-306) {
tmp = -b_2 / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 9.6e-306: 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 <= 9.6e-306) 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 <= 9.6e-306) 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, 9.6e-306], 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 9.6 \cdot 10^{-306}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < 9.5999999999999998e-306Initial program 76.3%
+-commutative76.3%
unsub-neg76.3%
Simplified76.3%
add-cbrt-cube63.9%
pow363.9%
pow1/361.5%
sqrt-pow261.4%
fma-neg61.4%
*-commutative61.4%
distribute-rgt-neg-in61.4%
metadata-eval61.4%
Applied egg-rr61.4%
unpow1/363.9%
fma-def63.9%
+-commutative63.9%
fma-def63.9%
Simplified63.9%
Taylor expanded in c around 0 3.5%
Taylor expanded in a around inf 30.3%
neg-mul-130.3%
Simplified30.3%
if 9.5999999999999998e-306 < b_2 Initial program 41.5%
+-commutative41.5%
unsub-neg41.5%
Simplified41.5%
Taylor expanded in b_2 around inf 59.1%
associate-*r/59.1%
Applied egg-rr59.1%
Final simplification44.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (/ (* b_2 -2.0) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
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 <= -2e-310: 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 <= -2e-310) 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 <= -2e-310) 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, -2e-310], 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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 76.3%
+-commutative76.3%
unsub-neg76.3%
Simplified76.3%
Taylor expanded in b_2 around -inf 69.1%
*-commutative69.1%
Simplified69.1%
if -1.999999999999994e-310 < b_2 Initial program 41.5%
+-commutative41.5%
unsub-neg41.5%
Simplified41.5%
Taylor expanded in b_2 around inf 59.1%
associate-*r/59.1%
Applied egg-rr59.1%
Final simplification64.2%
(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 59.5%
+-commutative59.5%
unsub-neg59.5%
Simplified59.5%
add-cbrt-cube47.3%
pow347.3%
pow1/344.3%
sqrt-pow244.3%
fma-neg44.3%
*-commutative44.3%
distribute-rgt-neg-in44.3%
metadata-eval44.3%
Applied egg-rr44.3%
unpow1/347.4%
fma-def47.4%
+-commutative47.4%
fma-def47.4%
Simplified47.4%
Taylor expanded in c around 0 4.6%
Taylor expanded in a around inf 16.9%
neg-mul-116.9%
Simplified16.9%
Final simplification16.9%
herbie shell --seed 2023292
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))