
(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 7 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
(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 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, 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, 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, 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 = 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 ^ 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[Power[a, 4.0], $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}^{4}\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
sqr-neg0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-def0.0%
sqr-neg0.0%
Simplified16.4%
Taylor expanded in a around inf 97.4%
Final simplification99.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0))))
(if (<= b 3e-211)
t_0
(if (<= b 4.8e-189)
(pow a 4.0)
(if (<= b 2.3e-60)
t_0
(if (<= b 1.15e-43)
(pow a 4.0)
(if (<= b 20.0) (+ (* 4.0 (pow a 2.0)) -1.0) (pow b 4.0))))))))
double code(double a, double b) {
double t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
double tmp;
if (b <= 3e-211) {
tmp = t_0;
} else if (b <= 4.8e-189) {
tmp = pow(a, 4.0);
} else if (b <= 2.3e-60) {
tmp = t_0;
} else if (b <= 1.15e-43) {
tmp = pow(a, 4.0);
} else if (b <= 20.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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 + (a * 2.0d0)) * ((a * 2.0d0) + (-1.0d0))
if (b <= 3d-211) then
tmp = t_0
else if (b <= 4.8d-189) then
tmp = a ** 4.0d0
else if (b <= 2.3d-60) then
tmp = t_0
else if (b <= 1.15d-43) then
tmp = a ** 4.0d0
else if (b <= 20.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 t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
double tmp;
if (b <= 3e-211) {
tmp = t_0;
} else if (b <= 4.8e-189) {
tmp = Math.pow(a, 4.0);
} else if (b <= 2.3e-60) {
tmp = t_0;
} else if (b <= 1.15e-43) {
tmp = Math.pow(a, 4.0);
} else if (b <= 20.0) {
tmp = (4.0 * Math.pow(a, 2.0)) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0) tmp = 0 if b <= 3e-211: tmp = t_0 elif b <= 4.8e-189: tmp = math.pow(a, 4.0) elif b <= 2.3e-60: tmp = t_0 elif b <= 1.15e-43: tmp = math.pow(a, 4.0) elif b <= 20.0: tmp = (4.0 * math.pow(a, 2.0)) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) t_0 = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)) tmp = 0.0 if (b <= 3e-211) tmp = t_0; elseif (b <= 4.8e-189) tmp = a ^ 4.0; elseif (b <= 2.3e-60) tmp = t_0; elseif (b <= 1.15e-43) tmp = a ^ 4.0; elseif (b <= 20.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) t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); tmp = 0.0; if (b <= 3e-211) tmp = t_0; elseif (b <= 4.8e-189) tmp = a ^ 4.0; elseif (b <= 2.3e-60) tmp = t_0; elseif (b <= 1.15e-43) tmp = a ^ 4.0; elseif (b <= 20.0) tmp = (4.0 * (a ^ 2.0)) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 3e-211], t$95$0, If[LessEqual[b, 4.8e-189], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 2.3e-60], t$95$0, If[LessEqual[b, 1.15e-43], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 20.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}
t_0 := \left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)\\
\mathbf{if}\;b \leq 3 \cdot 10^{-211}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-189}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-43}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 20:\\
\;\;\;\;4 \cdot {a}^{2} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3.00000000000000005e-211 or 4.7999999999999997e-189 < b < 2.3000000000000001e-60Initial program 76.0%
associate--l+76.0%
fma-def76.0%
sqr-neg76.0%
fma-def76.0%
distribute-rgt-in76.0%
sqr-neg76.0%
distribute-rgt-in76.0%
fma-def76.0%
sqr-neg76.0%
Simplified79.5%
Taylor expanded in b around 0 62.1%
Taylor expanded in a around 0 53.5%
add-sqr-sqrt53.5%
difference-of-sqr-153.5%
*-commutative53.5%
sqrt-prod53.5%
unpow253.5%
sqrt-prod26.8%
add-sqr-sqrt42.6%
metadata-eval42.6%
*-commutative42.6%
sqrt-prod42.6%
unpow242.6%
sqrt-prod26.8%
add-sqr-sqrt53.5%
metadata-eval53.5%
Applied egg-rr53.5%
if 3.00000000000000005e-211 < b < 4.7999999999999997e-189 or 2.3000000000000001e-60 < b < 1.1499999999999999e-43Initial program 33.3%
associate--l+33.3%
fma-def33.3%
sqr-neg33.3%
fma-def33.3%
distribute-rgt-in33.3%
sqr-neg33.3%
distribute-rgt-in33.3%
fma-def33.3%
sqr-neg33.3%
Simplified33.3%
Taylor expanded in a around inf 100.0%
if 1.1499999999999999e-43 < b < 20Initial program 100.0%
associate--l+100.0%
fma-def99.7%
sqr-neg99.7%
fma-def100.0%
distribute-rgt-in100.0%
sqr-neg100.0%
distribute-rgt-in100.0%
fma-def99.7%
sqr-neg99.7%
Simplified99.7%
Taylor expanded in b around 0 91.2%
Taylor expanded in a around 0 52.7%
if 20 < b Initial program 61.0%
associate--l+61.0%
fma-def61.0%
sqr-neg61.0%
fma-def61.0%
distribute-rgt-in61.0%
sqr-neg61.0%
distribute-rgt-in61.0%
fma-def61.0%
sqr-neg61.0%
Simplified69.3%
Taylor expanded in b around inf 90.4%
Final simplification65.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0))))
(if (<= b 1.5e-210)
t_0
(if (<= b 5.4e-189)
(pow a 4.0)
(if (<= b 1.6e-56)
t_0
(if (<= b 8e-38) (pow a 4.0) (if (<= b 125.0) t_0 (pow b 4.0))))))))
double code(double a, double b) {
double t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
double tmp;
if (b <= 1.5e-210) {
tmp = t_0;
} else if (b <= 5.4e-189) {
tmp = pow(a, 4.0);
} else if (b <= 1.6e-56) {
tmp = t_0;
} else if (b <= 8e-38) {
tmp = pow(a, 4.0);
} else if (b <= 125.0) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 + (a * 2.0d0)) * ((a * 2.0d0) + (-1.0d0))
if (b <= 1.5d-210) then
tmp = t_0
else if (b <= 5.4d-189) then
tmp = a ** 4.0d0
else if (b <= 1.6d-56) then
tmp = t_0
else if (b <= 8d-38) then
tmp = a ** 4.0d0
else if (b <= 125.0d0) then
tmp = t_0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
double tmp;
if (b <= 1.5e-210) {
tmp = t_0;
} else if (b <= 5.4e-189) {
tmp = Math.pow(a, 4.0);
} else if (b <= 1.6e-56) {
tmp = t_0;
} else if (b <= 8e-38) {
tmp = Math.pow(a, 4.0);
} else if (b <= 125.0) {
tmp = t_0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0) tmp = 0 if b <= 1.5e-210: tmp = t_0 elif b <= 5.4e-189: tmp = math.pow(a, 4.0) elif b <= 1.6e-56: tmp = t_0 elif b <= 8e-38: tmp = math.pow(a, 4.0) elif b <= 125.0: tmp = t_0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) t_0 = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)) tmp = 0.0 if (b <= 1.5e-210) tmp = t_0; elseif (b <= 5.4e-189) tmp = a ^ 4.0; elseif (b <= 1.6e-56) tmp = t_0; elseif (b <= 8e-38) tmp = a ^ 4.0; elseif (b <= 125.0) tmp = t_0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); tmp = 0.0; if (b <= 1.5e-210) tmp = t_0; elseif (b <= 5.4e-189) tmp = a ^ 4.0; elseif (b <= 1.6e-56) tmp = t_0; elseif (b <= 8e-38) tmp = a ^ 4.0; elseif (b <= 125.0) tmp = t_0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 1.5e-210], t$95$0, If[LessEqual[b, 5.4e-189], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 1.6e-56], t$95$0, If[LessEqual[b, 8e-38], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 125.0], t$95$0, N[Power[b, 4.0], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)\\
\mathbf{if}\;b \leq 1.5 \cdot 10^{-210}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-189}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-56}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-38}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 125:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 1.5000000000000001e-210 or 5.3999999999999999e-189 < b < 1.59999999999999993e-56 or 7.9999999999999997e-38 < b < 125Initial program 76.8%
associate--l+76.8%
fma-def76.8%
sqr-neg76.8%
fma-def76.8%
distribute-rgt-in76.8%
sqr-neg76.8%
distribute-rgt-in76.8%
fma-def76.8%
sqr-neg76.8%
Simplified80.2%
Taylor expanded in b around 0 63.1%
Taylor expanded in a around 0 53.5%
add-sqr-sqrt53.5%
difference-of-sqr-153.5%
*-commutative53.5%
sqrt-prod53.5%
unpow253.5%
sqrt-prod26.4%
add-sqr-sqrt42.3%
metadata-eval42.3%
*-commutative42.3%
sqrt-prod42.3%
unpow242.3%
sqrt-prod26.4%
add-sqr-sqrt53.5%
metadata-eval53.5%
Applied egg-rr53.5%
if 1.5000000000000001e-210 < b < 5.3999999999999999e-189 or 1.59999999999999993e-56 < b < 7.9999999999999997e-38Initial program 33.3%
associate--l+33.3%
fma-def33.3%
sqr-neg33.3%
fma-def33.3%
distribute-rgt-in33.3%
sqr-neg33.3%
distribute-rgt-in33.3%
fma-def33.3%
sqr-neg33.3%
Simplified33.3%
Taylor expanded in a around inf 100.0%
if 125 < b Initial program 61.0%
associate--l+61.0%
fma-def61.0%
sqr-neg61.0%
fma-def61.0%
distribute-rgt-in61.0%
sqr-neg61.0%
distribute-rgt-in61.0%
fma-def61.0%
sqr-neg61.0%
Simplified69.3%
Taylor expanded in b around inf 90.4%
Final simplification65.0%
(FPCore (a b) :precision binary64 (if (or (<= a -3.0) (not (<= a 1800.0))) (pow a 4.0) (+ (* (pow b 2.0) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -3.0) || !(a <= 1800.0)) {
tmp = pow(a, 4.0);
} else {
tmp = (pow(b, 2.0) * 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.0d0)) .or. (.not. (a <= 1800.0d0))) then
tmp = a ** 4.0d0
else
tmp = ((b ** 2.0d0) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -3.0) || !(a <= 1800.0)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (Math.pow(b, 2.0) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -3.0) or not (a <= 1800.0): tmp = math.pow(a, 4.0) else: tmp = (math.pow(b, 2.0) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -3.0) || !(a <= 1800.0)) tmp = a ^ 4.0; else tmp = Float64(Float64((b ^ 2.0) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -3.0) || ~((a <= 1800.0))) tmp = a ^ 4.0; else tmp = ((b ^ 2.0) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -3.0], N[Not[LessEqual[a, 1800.0]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[Power[b, 2.0], $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3 \lor \neg \left(a \leq 1800\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} \cdot 12 + -1\\
\end{array}
\end{array}
if a < -3 or 1800 < a Initial program 44.6%
associate--l+44.6%
fma-def44.6%
sqr-neg44.6%
fma-def44.6%
distribute-rgt-in44.6%
sqr-neg44.6%
distribute-rgt-in44.6%
fma-def44.6%
sqr-neg44.6%
Simplified53.7%
Taylor expanded in a around inf 91.9%
if -3 < a < 1800Initial program 99.8%
associate--l+99.8%
fma-def99.8%
sqr-neg99.8%
fma-def99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
fma-def99.8%
sqr-neg99.8%
Simplified99.8%
Taylor expanded in a around 0 99.3%
Taylor expanded in b around 0 76.7%
*-commutative76.7%
Simplified76.7%
Final simplification84.5%
(FPCore (a b) :precision binary64 (if (or (<= a -9.2e-19) (not (<= a 2.5))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -9.2e-19) || !(a <= 2.5)) {
tmp = pow(a, 4.0);
} else {
tmp = -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 <= (-9.2d-19)) .or. (.not. (a <= 2.5d0))) then
tmp = a ** 4.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -9.2e-19) || !(a <= 2.5)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -9.2e-19) or not (a <= 2.5): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -9.2e-19) || !(a <= 2.5)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -9.2e-19) || ~((a <= 2.5))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -9.2e-19], N[Not[LessEqual[a, 2.5]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.2 \cdot 10^{-19} \lor \neg \left(a \leq 2.5\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -9.19999999999999919e-19 or 2.5 < a Initial program 45.0%
associate--l+45.0%
fma-def45.0%
sqr-neg45.0%
fma-def45.0%
distribute-rgt-in45.0%
sqr-neg45.0%
distribute-rgt-in45.0%
fma-def45.0%
sqr-neg45.0%
Simplified54.0%
Taylor expanded in a around inf 91.2%
if -9.19999999999999919e-19 < a < 2.5Initial program 99.8%
associate--l+99.8%
fma-def99.8%
sqr-neg99.8%
fma-def99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
fma-def99.8%
sqr-neg99.8%
Simplified99.8%
Taylor expanded in b around 0 45.8%
Taylor expanded in a around 0 45.1%
Final simplification69.1%
(FPCore (a b) :precision binary64 (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0)))
double code(double a, double b) {
return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (1.0d0 + (a * 2.0d0)) * ((a * 2.0d0) + (-1.0d0))
end function
public static double code(double a, double b) {
return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
def code(a, b): return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0)
function code(a, b) return Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)) end
function tmp = code(a, b) tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); end
code[a_, b_] := N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)
\end{array}
Initial program 71.4%
associate--l+71.3%
fma-def71.3%
sqr-neg71.3%
fma-def71.3%
distribute-rgt-in71.3%
sqr-neg71.3%
distribute-rgt-in71.3%
fma-def71.3%
sqr-neg71.3%
Simplified76.0%
Taylor expanded in b around 0 50.7%
Taylor expanded in a around 0 45.6%
add-sqr-sqrt45.6%
difference-of-sqr-145.6%
*-commutative45.6%
sqrt-prod45.6%
unpow245.6%
sqrt-prod22.6%
add-sqr-sqrt33.7%
metadata-eval33.7%
*-commutative33.7%
sqrt-prod33.7%
unpow233.7%
sqrt-prod22.6%
add-sqr-sqrt45.6%
metadata-eval45.6%
Applied egg-rr45.6%
Final simplification45.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 71.4%
associate--l+71.3%
fma-def71.3%
sqr-neg71.3%
fma-def71.3%
distribute-rgt-in71.3%
sqr-neg71.3%
distribute-rgt-in71.3%
fma-def71.3%
sqr-neg71.3%
Simplified76.0%
Taylor expanded in b around 0 50.7%
Taylor expanded in a around 0 22.1%
Final simplification22.1%
herbie shell --seed 2023335
(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))