
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 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 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 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[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 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 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 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[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* a a) (* (* b b) 3.0)))) -1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -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 * ((a * a) + ((b * b) * 3.0d0)))) + (-1.0d0)
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * 3.0)))) + -1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -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[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right)\right) + -1
\end{array}
Initial program 75.7%
Taylor expanded in a around 0 91.7%
Taylor expanded in a around 0 99.1%
Final simplification99.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-14) (+ (* (pow a 2.0) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (+ (* 4.0 (+ (* a a) (* (* b b) 3.0))) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-14) {
tmp = (pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + pow(b, 4.0)) + -1.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) <= 1d-14) then
tmp = ((a ** 2.0d0) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = ((4.0d0 * ((a * a) + ((b * b) * 3.0d0))) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-14) {
tmp = (Math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-14: tmp = (math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-14) tmp = Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64(Float64(Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * 3.0))) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-14) tmp = ((a ^ 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-14], N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-14}:\\
\;\;\;\;{a}^{2} \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right) + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999999e-15Initial program 79.9%
associate--l+79.8%
fma-define79.8%
distribute-rgt-in79.8%
sqr-neg79.8%
distribute-rgt-in79.8%
Simplified79.8%
add-log-exp66.6%
+-commutative66.6%
fmm-def66.6%
fma-undefine66.6%
associate-*r*66.6%
+-commutative66.6%
+-commutative66.6%
fma-define66.6%
pow266.6%
+-commutative66.6%
pow266.6%
metadata-eval66.6%
Applied egg-rr66.6%
Taylor expanded in b around 0 66.6%
Taylor expanded in a around 0 99.9%
if 9.99999999999999999e-15 < (*.f64 b b) Initial program 72.0%
Taylor expanded in a around 0 86.0%
Taylor expanded in a around 0 99.9%
Taylor expanded in a around 0 97.9%
Final simplification98.8%
(FPCore (a b)
:precision binary64
(if (<= a -2.7e+17)
(pow a 4.0)
(if (<= a -5.4e-8)
(pow b 4.0)
(if (<= a 1.8e-146)
(+ (* (* b b) 12.0) -1.0)
(if (<= a 9.5e+18) (pow b 4.0) (pow a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= -2.7e+17) {
tmp = pow(a, 4.0);
} else if (a <= -5.4e-8) {
tmp = pow(b, 4.0);
} else if (a <= 1.8e-146) {
tmp = ((b * b) * 12.0) + -1.0;
} else if (a <= 9.5e+18) {
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 <= (-2.7d+17)) then
tmp = a ** 4.0d0
else if (a <= (-5.4d-8)) then
tmp = b ** 4.0d0
else if (a <= 1.8d-146) then
tmp = ((b * b) * 12.0d0) + (-1.0d0)
else if (a <= 9.5d+18) 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 <= -2.7e+17) {
tmp = Math.pow(a, 4.0);
} else if (a <= -5.4e-8) {
tmp = Math.pow(b, 4.0);
} else if (a <= 1.8e-146) {
tmp = ((b * b) * 12.0) + -1.0;
} else if (a <= 9.5e+18) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.7e+17: tmp = math.pow(a, 4.0) elif a <= -5.4e-8: tmp = math.pow(b, 4.0) elif a <= 1.8e-146: tmp = ((b * b) * 12.0) + -1.0 elif a <= 9.5e+18: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.7e+17) tmp = a ^ 4.0; elseif (a <= -5.4e-8) tmp = b ^ 4.0; elseif (a <= 1.8e-146) tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); elseif (a <= 9.5e+18) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.7e+17) tmp = a ^ 4.0; elseif (a <= -5.4e-8) tmp = b ^ 4.0; elseif (a <= 1.8e-146) tmp = ((b * b) * 12.0) + -1.0; elseif (a <= 9.5e+18) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.7e+17], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -5.4e-8], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 1.8e-146], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 9.5e+18], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.7 \cdot 10^{+17}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -5.4 \cdot 10^{-8}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 1.8 \cdot 10^{-146}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\mathbf{elif}\;a \leq 9.5 \cdot 10^{+18}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -2.7e17 or 9.5e18 < a Initial program 43.8%
associate--l+43.8%
fma-define43.8%
distribute-rgt-in43.8%
sqr-neg43.8%
distribute-rgt-in43.8%
Simplified46.6%
Taylor expanded in a around inf 92.9%
associate-*r/92.9%
metadata-eval92.9%
Simplified92.9%
Taylor expanded in a around inf 92.9%
Taylor expanded in a around 0 92.9%
if -2.7e17 < a < -5.40000000000000005e-8 or 1.79999999999999989e-146 < a < 9.5e18Initial program 96.1%
associate--l+96.0%
fma-define96.0%
distribute-rgt-in96.0%
sqr-neg96.0%
distribute-rgt-in96.0%
Simplified96.0%
Taylor expanded in a around 0 94.1%
pow294.1%
Applied egg-rr94.1%
Taylor expanded in b around inf 76.4%
if -5.40000000000000005e-8 < a < 1.79999999999999989e-146Initial program 99.9%
associate--l+99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 77.8%
pow2100.0%
Applied egg-rr77.8%
Final simplification83.8%
(FPCore (a b) :precision binary64 (if (or (<= a -7.2e+16) (not (<= a 6.4e+19))) (pow a 4.0) (+ (+ (pow b 4.0) (* (* b b) 12.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -7.2e+16) || !(a <= 6.4e+19)) {
tmp = pow(a, 4.0);
} else {
tmp = (pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-7.2d+16)) .or. (.not. (a <= 6.4d+19))) then
tmp = a ** 4.0d0
else
tmp = ((b ** 4.0d0) + ((b * b) * 12.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -7.2e+16) || !(a <= 6.4e+19)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (Math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -7.2e+16) or not (a <= 6.4e+19): tmp = math.pow(a, 4.0) else: tmp = (math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -7.2e+16) || !(a <= 6.4e+19)) tmp = a ^ 4.0; else tmp = Float64(Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -7.2e+16) || ~((a <= 6.4e+19))) tmp = a ^ 4.0; else tmp = ((b ^ 4.0) + ((b * b) * 12.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -7.2e+16], N[Not[LessEqual[a, 6.4e+19]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.2 \cdot 10^{+16} \lor \neg \left(a \leq 6.4 \cdot 10^{+19}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\
\end{array}
\end{array}
if a < -7.2e16 or 6.4e19 < a Initial program 43.8%
associate--l+43.8%
fma-define43.8%
distribute-rgt-in43.8%
sqr-neg43.8%
distribute-rgt-in43.8%
Simplified46.6%
Taylor expanded in a around inf 92.9%
associate-*r/92.9%
metadata-eval92.9%
Simplified92.9%
Taylor expanded in a around inf 92.9%
Taylor expanded in a around 0 92.9%
if -7.2e16 < a < 6.4e19Initial program 98.6%
associate--l+98.6%
fma-define98.6%
distribute-rgt-in98.6%
sqr-neg98.6%
distribute-rgt-in98.6%
Simplified98.6%
Taylor expanded in a around 0 98.0%
pow298.0%
Applied egg-rr98.0%
Final simplification95.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2000.0) (+ (* (pow a 2.0) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (+ (pow b 4.0) (* (* b b) 12.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2000.0) {
tmp = (pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (pow(b, 4.0) + ((b * b) * 12.0)) + -1.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) <= 2000.0d0) then
tmp = ((a ** 2.0d0) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = ((b ** 4.0d0) + ((b * b) * 12.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2000.0) {
tmp = (Math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (Math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2000.0: tmp = (math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = (math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2000.0) tmp = Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64(Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2000.0) tmp = ((a ^ 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = ((b ^ 4.0) + ((b * b) * 12.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2000.0], N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2000:\\
\;\;\;\;{a}^{2} \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 2e3Initial program 80.2%
associate--l+80.2%
fma-define80.2%
distribute-rgt-in80.2%
sqr-neg80.2%
distribute-rgt-in80.2%
Simplified80.2%
add-log-exp67.2%
+-commutative67.2%
fmm-def67.2%
fma-undefine67.2%
associate-*r*67.2%
+-commutative67.2%
+-commutative67.2%
fma-define67.2%
pow267.2%
+-commutative67.2%
pow267.2%
metadata-eval67.2%
Applied egg-rr67.2%
Taylor expanded in b around 0 67.0%
Taylor expanded in a around 0 99.6%
if 2e3 < (*.f64 b b) Initial program 71.6%
associate--l+71.6%
fma-define71.6%
distribute-rgt-in71.6%
sqr-neg71.6%
distribute-rgt-in71.6%
Simplified73.8%
Taylor expanded in a around 0 93.6%
pow293.6%
Applied egg-rr93.6%
Final simplification96.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2000.0) (+ (* 4.0 (pow a 2.0)) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2000.0) {
tmp = (4.0 * pow(a, 2.0)) + -1.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) <= 2000.0d0) then
tmp = (4.0d0 * (a ** 2.0d0)) + (-1.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) <= 2000.0) {
tmp = (4.0 * Math.pow(a, 2.0)) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2000.0: tmp = (4.0 * math.pow(a, 2.0)) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2000.0) tmp = Float64(Float64(4.0 * (a ^ 2.0)) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2000.0) tmp = (4.0 * (a ^ 2.0)) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2000.0], N[(N[(4.0 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2000:\\
\;\;\;\;4 \cdot {a}^{2} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2e3Initial program 80.2%
associate--l+80.2%
fma-define80.2%
distribute-rgt-in80.2%
sqr-neg80.2%
distribute-rgt-in80.2%
Simplified80.2%
add-log-exp67.2%
+-commutative67.2%
fmm-def67.2%
fma-undefine67.2%
associate-*r*67.2%
+-commutative67.2%
+-commutative67.2%
fma-define67.2%
pow267.2%
+-commutative67.2%
pow267.2%
metadata-eval67.2%
Applied egg-rr67.2%
Taylor expanded in b around 0 67.0%
Taylor expanded in a around 0 75.9%
if 2e3 < (*.f64 b b) Initial program 71.6%
associate--l+71.6%
fma-define71.6%
distribute-rgt-in71.6%
sqr-neg71.6%
distribute-rgt-in71.6%
Simplified73.8%
Taylor expanded in a around 0 93.6%
pow293.6%
Applied egg-rr93.6%
Taylor expanded in b around inf 93.1%
Final simplification84.9%
(FPCore (a b) :precision binary64 (if (or (<= a -20000000.0) (not (<= a 2.8e+18))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -20000000.0) || !(a <= 2.8e+18)) {
tmp = pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-20000000.0d0)) .or. (.not. (a <= 2.8d+18))) then
tmp = a ** 4.0d0
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -20000000.0) || !(a <= 2.8e+18)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -20000000.0) or not (a <= 2.8e+18): tmp = math.pow(a, 4.0) else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -20000000.0) || !(a <= 2.8e+18)) tmp = a ^ 4.0; else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -20000000.0) || ~((a <= 2.8e+18))) tmp = a ^ 4.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -20000000.0], N[Not[LessEqual[a, 2.8e+18]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -20000000 \lor \neg \left(a \leq 2.8 \cdot 10^{+18}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -2e7 or 2.8e18 < a Initial program 45.3%
associate--l+45.3%
fma-define45.3%
distribute-rgt-in45.3%
sqr-neg45.3%
distribute-rgt-in45.3%
Simplified48.1%
Taylor expanded in a around inf 91.3%
associate-*r/91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in a around inf 90.9%
Taylor expanded in a around 0 90.9%
if -2e7 < a < 2.8e18Initial program 98.5%
associate--l+98.5%
fma-define98.5%
distribute-rgt-in98.5%
sqr-neg98.5%
distribute-rgt-in98.5%
Simplified98.5%
Taylor expanded in a around 0 98.6%
Taylor expanded in b around 0 72.4%
pow298.6%
Applied egg-rr72.4%
Final simplification80.4%
(FPCore (a b) :precision binary64 (+ (* (* b b) 12.0) -1.0))
double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * 12.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
def code(a, b): return ((b * b) * 12.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 12.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 12.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Initial program 75.7%
associate--l+75.7%
fma-define75.7%
distribute-rgt-in75.7%
sqr-neg75.7%
distribute-rgt-in75.7%
Simplified76.8%
Taylor expanded in a around 0 71.4%
Taylor expanded in b around 0 53.9%
pow271.4%
Applied egg-rr53.9%
Final simplification53.9%
(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 75.7%
associate--l+75.7%
fma-define75.7%
distribute-rgt-in75.7%
sqr-neg75.7%
distribute-rgt-in75.7%
Simplified76.8%
Taylor expanded in a around 0 71.4%
Taylor expanded in b around 0 22.7%
herbie shell --seed 2024177
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))