
(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 10 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 (<= a -3.9e+64)
(pow a 4.0)
(if (<= a 260000000000.0)
(+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)
(* (pow a 4.0) (- 1.0 (/ 4.0 a))))))
double code(double a, double b) {
double tmp;
if (a <= -3.9e+64) {
tmp = pow(a, 4.0);
} else if (a <= 260000000000.0) {
tmp = (((b * b) * 12.0) + pow(b, 4.0)) + -1.0;
} else {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-3.9d+64)) then
tmp = a ** 4.0d0
else if (a <= 260000000000.0d0) then
tmp = (((b * b) * 12.0d0) + (b ** 4.0d0)) + (-1.0d0)
else
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -3.9e+64) {
tmp = Math.pow(a, 4.0);
} else if (a <= 260000000000.0) {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
} else {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3.9e+64: tmp = math.pow(a, 4.0) elif a <= 260000000000.0: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 else: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) return tmp
function code(a, b) tmp = 0.0 if (a <= -3.9e+64) tmp = a ^ 4.0; elseif (a <= 260000000000.0) tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3.9e+64) tmp = a ^ 4.0; elseif (a <= 260000000000.0) tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; else tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3.9e+64], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 260000000000.0], N[(N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.9 \cdot 10^{+64}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 260000000000:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\end{array}
\end{array}
if a < -3.8999999999999998e64Initial program 58.4%
associate--l+58.4%
fma-define58.4%
sqr-neg58.4%
fma-define58.4%
distribute-rgt-in58.4%
sqr-neg58.4%
distribute-rgt-in58.4%
fma-define58.4%
sqr-neg58.4%
Simplified58.4%
Taylor expanded in a around inf 98.6%
if -3.8999999999999998e64 < a < 2.6e11Initial program 94.4%
associate--l+94.4%
fma-define94.4%
sqr-neg94.4%
fma-define94.4%
distribute-rgt-in94.4%
sqr-neg94.4%
distribute-rgt-in94.4%
fma-define94.4%
sqr-neg94.4%
Simplified94.4%
Taylor expanded in a around 0 97.1%
unpow297.1%
Applied egg-rr97.1%
if 2.6e11 < a Initial program 27.8%
associate--l+27.8%
fma-define27.8%
sqr-neg27.8%
fma-define27.8%
distribute-rgt-in27.8%
sqr-neg27.8%
distribute-rgt-in27.8%
fma-define27.8%
sqr-neg27.8%
Simplified32.7%
Taylor expanded in a around inf 96.9%
associate-*r/96.9%
metadata-eval96.9%
Simplified96.9%
Final simplification97.4%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (* (pow a 3.0) (- a 4.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 3.0) * (a - 4.0) return tmp
function code(a, b) t_0 = 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(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 3.0) * (a - 4.0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = 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[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\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(a + 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) Initial program 0.0%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified3.8%
Taylor expanded in a around inf 90.3%
associate-*r/90.3%
metadata-eval90.3%
Simplified90.3%
Taylor expanded in a around 0 90.3%
Final simplification96.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ (* (* b b) 12.0) -1.0)))
(if (<= a -1.1e+64)
(pow a 4.0)
(if (<= a 4.6e-246)
t_0
(if (<= a 7e-231) (pow b 4.0) (if (<= a 12200.0) t_0 (pow a 4.0)))))))
double code(double a, double b) {
double t_0 = ((b * b) * 12.0) + -1.0;
double tmp;
if (a <= -1.1e+64) {
tmp = pow(a, 4.0);
} else if (a <= 4.6e-246) {
tmp = t_0;
} else if (a <= 7e-231) {
tmp = pow(b, 4.0);
} else if (a <= 12200.0) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = ((b * b) * 12.0d0) + (-1.0d0)
if (a <= (-1.1d+64)) then
tmp = a ** 4.0d0
else if (a <= 4.6d-246) then
tmp = t_0
else if (a <= 7d-231) then
tmp = b ** 4.0d0
else if (a <= 12200.0d0) then
tmp = t_0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = ((b * b) * 12.0) + -1.0;
double tmp;
if (a <= -1.1e+64) {
tmp = Math.pow(a, 4.0);
} else if (a <= 4.6e-246) {
tmp = t_0;
} else if (a <= 7e-231) {
tmp = Math.pow(b, 4.0);
} else if (a <= 12200.0) {
tmp = t_0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = ((b * b) * 12.0) + -1.0 tmp = 0 if a <= -1.1e+64: tmp = math.pow(a, 4.0) elif a <= 4.6e-246: tmp = t_0 elif a <= 7e-231: tmp = math.pow(b, 4.0) elif a <= 12200.0: tmp = t_0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) t_0 = Float64(Float64(Float64(b * b) * 12.0) + -1.0) tmp = 0.0 if (a <= -1.1e+64) tmp = a ^ 4.0; elseif (a <= 4.6e-246) tmp = t_0; elseif (a <= 7e-231) tmp = b ^ 4.0; elseif (a <= 12200.0) tmp = t_0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = ((b * b) * 12.0) + -1.0; tmp = 0.0; if (a <= -1.1e+64) tmp = a ^ 4.0; elseif (a <= 4.6e-246) tmp = t_0; elseif (a <= 7e-231) tmp = b ^ 4.0; elseif (a <= 12200.0) tmp = t_0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[a, -1.1e+64], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 4.6e-246], t$95$0, If[LessEqual[a, 7e-231], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 12200.0], t$95$0, N[Power[a, 4.0], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot 12 + -1\\
\mathbf{if}\;a \leq -1.1 \cdot 10^{+64}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 4.6 \cdot 10^{-246}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 7 \cdot 10^{-231}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 12200:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.10000000000000001e64 or 12200 < a Initial program 44.4%
associate--l+44.4%
fma-define44.4%
sqr-neg44.4%
fma-define44.4%
distribute-rgt-in44.4%
sqr-neg44.4%
distribute-rgt-in44.4%
fma-define44.4%
sqr-neg44.4%
Simplified46.8%
Taylor expanded in a around inf 96.3%
if -1.10000000000000001e64 < a < 4.5999999999999995e-246 or 7.0000000000000002e-231 < a < 12200Initial program 93.8%
associate--l+93.8%
fma-define93.8%
sqr-neg93.8%
fma-define93.8%
distribute-rgt-in93.8%
sqr-neg93.8%
distribute-rgt-in93.8%
fma-define93.8%
sqr-neg93.8%
Simplified93.8%
Taylor expanded in a around 0 97.5%
Taylor expanded in b around 0 80.9%
unpow297.5%
Applied egg-rr80.9%
if 4.5999999999999995e-246 < a < 7.0000000000000002e-231Initial program 99.6%
associate--l+99.6%
fma-define99.6%
sqr-neg99.6%
fma-define99.6%
distribute-rgt-in99.6%
sqr-neg99.6%
distribute-rgt-in99.6%
fma-define99.6%
sqr-neg99.6%
Simplified99.6%
Taylor expanded in b around inf 92.5%
Final simplification89.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-15) (+ (* (pow a 2.0) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-15) {
tmp = (pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (((b * b) * 12.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-15) then
tmp = ((a ** 2.0d0) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = (((b * b) * 12.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-15) {
tmp = (Math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-15: tmp = (math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-15) tmp = Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-15) tmp = ((a ^ 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-15], 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[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-15}:\\
\;\;\;\;{a}^{2} \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.0000000000000001e-15Initial program 78.4%
associate--l+78.4%
fma-define78.4%
sqr-neg78.4%
fma-define78.4%
distribute-rgt-in78.4%
sqr-neg78.4%
distribute-rgt-in78.4%
fma-define78.4%
sqr-neg78.4%
Simplified78.4%
Taylor expanded in b around 0 78.5%
Taylor expanded in a around 0 99.9%
if 1.0000000000000001e-15 < (*.f64 b b) Initial program 59.3%
associate--l+59.3%
fma-define59.3%
sqr-neg59.3%
fma-define59.3%
distribute-rgt-in59.3%
sqr-neg59.3%
distribute-rgt-in59.3%
fma-define59.3%
sqr-neg59.3%
Simplified61.8%
Taylor expanded in a around 0 91.4%
unpow291.4%
Applied egg-rr91.4%
Final simplification95.9%
(FPCore (a b)
:precision binary64
(if (<= a -1.1e+64)
(pow a 4.0)
(if (<= a 265000000000.0)
(+ (pow b 4.0) -1.0)
(* (pow a 4.0) (- 1.0 (/ 4.0 a))))))
double code(double a, double b) {
double tmp;
if (a <= -1.1e+64) {
tmp = pow(a, 4.0);
} else if (a <= 265000000000.0) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.1d+64)) then
tmp = a ** 4.0d0
else if (a <= 265000000000.0d0) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.1e+64) {
tmp = Math.pow(a, 4.0);
} else if (a <= 265000000000.0) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.1e+64: tmp = math.pow(a, 4.0) elif a <= 265000000000.0: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.1e+64) tmp = a ^ 4.0; elseif (a <= 265000000000.0) tmp = Float64((b ^ 4.0) + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.1e+64) tmp = a ^ 4.0; elseif (a <= 265000000000.0) tmp = (b ^ 4.0) + -1.0; else tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.1e+64], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 265000000000.0], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{+64}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 265000000000:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\end{array}
\end{array}
if a < -1.10000000000000001e64Initial program 58.4%
associate--l+58.4%
fma-define58.4%
sqr-neg58.4%
fma-define58.4%
distribute-rgt-in58.4%
sqr-neg58.4%
distribute-rgt-in58.4%
fma-define58.4%
sqr-neg58.4%
Simplified58.4%
Taylor expanded in a around inf 98.6%
if -1.10000000000000001e64 < a < 2.65e11Initial program 94.4%
associate--l+94.4%
fma-define94.4%
sqr-neg94.4%
fma-define94.4%
distribute-rgt-in94.4%
sqr-neg94.4%
distribute-rgt-in94.4%
fma-define94.4%
sqr-neg94.4%
Simplified94.4%
Taylor expanded in a around 0 97.1%
Taylor expanded in b around inf 95.6%
if 2.65e11 < a Initial program 27.8%
associate--l+27.8%
fma-define27.8%
sqr-neg27.8%
fma-define27.8%
distribute-rgt-in27.8%
sqr-neg27.8%
distribute-rgt-in27.8%
fma-define27.8%
sqr-neg27.8%
Simplified32.7%
Taylor expanded in a around inf 96.9%
associate-*r/96.9%
metadata-eval96.9%
Simplified96.9%
Final simplification96.7%
(FPCore (a b) :precision binary64 (if (<= a -5.5e+65) (pow a 4.0) (if (<= a 265000000000.0) (+ (pow b 4.0) -1.0) (* (pow a 3.0) (- a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -5.5e+65) {
tmp = pow(a, 4.0);
} else if (a <= 265000000000.0) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 3.0) * (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 <= (-5.5d+65)) then
tmp = a ** 4.0d0
else if (a <= 265000000000.0d0) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = (a ** 3.0d0) * (a - 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -5.5e+65) {
tmp = Math.pow(a, 4.0);
} else if (a <= 265000000000.0) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5.5e+65: tmp = math.pow(a, 4.0) elif a <= 265000000000.0: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 3.0) * (a - 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -5.5e+65) tmp = a ^ 4.0; elseif (a <= 265000000000.0) tmp = Float64((b ^ 4.0) + -1.0); else tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5.5e+65) tmp = a ^ 4.0; elseif (a <= 265000000000.0) tmp = (b ^ 4.0) + -1.0; else tmp = (a ^ 3.0) * (a - 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5.5e+65], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 265000000000.0], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.5 \cdot 10^{+65}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 265000000000:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if a < -5.4999999999999996e65Initial program 58.4%
associate--l+58.4%
fma-define58.4%
sqr-neg58.4%
fma-define58.4%
distribute-rgt-in58.4%
sqr-neg58.4%
distribute-rgt-in58.4%
fma-define58.4%
sqr-neg58.4%
Simplified58.4%
Taylor expanded in a around inf 98.6%
if -5.4999999999999996e65 < a < 2.65e11Initial program 94.4%
associate--l+94.4%
fma-define94.4%
sqr-neg94.4%
fma-define94.4%
distribute-rgt-in94.4%
sqr-neg94.4%
distribute-rgt-in94.4%
fma-define94.4%
sqr-neg94.4%
Simplified94.4%
Taylor expanded in a around 0 97.1%
Taylor expanded in b around inf 95.6%
if 2.65e11 < a Initial program 27.8%
associate--l+27.8%
fma-define27.8%
sqr-neg27.8%
fma-define27.8%
distribute-rgt-in27.8%
sqr-neg27.8%
distribute-rgt-in27.8%
fma-define27.8%
sqr-neg27.8%
Simplified32.7%
Taylor expanded in a around inf 96.9%
associate-*r/96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in a around 0 96.8%
Final simplification96.7%
(FPCore (a b) :precision binary64 (if (or (<= a -8.4e+64) (not (<= a 400000000000.0))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -8.4e+64) || !(a <= 400000000000.0)) {
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 <= (-8.4d+64)) .or. (.not. (a <= 400000000000.0d0))) 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 <= -8.4e+64) || !(a <= 400000000000.0)) {
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 <= -8.4e+64) or not (a <= 400000000000.0): 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 <= -8.4e+64) || !(a <= 400000000000.0)) 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 <= -8.4e+64) || ~((a <= 400000000000.0))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -8.4e+64], N[Not[LessEqual[a, 400000000000.0]], $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 -8.4 \cdot 10^{+64} \lor \neg \left(a \leq 400000000000\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -8.4000000000000001e64 or 4e11 < a Initial program 43.6%
associate--l+43.6%
fma-define43.6%
sqr-neg43.6%
fma-define43.6%
distribute-rgt-in43.6%
sqr-neg43.6%
distribute-rgt-in43.6%
fma-define43.6%
sqr-neg43.6%
Simplified46.0%
Taylor expanded in a around inf 97.5%
if -8.4000000000000001e64 < a < 4e11Initial program 94.4%
associate--l+94.4%
fma-define94.4%
sqr-neg94.4%
fma-define94.4%
distribute-rgt-in94.4%
sqr-neg94.4%
distribute-rgt-in94.4%
fma-define94.4%
sqr-neg94.4%
Simplified94.4%
Taylor expanded in a around 0 97.1%
Taylor expanded in b around inf 95.6%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (or (<= a -1.1e+64) (not (<= a 380.0))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -1.1e+64) || !(a <= 380.0)) {
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 <= (-1.1d+64)) .or. (.not. (a <= 380.0d0))) 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 <= -1.1e+64) || !(a <= 380.0)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.1e+64) or not (a <= 380.0): 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 <= -1.1e+64) || !(a <= 380.0)) 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 <= -1.1e+64) || ~((a <= 380.0))) tmp = a ^ 4.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.1e+64], N[Not[LessEqual[a, 380.0]], $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 -1.1 \cdot 10^{+64} \lor \neg \left(a \leq 380\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -1.10000000000000001e64 or 380 < a Initial program 44.4%
associate--l+44.4%
fma-define44.4%
sqr-neg44.4%
fma-define44.4%
distribute-rgt-in44.4%
sqr-neg44.4%
distribute-rgt-in44.4%
fma-define44.4%
sqr-neg44.4%
Simplified46.8%
Taylor expanded in a around inf 96.3%
if -1.10000000000000001e64 < a < 380Initial program 94.4%
associate--l+94.4%
fma-define94.4%
sqr-neg94.4%
fma-define94.4%
distribute-rgt-in94.4%
sqr-neg94.4%
distribute-rgt-in94.4%
fma-define94.4%
sqr-neg94.4%
Simplified94.4%
Taylor expanded in a around 0 97.8%
Taylor expanded in b around 0 76.3%
unpow297.8%
Applied egg-rr76.3%
Final simplification86.3%
(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 69.4%
associate--l+69.4%
fma-define69.4%
sqr-neg69.4%
fma-define69.4%
distribute-rgt-in69.4%
sqr-neg69.4%
distribute-rgt-in69.4%
fma-define69.4%
sqr-neg69.4%
Simplified70.6%
Taylor expanded in a around 0 66.9%
Taylor expanded in b around 0 50.6%
unpow266.9%
Applied egg-rr50.6%
Final simplification50.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 69.4%
associate--l+69.4%
fma-define69.4%
sqr-neg69.4%
fma-define69.4%
distribute-rgt-in69.4%
sqr-neg69.4%
distribute-rgt-in69.4%
fma-define69.4%
sqr-neg69.4%
Simplified70.6%
Taylor expanded in a around 0 66.9%
Taylor expanded in b around inf 66.1%
Taylor expanded in b around 0 24.1%
herbie shell --seed 2024106
(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))