
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (pow (hypot a b) 4.0) (fma b (* b 4.0) -1.0)))
double code(double a, double b) {
return pow(hypot(a, b), 4.0) + fma(b, (b * 4.0), -1.0);
}
function code(a, b) return Float64((hypot(a, b) ^ 4.0) + fma(b, Float64(b * 4.0), -1.0)) end
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)
\end{array}
Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 2e+16)
(+ (pow a 4.0) -1.0)
(if (<= (* b b) 2e+44)
(+ (+ (* 4.0 (* b b)) (pow b 4.0)) -1.0)
(if (<= (* b b) 5e+84) (pow a 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+16) {
tmp = pow(a, 4.0) + -1.0;
} else if ((b * b) <= 2e+44) {
tmp = ((4.0 * (b * b)) + pow(b, 4.0)) + -1.0;
} else if ((b * b) <= 5e+84) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+16) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if ((b * b) <= 2d+44) then
tmp = ((4.0d0 * (b * b)) + (b ** 4.0d0)) + (-1.0d0)
else if ((b * b) <= 5d+84) then
tmp = a ** 4.0d0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+16) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if ((b * b) <= 2e+44) {
tmp = ((4.0 * (b * b)) + Math.pow(b, 4.0)) + -1.0;
} else if ((b * b) <= 5e+84) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+16: tmp = math.pow(a, 4.0) + -1.0 elif (b * b) <= 2e+44: tmp = ((4.0 * (b * b)) + math.pow(b, 4.0)) + -1.0 elif (b * b) <= 5e+84: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+16) tmp = Float64((a ^ 4.0) + -1.0); elseif (Float64(b * b) <= 2e+44) tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) + (b ^ 4.0)) + -1.0); elseif (Float64(b * b) <= 5e+84) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+16) tmp = (a ^ 4.0) + -1.0; elseif ((b * b) <= 2e+44) tmp = ((4.0 * (b * b)) + (b ^ 4.0)) + -1.0; elseif ((b * b) <= 5e+84) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+16], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 2e+44], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 5e+84], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+16}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+44}:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right) + -1\\
\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+84}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2e16Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around 0 99.2%
if 2e16 < (*.f64 b b) < 2.0000000000000002e44Initial program 98.7%
Taylor expanded in a around 0 98.7%
unpow298.7%
Simplified98.7%
unpow298.7%
Applied egg-rr98.7%
Taylor expanded in b around 0 99.8%
if 2.0000000000000002e44 < (*.f64 b b) < 5.0000000000000001e84Initial program 99.4%
associate--l+99.4%
unpow299.4%
unpow199.4%
sqr-pow99.4%
associate-*r*99.6%
unpow199.6%
sqr-pow99.6%
unpow399.6%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around inf 73.5%
if 5.0000000000000001e84 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 95.7%
Final simplification96.7%
(FPCore (a b) :precision binary64 (+ (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) -1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) + -1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) + -1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 2e+16)
(+ (pow a 4.0) -1.0)
(if (<= (* b b) 2e+44)
(pow b 4.0)
(if (<= (* b b) 5e+84) (pow a 4.0) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+16) {
tmp = pow(a, 4.0) + -1.0;
} else if ((b * b) <= 2e+44) {
tmp = pow(b, 4.0);
} else if ((b * b) <= 5e+84) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+16) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if ((b * b) <= 2d+44) then
tmp = b ** 4.0d0
else if ((b * b) <= 5d+84) then
tmp = a ** 4.0d0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+16) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if ((b * b) <= 2e+44) {
tmp = Math.pow(b, 4.0);
} else if ((b * b) <= 5e+84) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+16: tmp = math.pow(a, 4.0) + -1.0 elif (b * b) <= 2e+44: tmp = math.pow(b, 4.0) elif (b * b) <= 5e+84: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+16) tmp = Float64((a ^ 4.0) + -1.0); elseif (Float64(b * b) <= 2e+44) tmp = b ^ 4.0; elseif (Float64(b * b) <= 5e+84) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+16) tmp = (a ^ 4.0) + -1.0; elseif ((b * b) <= 2e+44) tmp = b ^ 4.0; elseif ((b * b) <= 5e+84) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+16], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 2e+44], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 5e+84], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+16}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+44}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+84}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2e16Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around 0 99.2%
if 2e16 < (*.f64 b b) < 2.0000000000000002e44 or 5.0000000000000001e84 < (*.f64 b b) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 95.9%
if 2.0000000000000002e44 < (*.f64 b b) < 5.0000000000000001e84Initial program 99.4%
associate--l+99.4%
unpow299.4%
unpow199.4%
sqr-pow99.4%
associate-*r*99.6%
unpow199.6%
sqr-pow99.6%
unpow399.6%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around inf 73.5%
Final simplification96.7%
(FPCore (a b)
:precision binary64
(if (<= a 35.0)
(+ (+ (* 4.0 (* b b)) (* (* b b) (* b b))) -1.0)
(if (<= a 6.8e+46)
(pow a 4.0)
(if (<= a 1.45e+76) (+ (* (* b b) (+ 4.0 (* b b))) -1.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 35.0) {
tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
} else if (a <= 6.8e+46) {
tmp = pow(a, 4.0);
} else if (a <= 1.45e+76) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 35.0d0) then
tmp = ((4.0d0 * (b * b)) + ((b * b) * (b * b))) + (-1.0d0)
else if (a <= 6.8d+46) then
tmp = a ** 4.0d0
else if (a <= 1.45d+76) then
tmp = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 35.0) {
tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
} else if (a <= 6.8e+46) {
tmp = Math.pow(a, 4.0);
} else if (a <= 1.45e+76) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 35.0: tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0 elif a <= 6.8e+46: tmp = math.pow(a, 4.0) elif a <= 1.45e+76: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 35.0) tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))) + -1.0); elseif (a <= 6.8e+46) tmp = a ^ 4.0; elseif (a <= 1.45e+76) tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 35.0) tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0; elseif (a <= 6.8e+46) tmp = a ^ 4.0; elseif (a <= 1.45e+76) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 35.0], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 6.8e+46], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 1.45e+76], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 35:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\
\mathbf{elif}\;a \leq 6.8 \cdot 10^{+46}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 1.45 \cdot 10^{+76}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 35Initial program 99.9%
Taylor expanded in a around 0 78.2%
unpow278.2%
Simplified78.2%
unpow278.2%
Applied egg-rr78.2%
if 35 < a < 6.7999999999999996e46 or 1.4500000000000001e76 < a Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around inf 92.8%
if 6.7999999999999996e46 < a < 1.4500000000000001e76Initial program 99.7%
Taylor expanded in a around 0 80.2%
unpow280.2%
Simplified80.2%
unpow280.2%
Applied egg-rr80.2%
Taylor expanded in b around 0 80.2%
sqr-pow80.2%
metadata-eval80.2%
pow280.2%
metadata-eval80.2%
pow280.2%
distribute-rgt-out80.2%
Applied egg-rr80.2%
Final simplification81.7%
(FPCore (a b)
:precision binary64
(if (<= a 35.0)
(+ (+ (* 4.0 (* b b)) (* (* b b) (* b b))) -1.0)
(if (<= a 3.05e+47)
(pow a 4.0)
(if (<= a 1.45e+76) (pow b 4.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 35.0) {
tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
} else if (a <= 3.05e+47) {
tmp = pow(a, 4.0);
} else if (a <= 1.45e+76) {
tmp = pow(b, 4.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 35.0d0) then
tmp = ((4.0d0 * (b * b)) + ((b * b) * (b * b))) + (-1.0d0)
else if (a <= 3.05d+47) then
tmp = a ** 4.0d0
else if (a <= 1.45d+76) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 35.0) {
tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
} else if (a <= 3.05e+47) {
tmp = Math.pow(a, 4.0);
} else if (a <= 1.45e+76) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 35.0: tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0 elif a <= 3.05e+47: tmp = math.pow(a, 4.0) elif a <= 1.45e+76: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 35.0) tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))) + -1.0); elseif (a <= 3.05e+47) tmp = a ^ 4.0; elseif (a <= 1.45e+76) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 35.0) tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0; elseif (a <= 3.05e+47) tmp = a ^ 4.0; elseif (a <= 1.45e+76) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 35.0], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 3.05e+47], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 1.45e+76], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 35:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\
\mathbf{elif}\;a \leq 3.05 \cdot 10^{+47}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 1.45 \cdot 10^{+76}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 35Initial program 99.9%
Taylor expanded in a around 0 78.2%
unpow278.2%
Simplified78.2%
unpow278.2%
Applied egg-rr78.2%
if 35 < a < 3.05000000000000009e47 or 1.4500000000000001e76 < a Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*100.0%
unpow1100.0%
sqr-pow100.0%
unpow3100.0%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around inf 92.8%
if 3.05000000000000009e47 < a < 1.4500000000000001e76Initial program 99.7%
associate--l+99.7%
unpow299.7%
unpow199.7%
sqr-pow99.7%
associate-*r*99.7%
unpow199.7%
sqr-pow99.7%
unpow399.7%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 80.4%
Final simplification81.7%
(FPCore (a b) :precision binary64 (+ (+ (* 4.0 (* b b)) (* (* b b) (* b b))) -1.0))
double code(double a, double b) {
return ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((4.0d0 * (b * b)) + ((b * b) * (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
}
def code(a, b): return ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0
function code(a, b) return Float64(Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))) + -1.0) end
function tmp = code(a, b) tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0; end
code[a_, b_] := N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around 0 67.6%
unpow267.6%
Simplified67.6%
unpow267.6%
Applied egg-rr67.6%
Final simplification67.6%
(FPCore (a b) :precision binary64 (+ (* (* b b) (+ 4.0 (* b b))) -1.0))
double code(double a, double b) {
return ((b * b) * (4.0 + (b * b))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * (4.0 + (b * b))) + -1.0;
}
def code(a, b): return ((b * b) * (4.0 + (b * b))) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around 0 67.6%
unpow267.6%
Simplified67.6%
unpow267.6%
Applied egg-rr67.6%
Taylor expanded in b around 0 67.7%
sqr-pow67.6%
metadata-eval67.6%
pow267.6%
metadata-eval67.6%
pow267.6%
distribute-rgt-out67.6%
Applied egg-rr67.6%
Final simplification67.6%
(FPCore (a b) :precision binary64 (+ (* 4.0 (* b b)) -1.0))
double code(double a, double b) {
return (4.0 * (b * b)) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (4.0d0 * (b * b)) + (-1.0d0)
end function
public static double code(double a, double b) {
return (4.0 * (b * b)) + -1.0;
}
def code(a, b): return (4.0 * (b * b)) + -1.0
function code(a, b) return Float64(Float64(4.0 * Float64(b * b)) + -1.0) end
function tmp = code(a, b) tmp = (4.0 * (b * b)) + -1.0; end
code[a_, b_] := N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \left(b \cdot b\right) + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around 0 67.6%
unpow267.6%
Simplified67.6%
Taylor expanded in b around 0 51.6%
unpow251.6%
Simplified51.6%
Final simplification51.6%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 67.7%
+-commutative67.7%
metadata-eval67.7%
pow-sqr67.6%
unpow267.6%
unpow267.6%
unpow267.6%
distribute-rgt-out67.6%
fma-neg67.6%
metadata-eval67.6%
Simplified67.6%
Taylor expanded in b around 0 23.6%
Final simplification23.6%
herbie shell --seed 2023282
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))