
(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 8 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
(if (<= (* b b) 5e+138)
(+
(+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0)))))
-1.0)
(pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+138) {
tmp = (pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.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) <= 5d+138) then
tmp = ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * (a + 3.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) <= 5e+138) {
tmp = (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+138: tmp = (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+138) tmp = Float64(Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+138) tmp = ((((b * b) + (a * a)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+138], N[(N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+138}:\\
\;\;\;\;\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000016e138Initial program 77.6%
Taylor expanded in a around 0 96.8%
if 5.00000000000000016e138 < (*.f64 b b) Initial program 63.1%
associate--l+63.1%
fma-define63.1%
distribute-rgt-in63.1%
sqr-neg63.1%
distribute-rgt-in63.1%
Simplified64.1%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around inf 100.0%
Final simplification98.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+138) (+ (+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (+ (* a a) (* (* b b) a)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+138) {
tmp = (pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -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) <= 5d+138) then
tmp = ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * a)))) + (-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) <= 5e+138) {
tmp = (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+138: tmp = (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+138) tmp = Float64(Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * a)))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+138) tmp = ((((b * b) + (a * a)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+138], N[(N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+138}:\\
\;\;\;\;\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot a\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000016e138Initial program 77.6%
Taylor expanded in a around 0 96.8%
Taylor expanded in a around inf 95.4%
if 5.00000000000000016e138 < (*.f64 b b) Initial program 63.1%
associate--l+63.1%
fma-define63.1%
distribute-rgt-in63.1%
sqr-neg63.1%
distribute-rgt-in63.1%
Simplified64.1%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around inf 100.0%
Final simplification97.3%
(FPCore (a b) :precision binary64 (if (or (<= a -1.65e+37) (not (<= a 5.2e+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 <= -1.65e+37) || !(a <= 5.2e+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 <= (-1.65d+37)) .or. (.not. (a <= 5.2d+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 <= -1.65e+37) || !(a <= 5.2e+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 <= -1.65e+37) or not (a <= 5.2e+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 <= -1.65e+37) || !(a <= 5.2e+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 <= -1.65e+37) || ~((a <= 5.2e+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, -1.65e+37], N[Not[LessEqual[a, 5.2e+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 -1.65 \cdot 10^{+37} \lor \neg \left(a \leq 5.2 \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 < -1.65e37 or 5.2e19 < a Initial program 44.3%
associate--l+44.3%
fma-define44.3%
distribute-rgt-in44.3%
sqr-neg44.3%
distribute-rgt-in44.3%
Simplified45.1%
Taylor expanded in a around inf 96.2%
associate-*r/96.2%
metadata-eval96.2%
Simplified96.2%
Taylor expanded in a around inf 96.2%
if -1.65e37 < a < 5.2e19Initial program 97.6%
associate--l+97.6%
fma-define97.6%
distribute-rgt-in97.6%
sqr-neg97.6%
distribute-rgt-in97.6%
Simplified97.6%
Taylor expanded in a around 0 98.0%
pow298.0%
Applied egg-rr98.0%
Final simplification97.1%
(FPCore (a b)
:precision binary64
(if (<= a -1.65e+37)
(pow a 4.0)
(if (<= a -1.7e-19)
(pow b 4.0)
(if (<= a 8e+23) (+ (* (* b b) 12.0) -1.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -1.65e+37) {
tmp = pow(a, 4.0);
} else if (a <= -1.7e-19) {
tmp = pow(b, 4.0);
} else if (a <= 8e+23) {
tmp = ((b * b) * 12.0) + -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 <= (-1.65d+37)) then
tmp = a ** 4.0d0
else if (a <= (-1.7d-19)) then
tmp = b ** 4.0d0
else if (a <= 8d+23) then
tmp = ((b * b) * 12.0d0) + (-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 <= -1.65e+37) {
tmp = Math.pow(a, 4.0);
} else if (a <= -1.7e-19) {
tmp = Math.pow(b, 4.0);
} else if (a <= 8e+23) {
tmp = ((b * b) * 12.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.65e+37: tmp = math.pow(a, 4.0) elif a <= -1.7e-19: tmp = math.pow(b, 4.0) elif a <= 8e+23: tmp = ((b * b) * 12.0) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.65e+37) tmp = a ^ 4.0; elseif (a <= -1.7e-19) tmp = b ^ 4.0; elseif (a <= 8e+23) tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.65e+37) tmp = a ^ 4.0; elseif (a <= -1.7e-19) tmp = b ^ 4.0; elseif (a <= 8e+23) tmp = ((b * b) * 12.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.65e+37], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -1.7e-19], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 8e+23], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.65 \cdot 10^{+37}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -1.7 \cdot 10^{-19}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 8 \cdot 10^{+23}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.65e37 or 7.9999999999999993e23 < a Initial program 44.3%
associate--l+44.3%
fma-define44.3%
distribute-rgt-in44.3%
sqr-neg44.3%
distribute-rgt-in44.3%
Simplified45.1%
Taylor expanded in a around inf 96.2%
associate-*r/96.2%
metadata-eval96.2%
Simplified96.2%
Taylor expanded in a around inf 96.2%
if -1.65e37 < a < -1.7000000000000001e-19Initial program 76.6%
associate--l+76.6%
fma-define76.6%
distribute-rgt-in76.6%
sqr-neg76.6%
distribute-rgt-in76.6%
Simplified76.6%
Taylor expanded in a around 0 79.5%
Taylor expanded in b around inf 77.5%
if -1.7000000000000001e-19 < a < 7.9999999999999993e23Initial 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 75.1%
pow2100.0%
Applied egg-rr75.1%
Final simplification85.5%
(FPCore (a b) :precision binary64 (if (or (<= a -3.3e+35) (not (<= a 6.8e+22))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -3.3e+35) || !(a <= 6.8e+22)) {
tmp = pow(a, 4.0);
} else {
tmp = 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 ((a <= (-3.3d+35)) .or. (.not. (a <= 6.8d+22))) then
tmp = a ** 4.0d0
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -3.3e+35) || !(a <= 6.8e+22)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -3.3e+35) or not (a <= 6.8e+22): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -3.3e+35) || !(a <= 6.8e+22)) tmp = a ^ 4.0; else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -3.3e+35) || ~((a <= 6.8e+22))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -3.3e+35], N[Not[LessEqual[a, 6.8e+22]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.3 \cdot 10^{+35} \lor \neg \left(a \leq 6.8 \cdot 10^{+22}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -3.3000000000000002e35 or 6.8e22 < a Initial program 44.3%
associate--l+44.3%
fma-define44.3%
distribute-rgt-in44.3%
sqr-neg44.3%
distribute-rgt-in44.3%
Simplified45.1%
Taylor expanded in a around inf 96.2%
associate-*r/96.2%
metadata-eval96.2%
Simplified96.2%
Taylor expanded in a around inf 96.2%
if -3.3000000000000002e35 < a < 6.8e22Initial program 97.6%
Taylor expanded in a around 0 97.1%
Taylor expanded in a around inf 83.4%
Taylor expanded in a around 0 96.4%
Final simplification96.3%
(FPCore (a b) :precision binary64 (if (or (<= a -3.1e+35) (not (<= a 3.5e+19))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -3.1e+35) || !(a <= 3.5e+19)) {
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 <= (-3.1d+35)) .or. (.not. (a <= 3.5d+19))) 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 <= -3.1e+35) || !(a <= 3.5e+19)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -3.1e+35) or not (a <= 3.5e+19): 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 <= -3.1e+35) || !(a <= 3.5e+19)) 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 <= -3.1e+35) || ~((a <= 3.5e+19))) tmp = a ^ 4.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -3.1e+35], N[Not[LessEqual[a, 3.5e+19]], $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 -3.1 \cdot 10^{+35} \lor \neg \left(a \leq 3.5 \cdot 10^{+19}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -3.09999999999999987e35 or 3.5e19 < a Initial program 44.3%
associate--l+44.3%
fma-define44.3%
distribute-rgt-in44.3%
sqr-neg44.3%
distribute-rgt-in44.3%
Simplified45.1%
Taylor expanded in a around inf 96.2%
associate-*r/96.2%
metadata-eval96.2%
Simplified96.2%
Taylor expanded in a around inf 96.2%
if -3.09999999999999987e35 < a < 3.5e19Initial program 97.6%
associate--l+97.6%
fma-define97.6%
distribute-rgt-in97.6%
sqr-neg97.6%
distribute-rgt-in97.6%
Simplified97.6%
Taylor expanded in a around 0 98.0%
Taylor expanded in b around 0 71.3%
pow298.0%
Applied egg-rr71.3%
Final simplification83.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 71.7%
associate--l+71.7%
fma-define71.7%
distribute-rgt-in71.7%
sqr-neg71.7%
distribute-rgt-in71.7%
Simplified72.1%
Taylor expanded in a around 0 67.4%
Taylor expanded in b around 0 48.8%
pow267.4%
Applied egg-rr48.8%
Final simplification48.8%
(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 71.7%
associate--l+71.7%
fma-define71.7%
distribute-rgt-in71.7%
sqr-neg71.7%
distribute-rgt-in71.7%
Simplified72.1%
Taylor expanded in a around 0 67.4%
Taylor expanded in b around 0 20.6%
herbie shell --seed 2024152
(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))