
(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 -5e+92)
(/ (- (* (fabs b_2) (sqrt (- 1.0 (* a (/ c (pow b_2 2.0)))))) b_2) a)
(if (<= b_2 3e-88)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(* -0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e+92) {
tmp = ((fabs(b_2) * sqrt((1.0 - (a * (c / pow(b_2, 2.0)))))) - b_2) / a;
} else if (b_2 <= 3e-88) {
tmp = (sqrt(((b_2 * b_2) - (a * c))) - 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 <= (-5d+92)) then
tmp = ((abs(b_2) * sqrt((1.0d0 - (a * (c / (b_2 ** 2.0d0)))))) - b_2) / a
else if (b_2 <= 3d-88) then
tmp = (sqrt(((b_2 * b_2) - (a * c))) - 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 <= -5e+92) {
tmp = ((Math.abs(b_2) * Math.sqrt((1.0 - (a * (c / Math.pow(b_2, 2.0)))))) - b_2) / a;
} else if (b_2 <= 3e-88) {
tmp = (Math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e+92: tmp = ((math.fabs(b_2) * math.sqrt((1.0 - (a * (c / math.pow(b_2, 2.0)))))) - b_2) / a elif b_2 <= 3e-88: tmp = (math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e+92) tmp = Float64(Float64(Float64(abs(b_2) * sqrt(Float64(1.0 - Float64(a * Float64(c / (b_2 ^ 2.0)))))) - b_2) / a); elseif (b_2 <= 3e-88) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - 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 <= -5e+92) tmp = ((abs(b_2) * sqrt((1.0 - (a * (c / (b_2 ^ 2.0)))))) - b_2) / a; elseif (b_2 <= 3e-88) tmp = (sqrt(((b_2 * b_2) - (a * c))) - 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, -5e+92], N[(N[(N[(N[Abs[b$95$2], $MachinePrecision] * N[Sqrt[N[(1.0 - N[(a * N[(c / N[Power[b$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 3e-88], 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[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5 \cdot 10^{+92}:\\
\;\;\;\;\frac{\left|b\_2\right| \cdot \sqrt{1 - a \cdot \frac{c}{{b\_2}^{2}}} - b\_2}{a}\\
\mathbf{elif}\;b\_2 \leq 3 \cdot 10^{-88}:\\
\;\;\;\;\frac{\sqrt{b\_2 \cdot b\_2 - a \cdot c} - b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -5.00000000000000022e92Initial program 49.7%
+-commutative49.7%
unsub-neg49.7%
Simplified49.7%
Taylor expanded in b_2 around inf 49.6%
associate-*r/49.6%
associate-*r*49.6%
neg-mul-149.6%
*-commutative49.6%
Simplified49.6%
sqrt-prod49.6%
fmm-def49.6%
+-commutative49.6%
associate-/l*54.1%
fma-define54.1%
Applied egg-rr54.1%
fmm-undef54.1%
unpow254.1%
rem-sqrt-square99.3%
fma-undefine99.3%
associate-*r/85.2%
*-commutative85.2%
neg-mul-185.2%
associate-*r*85.2%
associate-*r/85.2%
+-commutative85.2%
mul-1-neg85.2%
unsub-neg85.2%
associate-/l*99.3%
Simplified99.3%
if -5.00000000000000022e92 < b_2 < 2.9999999999999999e-88Initial program 82.9%
+-commutative82.9%
unsub-neg82.9%
Simplified82.9%
if 2.9999999999999999e-88 < b_2 Initial program 16.0%
+-commutative16.0%
unsub-neg16.0%
Simplified16.0%
Taylor expanded in b_2 around inf 84.6%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.1e+154)
(/ (+ (* b_2 -2.0) (* c (/ 0.5 (/ b_2 a)))) a)
(if (<= b_2 2.45e-88)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(* -0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.1e+154) {
tmp = ((b_2 * -2.0) + (c * (0.5 / (b_2 / a)))) / a;
} else if (b_2 <= 2.45e-88) {
tmp = (sqrt(((b_2 * b_2) - (a * c))) - 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.1d+154)) then
tmp = ((b_2 * (-2.0d0)) + (c * (0.5d0 / (b_2 / a)))) / a
else if (b_2 <= 2.45d-88) then
tmp = (sqrt(((b_2 * b_2) - (a * c))) - 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.1e+154) {
tmp = ((b_2 * -2.0) + (c * (0.5 / (b_2 / a)))) / a;
} else if (b_2 <= 2.45e-88) {
tmp = (Math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.1e+154: tmp = ((b_2 * -2.0) + (c * (0.5 / (b_2 / a)))) / a elif b_2 <= 2.45e-88: tmp = (math.sqrt(((b_2 * b_2) - (a * c))) - 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.1e+154) tmp = Float64(Float64(Float64(b_2 * -2.0) + Float64(c * Float64(0.5 / Float64(b_2 / a)))) / a); elseif (b_2 <= 2.45e-88) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - 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.1e+154) tmp = ((b_2 * -2.0) + (c * (0.5 / (b_2 / a)))) / a; elseif (b_2 <= 2.45e-88) tmp = (sqrt(((b_2 * b_2) - (a * c))) - 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.1e+154], N[(N[(N[(b$95$2 * -2.0), $MachinePrecision] + N[(c * N[(0.5 / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 2.45e-88], 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[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.1 \cdot 10^{+154}:\\
\;\;\;\;\frac{b\_2 \cdot -2 + c \cdot \frac{0.5}{\frac{b\_2}{a}}}{a}\\
\mathbf{elif}\;b\_2 \leq 2.45 \cdot 10^{-88}:\\
\;\;\;\;\frac{\sqrt{b\_2 \cdot b\_2 - a \cdot c} - b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -1.1000000000000001e154Initial program 38.0%
+-commutative38.0%
unsub-neg38.0%
Simplified38.0%
Taylor expanded in b_2 around -inf 98.8%
Taylor expanded in a around 0 85.9%
clear-num85.9%
un-div-inv85.9%
associate-/r*100.0%
Applied egg-rr100.0%
associate-/r/100.0%
Simplified100.0%
if -1.1000000000000001e154 < b_2 < 2.45000000000000014e-88Initial program 83.0%
+-commutative83.0%
unsub-neg83.0%
Simplified83.0%
if 2.45000000000000014e-88 < b_2 Initial program 16.0%
+-commutative16.0%
unsub-neg16.0%
Simplified16.0%
Taylor expanded in b_2 around inf 84.6%
Final simplification85.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -6.5e-71) (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)) (if (<= b_2 3.3e-88) (/ (- (sqrt (* a (- c))) b_2) a) (* -0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.5e-71) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 3.3e-88) {
tmp = (sqrt((a * -c)) - 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 <= (-6.5d-71)) then
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
else if (b_2 <= 3.3d-88) then
tmp = (sqrt((a * -c)) - 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 <= -6.5e-71) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 3.3e-88) {
tmp = (Math.sqrt((a * -c)) - b_2) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.5e-71: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) elif b_2 <= 3.3e-88: tmp = (math.sqrt((a * -c)) - b_2) / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.5e-71) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); elseif (b_2 <= 3.3e-88) tmp = Float64(Float64(sqrt(Float64(a * Float64(-c))) - 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 <= -6.5e-71) tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); elseif (b_2 <= 3.3e-88) tmp = (sqrt((a * -c)) - 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, -6.5e-71], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 3.3e-88], N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -6.5 \cdot 10^{-71}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + \frac{c}{b\_2} \cdot 0.5\\
\mathbf{elif}\;b\_2 \leq 3.3 \cdot 10^{-88}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -6.50000000000000005e-71Initial program 69.8%
+-commutative69.8%
unsub-neg69.8%
Simplified69.8%
Taylor expanded in b_2 around -inf 81.0%
Taylor expanded in c around 0 81.6%
if -6.50000000000000005e-71 < b_2 < 3.29999999999999994e-88Initial program 77.3%
+-commutative77.3%
unsub-neg77.3%
Simplified77.3%
Taylor expanded in b_2 around 0 75.1%
associate-*r*75.1%
neg-mul-175.1%
*-commutative75.1%
Simplified75.1%
if 3.29999999999999994e-88 < b_2 Initial program 16.0%
+-commutative16.0%
unsub-neg16.0%
Simplified16.0%
Taylor expanded in b_2 around inf 84.6%
Final simplification80.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -6e-71) (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)) (if (<= b_2 3.2e-88) (/ (sqrt (* a (- c))) a) (* -0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6e-71) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 3.2e-88) {
tmp = sqrt((a * -c)) / 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 <= (-6d-71)) then
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
else if (b_2 <= 3.2d-88) then
tmp = sqrt((a * -c)) / 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 <= -6e-71) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 3.2e-88) {
tmp = Math.sqrt((a * -c)) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6e-71: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) elif b_2 <= 3.2e-88: tmp = math.sqrt((a * -c)) / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6e-71) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); elseif (b_2 <= 3.2e-88) tmp = Float64(sqrt(Float64(a * Float64(-c))) / 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 <= -6e-71) tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); elseif (b_2 <= 3.2e-88) tmp = sqrt((a * -c)) / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6e-71], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 3.2e-88], N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -6 \cdot 10^{-71}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + \frac{c}{b\_2} \cdot 0.5\\
\mathbf{elif}\;b\_2 \leq 3.2 \cdot 10^{-88}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -6.0000000000000003e-71Initial program 69.8%
+-commutative69.8%
unsub-neg69.8%
Simplified69.8%
Taylor expanded in b_2 around -inf 81.0%
Taylor expanded in c around 0 81.6%
if -6.0000000000000003e-71 < b_2 < 3.20000000000000012e-88Initial program 77.3%
+-commutative77.3%
unsub-neg77.3%
Simplified77.3%
prod-diff76.7%
*-commutative76.7%
fmm-def76.7%
prod-diff76.7%
*-commutative76.7%
fmm-def76.7%
associate-+l+76.6%
pow276.6%
*-commutative76.6%
fma-undefine76.7%
distribute-lft-neg-in76.7%
*-commutative76.7%
distribute-rgt-neg-in76.7%
fma-define76.6%
*-commutative76.6%
fma-undefine76.7%
distribute-lft-neg-in76.7%
*-commutative76.7%
distribute-rgt-neg-in76.7%
Applied egg-rr76.6%
*-commutative76.6%
count-276.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in b_2 around 0 73.8%
associate-*l/73.8%
*-lft-identity73.8%
distribute-lft1-in73.8%
metadata-eval73.8%
mul0-lft74.5%
metadata-eval74.5%
neg-sub074.5%
distribute-rgt-neg-out74.5%
Simplified74.5%
if 3.20000000000000012e-88 < b_2 Initial program 16.0%
+-commutative16.0%
unsub-neg16.0%
Simplified16.0%
Taylor expanded in b_2 around inf 84.6%
Final simplification80.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5.5e-116) (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)) (if (<= b_2 2.45e-88) (sqrt (* c (/ -1.0 a))) (* -0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5.5e-116) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 2.45e-88) {
tmp = sqrt((c * (-1.0 / 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 <= (-5.5d-116)) then
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
else if (b_2 <= 2.45d-88) then
tmp = sqrt((c * ((-1.0d0) / 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 <= -5.5e-116) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 2.45e-88) {
tmp = Math.sqrt((c * (-1.0 / a)));
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5.5e-116: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) elif b_2 <= 2.45e-88: tmp = math.sqrt((c * (-1.0 / a))) else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5.5e-116) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); elseif (b_2 <= 2.45e-88) tmp = sqrt(Float64(c * Float64(-1.0 / 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 <= -5.5e-116) tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); elseif (b_2 <= 2.45e-88) tmp = sqrt((c * (-1.0 / a))); else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5.5e-116], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.45e-88], N[Sqrt[N[(c * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5.5 \cdot 10^{-116}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + \frac{c}{b\_2} \cdot 0.5\\
\mathbf{elif}\;b\_2 \leq 2.45 \cdot 10^{-88}:\\
\;\;\;\;\sqrt{c \cdot \frac{-1}{a}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -5.4999999999999998e-116Initial program 72.6%
+-commutative72.6%
unsub-neg72.6%
Simplified72.6%
Taylor expanded in b_2 around -inf 75.9%
Taylor expanded in c around 0 76.5%
if -5.4999999999999998e-116 < b_2 < 2.45000000000000014e-88Initial program 74.2%
+-commutative74.2%
unsub-neg74.2%
Simplified74.2%
prod-diff73.4%
*-commutative73.4%
fmm-def73.4%
prod-diff73.4%
*-commutative73.4%
fmm-def73.4%
associate-+l+73.4%
pow273.4%
*-commutative73.4%
fma-undefine73.4%
distribute-lft-neg-in73.4%
*-commutative73.4%
distribute-rgt-neg-in73.4%
fma-define73.4%
*-commutative73.4%
fma-undefine73.4%
distribute-lft-neg-in73.4%
*-commutative73.4%
distribute-rgt-neg-in73.4%
Applied egg-rr73.4%
*-commutative73.4%
count-273.4%
*-commutative73.4%
Simplified73.4%
Taylor expanded in a around inf 38.9%
distribute-rgt1-in38.9%
metadata-eval38.9%
mul0-lft38.9%
metadata-eval38.9%
neg-sub038.9%
Simplified38.9%
frac-2neg38.9%
div-inv39.0%
add-sqr-sqrt37.8%
sqrt-unprod26.5%
sqr-neg26.5%
sqrt-unprod0.7%
add-sqr-sqrt0.9%
add-sqr-sqrt0.2%
sqrt-unprod1.3%
sqr-neg1.3%
sqrt-unprod1.1%
add-sqr-sqrt39.0%
Applied egg-rr39.0%
if 2.45000000000000014e-88 < b_2 Initial program 16.0%
+-commutative16.0%
unsub-neg16.0%
Simplified16.0%
Taylor expanded in b_2 around inf 84.6%
Final simplification70.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4.7e-116) (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)) (if (<= b_2 2.35e-88) (sqrt (/ c (- a))) (* -0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.7e-116) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 2.35e-88) {
tmp = sqrt((c / -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 <= (-4.7d-116)) then
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
else if (b_2 <= 2.35d-88) then
tmp = sqrt((c / -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 <= -4.7e-116) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else if (b_2 <= 2.35e-88) {
tmp = Math.sqrt((c / -a));
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.7e-116: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) elif b_2 <= 2.35e-88: tmp = math.sqrt((c / -a)) else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.7e-116) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); elseif (b_2 <= 2.35e-88) tmp = sqrt(Float64(c / Float64(-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 <= -4.7e-116) tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); elseif (b_2 <= 2.35e-88) tmp = sqrt((c / -a)); else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.7e-116], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.35e-88], N[Sqrt[N[(c / (-a)), $MachinePrecision]], $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -4.7 \cdot 10^{-116}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + \frac{c}{b\_2} \cdot 0.5\\
\mathbf{elif}\;b\_2 \leq 2.35 \cdot 10^{-88}:\\
\;\;\;\;\sqrt{\frac{c}{-a}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -4.69999999999999994e-116Initial program 72.6%
+-commutative72.6%
unsub-neg72.6%
Simplified72.6%
Taylor expanded in b_2 around -inf 75.9%
Taylor expanded in c around 0 76.5%
if -4.69999999999999994e-116 < b_2 < 2.35e-88Initial program 74.2%
+-commutative74.2%
unsub-neg74.2%
Simplified74.2%
prod-diff73.4%
*-commutative73.4%
fmm-def73.4%
prod-diff73.4%
*-commutative73.4%
fmm-def73.4%
associate-+l+73.4%
pow273.4%
*-commutative73.4%
fma-undefine73.4%
distribute-lft-neg-in73.4%
*-commutative73.4%
distribute-rgt-neg-in73.4%
fma-define73.4%
*-commutative73.4%
fma-undefine73.4%
distribute-lft-neg-in73.4%
*-commutative73.4%
distribute-rgt-neg-in73.4%
Applied egg-rr73.4%
*-commutative73.4%
count-273.4%
*-commutative73.4%
Simplified73.4%
Taylor expanded in a around inf 38.9%
distribute-rgt1-in38.9%
metadata-eval38.9%
mul0-lft38.9%
metadata-eval38.9%
neg-sub038.9%
Simplified38.9%
if 2.35e-88 < b_2 Initial program 16.0%
+-commutative16.0%
unsub-neg16.0%
Simplified16.0%
Taylor expanded in b_2 around inf 84.6%
Final simplification70.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-310) (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-310) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} 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 <= (-1d-310)) then
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
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 <= -1e-310) {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-310: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-310) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); 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 <= -1e-310) tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-310], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + \frac{c}{b\_2} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < -9.999999999999969e-311Initial program 74.9%
+-commutative74.9%
unsub-neg74.9%
Simplified74.9%
Taylor expanded in b_2 around -inf 58.0%
Taylor expanded in c around 0 59.1%
if -9.999999999999969e-311 < b_2 Initial program 28.7%
+-commutative28.7%
unsub-neg28.7%
Simplified28.7%
Taylor expanded in b_2 around inf 65.1%
Final simplification62.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 3.8e-304) (/ (* b_2 -2.0) a) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 3.8e-304) {
tmp = (b_2 * -2.0) / 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 <= 3.8d-304) then
tmp = (b_2 * (-2.0d0)) / 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 <= 3.8e-304) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 3.8e-304: tmp = (b_2 * -2.0) / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 3.8e-304) tmp = Float64(Float64(b_2 * -2.0) / 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 <= 3.8e-304) tmp = (b_2 * -2.0) / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 3.8e-304], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq 3.8 \cdot 10^{-304}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b\_2}\\
\end{array}
\end{array}
if b_2 < 3.79999999999999961e-304Initial program 75.3%
+-commutative75.3%
unsub-neg75.3%
Simplified75.3%
Taylor expanded in b_2 around -inf 57.6%
*-commutative57.6%
Simplified57.6%
if 3.79999999999999961e-304 < b_2 Initial program 27.6%
+-commutative27.6%
unsub-neg27.6%
Simplified27.6%
Taylor expanded in b_2 around inf 66.1%
(FPCore (a b_2 c) :precision binary64 (* -0.5 (/ c b_2)))
double code(double a, double b_2, double c) {
return -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 = (-0.5d0) * (c / b_2)
end function
public static double code(double a, double b_2, double c) {
return -0.5 * (c / b_2);
}
def code(a, b_2, c): return -0.5 * (c / b_2)
function code(a, b_2, c) return Float64(-0.5 * Float64(c / b_2)) end
function tmp = code(a, b_2, c) tmp = -0.5 * (c / b_2); end
code[a_, b$95$2_, c_] := N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b\_2}
\end{array}
Initial program 52.0%
+-commutative52.0%
unsub-neg52.0%
Simplified52.0%
Taylor expanded in b_2 around inf 33.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) (/ (- t_1 b_2) a) (/ (- c) (+ b_2 t_1)))))
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 = (t_1 - b_2) / a;
} else {
tmp_1 = -c / (b_2 + t_1);
}
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 = (t_1 - b_2) / a;
} else {
tmp_1 = -c / (b_2 + t_1);
}
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 = (t_1 - b_2) / a else: tmp_1 = -c / (b_2 + t_1) 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(Float64(t_1 - b_2) / a); else tmp_1 = Float64(Float64(-c) / Float64(b_2 + t_1)); 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 = (t_1 - b_2) / a; else tmp_2 = -c / (b_2 + t_1); 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[(N[(t$95$1 - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[((-c) / N[(b$95$2 + t$95$1), $MachinePrecision]), $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{t\_1 - b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b\_2 + t\_1}\\
\end{array}
\end{array}
herbie shell --seed 2024170
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
: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) (/ (- sqtD b_2) a) (/ (- c) (+ b_2 sqtD)))))
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))