
(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 -1.8e+149)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.22e-14)
(/ (- (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 <= -1.8e+149) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.22e-14) {
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 <= (-1.8d+149)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 1.22d-14) 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 <= -1.8e+149) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.22e-14) {
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 <= -1.8e+149: tmp = (b_2 * -2.0) / a elif b_2 <= 1.22e-14: 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 <= -1.8e+149) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.22e-14) 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 <= -1.8e+149) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.22e-14) 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, -1.8e+149], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.22e-14], 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 -1.8 \cdot 10^{+149}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\mathbf{elif}\;b\_2 \leq 1.22 \cdot 10^{-14}:\\
\;\;\;\;\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 < -1.79999999999999997e149Initial program 53.6%
+-commutative53.6%
unsub-neg53.6%
Simplified53.6%
Taylor expanded in b_2 around -inf 95.8%
*-commutative95.8%
Simplified95.8%
if -1.79999999999999997e149 < b_2 < 1.21999999999999994e-14Initial program 80.2%
+-commutative80.2%
unsub-neg80.2%
Simplified80.2%
if 1.21999999999999994e-14 < b_2 Initial program 15.9%
+-commutative15.9%
unsub-neg15.9%
Simplified15.9%
Taylor expanded in b_2 around inf 88.1%
associate-*r/88.1%
*-commutative88.1%
Simplified88.1%
Final simplification85.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -6.8e-69)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.35e-14)
(- (/ (sqrt (* a (- c))) a) (/ b_2 a))
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-69) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.35e-14) {
tmp = (sqrt((a * -c)) / a) - (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 <= (-6.8d-69)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 1.35d-14) then
tmp = (sqrt((a * -c)) / a) - (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 <= -6.8e-69) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.35e-14) {
tmp = (Math.sqrt((a * -c)) / a) - (b_2 / a);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.8e-69: tmp = (b_2 * -2.0) / a elif b_2 <= 1.35e-14: tmp = (math.sqrt((a * -c)) / a) - (b_2 / a) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.8e-69) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.35e-14) tmp = Float64(Float64(sqrt(Float64(a * Float64(-c))) / a) - 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 <= -6.8e-69) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.35e-14) tmp = (sqrt((a * -c)) / a) - (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, -6.8e-69], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.35e-14], N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision] - N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -6.8 \cdot 10^{-69}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\mathbf{elif}\;b\_2 \leq 1.35 \cdot 10^{-14}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a} - \frac{b\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b\_2}\\
\end{array}
\end{array}
if b_2 < -6.80000000000000016e-69Initial program 76.2%
+-commutative76.2%
unsub-neg76.2%
Simplified76.2%
Taylor expanded in b_2 around -inf 92.3%
*-commutative92.3%
Simplified92.3%
if -6.80000000000000016e-69 < b_2 < 1.3499999999999999e-14Initial program 71.5%
+-commutative71.5%
unsub-neg71.5%
Simplified71.5%
prod-diff71.1%
*-commutative71.1%
fma-neg71.1%
prod-diff71.1%
*-commutative71.1%
fma-neg71.1%
associate-+l+71.0%
pow271.0%
*-commutative71.0%
fma-undefine71.1%
distribute-lft-neg-in71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
fma-define71.0%
*-commutative71.0%
fma-undefine71.1%
distribute-lft-neg-in71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
Applied egg-rr71.0%
associate-+l-71.0%
count-271.0%
Simplified71.0%
Taylor expanded in b_2 around 0 67.3%
+-commutative67.3%
mul-1-neg67.3%
unsub-neg67.3%
associate-*l/67.5%
*-lft-identity67.5%
distribute-lft1-in67.5%
metadata-eval67.5%
mul0-lft68.0%
metadata-eval68.0%
neg-sub068.0%
distribute-rgt-neg-out68.0%
Simplified68.0%
if 1.3499999999999999e-14 < b_2 Initial program 15.9%
+-commutative15.9%
unsub-neg15.9%
Simplified15.9%
Taylor expanded in b_2 around inf 88.1%
associate-*r/88.1%
*-commutative88.1%
Simplified88.1%
Final simplification81.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -9e-70) (/ (* b_2 -2.0) a) (if (<= b_2 8.4e-12) (/ (sqrt (* a (- c))) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e-70) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 8.4e-12) {
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 <= (-9d-70)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 8.4d-12) 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 <= -9e-70) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 8.4e-12) {
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 <= -9e-70: tmp = (b_2 * -2.0) / a elif b_2 <= 8.4e-12: 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 <= -9e-70) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 8.4e-12) 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 <= -9e-70) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 8.4e-12) 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, -9e-70], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 8.4e-12], 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 -9 \cdot 10^{-70}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\mathbf{elif}\;b\_2 \leq 8.4 \cdot 10^{-12}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b\_2}\\
\end{array}
\end{array}
if b_2 < -9.00000000000000044e-70Initial program 76.2%
+-commutative76.2%
unsub-neg76.2%
Simplified76.2%
Taylor expanded in b_2 around -inf 92.3%
*-commutative92.3%
Simplified92.3%
if -9.00000000000000044e-70 < b_2 < 8.39999999999999975e-12Initial program 71.5%
+-commutative71.5%
unsub-neg71.5%
Simplified71.5%
prod-diff71.1%
*-commutative71.1%
fma-neg71.1%
prod-diff71.1%
*-commutative71.1%
fma-neg71.1%
associate-+l+71.0%
pow271.0%
*-commutative71.0%
fma-undefine71.1%
distribute-lft-neg-in71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
fma-define71.0%
*-commutative71.0%
fma-undefine71.1%
distribute-lft-neg-in71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
Applied egg-rr71.0%
associate-+l-71.0%
count-271.0%
Simplified71.0%
Taylor expanded in b_2 around 0 67.3%
associate-*l/67.5%
*-lft-identity67.5%
distribute-lft1-in67.5%
metadata-eval67.5%
mul0-lft68.0%
metadata-eval68.0%
neg-sub068.0%
distribute-rgt-neg-out68.0%
Simplified68.0%
if 8.39999999999999975e-12 < b_2 Initial program 15.9%
+-commutative15.9%
unsub-neg15.9%
Simplified15.9%
Taylor expanded in b_2 around inf 88.1%
associate-*r/88.1%
*-commutative88.1%
Simplified88.1%
Final simplification81.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.9e-70) (/ (* b_2 -2.0) a) (if (<= b_2 3.4e-164) (sqrt (/ c (- a))) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.9e-70) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 3.4e-164) {
tmp = sqrt((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.9d-70)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 3.4d-164) then
tmp = sqrt((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.9e-70) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 3.4e-164) {
tmp = Math.sqrt((c / -a));
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.9e-70: tmp = (b_2 * -2.0) / a elif b_2 <= 3.4e-164: tmp = math.sqrt((c / -a)) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.9e-70) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 3.4e-164) tmp = sqrt(Float64(c / Float64(-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.9e-70) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 3.4e-164) tmp = sqrt((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.9e-70], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 3.4e-164], N[Sqrt[N[(c / (-a)), $MachinePrecision]], $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -2.9 \cdot 10^{-70}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\mathbf{elif}\;b\_2 \leq 3.4 \cdot 10^{-164}:\\
\;\;\;\;\sqrt{\frac{c}{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b\_2}\\
\end{array}
\end{array}
if b_2 < -2.89999999999999971e-70Initial program 76.2%
+-commutative76.2%
unsub-neg76.2%
Simplified76.2%
Taylor expanded in b_2 around -inf 92.3%
*-commutative92.3%
Simplified92.3%
if -2.89999999999999971e-70 < b_2 < 3.4e-164Initial program 80.9%
+-commutative80.9%
unsub-neg80.9%
Simplified80.9%
prod-diff80.4%
*-commutative80.4%
fma-neg80.4%
prod-diff80.4%
*-commutative80.4%
fma-neg80.4%
associate-+l+80.4%
pow280.4%
*-commutative80.4%
fma-undefine80.4%
distribute-lft-neg-in80.4%
*-commutative80.4%
distribute-rgt-neg-in80.4%
fma-define80.4%
*-commutative80.4%
fma-undefine80.4%
distribute-lft-neg-in80.4%
*-commutative80.4%
distribute-rgt-neg-in80.4%
Applied egg-rr80.4%
associate-+l-80.4%
count-280.4%
Simplified80.4%
Taylor expanded in a around inf 47.8%
div-sub47.8%
distribute-rgt1-in47.8%
metadata-eval47.8%
mul0-lft47.8%
metadata-eval47.8%
div-sub47.8%
neg-sub047.8%
Simplified47.8%
if 3.4e-164 < b_2 Initial program 29.3%
+-commutative29.3%
unsub-neg29.3%
Simplified29.3%
Taylor expanded in b_2 around inf 70.7%
associate-*r/70.7%
*-commutative70.7%
Simplified70.7%
Final simplification72.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 3.5e-305) (/ b_2 (- a)) (* c (/ -0.5 b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 3.5e-305) {
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 <= 3.5d-305) 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 <= 3.5e-305) {
tmp = b_2 / -a;
} else {
tmp = c * (-0.5 / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 3.5e-305: 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 <= 3.5e-305) tmp = Float64(b_2 / Float64(-a)); else tmp = Float64(c * Float64(-0.5 / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 3.5e-305) 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, 3.5e-305], N[(b$95$2 / (-a)), $MachinePrecision], N[(c * N[(-0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq 3.5 \cdot 10^{-305}:\\
\;\;\;\;\frac{b\_2}{-a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b\_2}\\
\end{array}
\end{array}
if b_2 < 3.4999999999999998e-305Initial program 79.7%
+-commutative79.7%
unsub-neg79.7%
Simplified79.7%
prod-diff79.4%
*-commutative79.4%
fma-neg79.4%
prod-diff79.4%
*-commutative79.4%
fma-neg79.4%
associate-+l+79.4%
pow279.4%
*-commutative79.4%
fma-undefine79.4%
distribute-lft-neg-in79.4%
*-commutative79.4%
distribute-rgt-neg-in79.4%
fma-define79.4%
*-commutative79.4%
fma-undefine79.4%
distribute-lft-neg-in79.4%
*-commutative79.4%
distribute-rgt-neg-in79.4%
Applied egg-rr79.4%
associate-+l-79.4%
count-279.4%
Simplified79.4%
Taylor expanded in b_2 around 0 46.8%
+-commutative46.8%
mul-1-neg46.8%
unsub-neg46.8%
associate-*l/46.9%
*-lft-identity46.9%
distribute-lft1-in46.9%
metadata-eval46.9%
mul0-lft47.1%
metadata-eval47.1%
neg-sub047.1%
distribute-rgt-neg-out47.1%
Simplified47.1%
Taylor expanded in b_2 around inf 31.8%
neg-mul-131.8%
distribute-neg-frac231.8%
Simplified31.8%
if 3.4999999999999998e-305 < b_2 Initial program 36.1%
+-commutative36.1%
unsub-neg36.1%
Simplified36.1%
add-sqr-sqrt32.4%
pow232.4%
pow1/232.4%
sqrt-pow132.4%
pow232.4%
metadata-eval32.4%
Applied egg-rr32.4%
Taylor expanded in b_2 around inf 60.7%
metadata-eval60.7%
times-frac60.8%
*-commutative60.8%
times-frac60.6%
/-rgt-identity60.6%
Simplified60.6%
Final simplification46.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 1.4e-308) (/ (* 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.4e-308) {
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.4d-308) 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.4e-308) {
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.4e-308: 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.4e-308) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(c * Float64(-0.5 / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 1.4e-308) 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.4e-308], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(c * N[(-0.5 / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq 1.4 \cdot 10^{-308}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b\_2}\\
\end{array}
\end{array}
if b_2 < 1.4000000000000002e-308Initial program 79.7%
+-commutative79.7%
unsub-neg79.7%
Simplified79.7%
Taylor expanded in b_2 around -inf 66.4%
*-commutative66.4%
Simplified66.4%
if 1.4000000000000002e-308 < b_2 Initial program 36.1%
+-commutative36.1%
unsub-neg36.1%
Simplified36.1%
add-sqr-sqrt32.4%
pow232.4%
pow1/232.4%
sqrt-pow132.4%
pow232.4%
metadata-eval32.4%
Applied egg-rr32.4%
Taylor expanded in b_2 around inf 60.7%
metadata-eval60.7%
times-frac60.8%
*-commutative60.8%
times-frac60.6%
/-rgt-identity60.6%
Simplified60.6%
Final simplification63.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 1e-309) (/ (* b_2 -2.0) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1e-309) {
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 <= 1d-309) 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 <= 1e-309) {
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 <= 1e-309: 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 <= 1e-309) 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 <= 1e-309) 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, 1e-309], 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 10^{-309}:\\
\;\;\;\;\frac{b\_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b\_2}\\
\end{array}
\end{array}
if b_2 < 1.000000000000002e-309Initial program 79.7%
+-commutative79.7%
unsub-neg79.7%
Simplified79.7%
Taylor expanded in b_2 around -inf 66.4%
*-commutative66.4%
Simplified66.4%
if 1.000000000000002e-309 < b_2 Initial program 36.1%
+-commutative36.1%
unsub-neg36.1%
Simplified36.1%
Taylor expanded in b_2 around inf 60.7%
associate-*r/60.8%
*-commutative60.8%
Simplified60.8%
Final simplification63.6%
(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(b_2 / Float64(-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 57.9%
+-commutative57.9%
unsub-neg57.9%
Simplified57.9%
prod-diff57.6%
*-commutative57.6%
fma-neg57.6%
prod-diff57.6%
*-commutative57.6%
fma-neg57.6%
associate-+l+57.6%
pow257.6%
*-commutative57.6%
fma-undefine57.6%
distribute-lft-neg-in57.6%
*-commutative57.6%
distribute-rgt-neg-in57.6%
fma-define57.6%
*-commutative57.6%
fma-undefine57.6%
distribute-lft-neg-in57.6%
*-commutative57.6%
distribute-rgt-neg-in57.6%
Applied egg-rr57.6%
associate-+l-57.6%
count-257.6%
Simplified57.6%
Taylor expanded in b_2 around 0 37.7%
+-commutative37.7%
mul-1-neg37.7%
unsub-neg37.7%
associate-*l/37.8%
*-lft-identity37.8%
distribute-lft1-in37.8%
metadata-eval37.8%
mul0-lft38.1%
metadata-eval38.1%
neg-sub038.1%
distribute-rgt-neg-out38.1%
Simplified38.1%
Taylor expanded in b_2 around inf 17.4%
neg-mul-117.4%
distribute-neg-frac217.4%
Simplified17.4%
Final simplification17.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 2024053
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
:herbie-expected 10
:alt
(if (< b_2 0.0) (/ (- (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c))))) b_2) a) (/ (- c) (+ b_2 (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c))))))))
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))