
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot 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) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (+ (pow a 4.0) (fma 2.0 (* a (* b (* a b))) (pow b 4.0))) (+ (* 4.0 (pow b 2.0)) -1.0)))
double code(double a, double b) {
return (pow(a, 4.0) + fma(2.0, (a * (b * (a * b))), pow(b, 4.0))) + ((4.0 * pow(b, 2.0)) + -1.0);
}
function code(a, b) return Float64(Float64((a ^ 4.0) + fma(2.0, Float64(a * Float64(b * Float64(a * b))), (b ^ 4.0))) + Float64(Float64(4.0 * (b ^ 2.0)) + -1.0)) end
code[a_, b_] := N[(N[(N[Power[a, 4.0], $MachinePrecision] + N[(2.0 * N[(a * N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({a}^{4} + \mathsf{fma}\left(2, a \cdot \left(b \cdot \left(a \cdot b\right)\right), {b}^{4}\right)\right) + \left(4 \cdot {b}^{2} + -1\right)
\end{array}
Initial program 70.2%
associate--l+70.2%
fma-def70.2%
distribute-rgt-in70.2%
sqr-neg70.2%
distribute-rgt-in70.2%
Simplified72.1%
Taylor expanded in a around 0 60.5%
+-commutative60.5%
associate-+l+60.5%
+-commutative60.5%
fma-def60.5%
unpow260.5%
unpow260.5%
swap-sqr72.3%
unpow272.3%
*-commutative72.3%
Simplified72.3%
unpow272.3%
associate-*r*72.3%
*-commutative72.3%
Applied egg-rr72.3%
Taylor expanded in a around 0 99.4%
Final simplification99.4%
(FPCore (a b) :precision binary64 (+ (+ (pow a 4.0) (fma 2.0 (* a (* b (* a b))) (pow b 4.0))) -1.0))
double code(double a, double b) {
return (pow(a, 4.0) + fma(2.0, (a * (b * (a * b))), pow(b, 4.0))) + -1.0;
}
function code(a, b) return Float64(Float64((a ^ 4.0) + fma(2.0, Float64(a * Float64(b * Float64(a * b))), (b ^ 4.0))) + -1.0) end
code[a_, b_] := N[(N[(N[Power[a, 4.0], $MachinePrecision] + N[(2.0 * N[(a * N[(b * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({a}^{4} + \mathsf{fma}\left(2, a \cdot \left(b \cdot \left(a \cdot b\right)\right), {b}^{4}\right)\right) + -1
\end{array}
Initial program 70.2%
associate--l+70.2%
fma-def70.2%
distribute-rgt-in70.2%
sqr-neg70.2%
distribute-rgt-in70.2%
Simplified72.1%
Taylor expanded in a around 0 60.5%
+-commutative60.5%
associate-+l+60.5%
+-commutative60.5%
fma-def60.5%
unpow260.5%
unpow260.5%
swap-sqr72.3%
unpow272.3%
*-commutative72.3%
Simplified72.3%
unpow272.3%
associate-*r*72.3%
*-commutative72.3%
Applied egg-rr72.3%
Taylor expanded in a around 0 99.4%
Taylor expanded in b around 0 98.8%
Final simplification98.8%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* 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) * (a + 1.0)) + ((b * b) * (1.0 - (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) * (a + 1.0)) + ((b * b) * (1.0 - (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) * (a + 1.0)) + ((b * b) * (1.0 - (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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - 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) * (a + 1.0)) + ((b * b) * (1.0 - (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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 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 1 (*.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified6.6%
Taylor expanded in a around inf 97.5%
Final simplification99.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (pow a 3.0) (+ a 4.0))) (t_1 (+ (* 4.0 (pow a 2.0)) -1.0)))
(if (<= b 2.45e-205)
t_1
(if (<= b 1.38e-191)
t_0
(if (<= b 3.2e-65) t_1 (if (<= b 1.7e+14) t_0 (pow b 4.0)))))))
double code(double a, double b) {
double t_0 = pow(a, 3.0) * (a + 4.0);
double t_1 = (4.0 * pow(a, 2.0)) + -1.0;
double tmp;
if (b <= 2.45e-205) {
tmp = t_1;
} else if (b <= 1.38e-191) {
tmp = t_0;
} else if (b <= 3.2e-65) {
tmp = t_1;
} else if (b <= 1.7e+14) {
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) :: t_1
real(8) :: tmp
t_0 = (a ** 3.0d0) * (a + 4.0d0)
t_1 = (4.0d0 * (a ** 2.0d0)) + (-1.0d0)
if (b <= 2.45d-205) then
tmp = t_1
else if (b <= 1.38d-191) then
tmp = t_0
else if (b <= 3.2d-65) then
tmp = t_1
else if (b <= 1.7d+14) 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 = Math.pow(a, 3.0) * (a + 4.0);
double t_1 = (4.0 * Math.pow(a, 2.0)) + -1.0;
double tmp;
if (b <= 2.45e-205) {
tmp = t_1;
} else if (b <= 1.38e-191) {
tmp = t_0;
} else if (b <= 3.2e-65) {
tmp = t_1;
} else if (b <= 1.7e+14) {
tmp = t_0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(a, 3.0) * (a + 4.0) t_1 = (4.0 * math.pow(a, 2.0)) + -1.0 tmp = 0 if b <= 2.45e-205: tmp = t_1 elif b <= 1.38e-191: tmp = t_0 elif b <= 3.2e-65: tmp = t_1 elif b <= 1.7e+14: tmp = t_0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) t_0 = Float64((a ^ 3.0) * Float64(a + 4.0)) t_1 = Float64(Float64(4.0 * (a ^ 2.0)) + -1.0) tmp = 0.0 if (b <= 2.45e-205) tmp = t_1; elseif (b <= 1.38e-191) tmp = t_0; elseif (b <= 3.2e-65) tmp = t_1; elseif (b <= 1.7e+14) tmp = t_0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = (a ^ 3.0) * (a + 4.0); t_1 = (4.0 * (a ^ 2.0)) + -1.0; tmp = 0.0; if (b <= 2.45e-205) tmp = t_1; elseif (b <= 1.38e-191) tmp = t_0; elseif (b <= 3.2e-65) tmp = t_1; elseif (b <= 1.7e+14) tmp = t_0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[b, 2.45e-205], t$95$1, If[LessEqual[b, 1.38e-191], t$95$0, If[LessEqual[b, 3.2e-65], t$95$1, If[LessEqual[b, 1.7e+14], t$95$0, N[Power[b, 4.0], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {a}^{3} \cdot \left(a + 4\right)\\
t_1 := 4 \cdot {a}^{2} + -1\\
\mathbf{if}\;b \leq 2.45 \cdot 10^{-205}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq 1.38 \cdot 10^{-191}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-65}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 2.4499999999999999e-205 or 1.38000000000000003e-191 < b < 3.1999999999999999e-65Initial program 72.8%
associate--l+72.8%
fma-def72.8%
distribute-rgt-in72.8%
sqr-neg72.8%
distribute-rgt-in72.8%
Simplified74.5%
Taylor expanded in b around 0 53.9%
Taylor expanded in a around 0 57.3%
if 2.4499999999999999e-205 < b < 1.38000000000000003e-191 or 3.1999999999999999e-65 < b < 1.7e14Initial program 76.0%
associate--l+76.0%
fma-def76.0%
distribute-rgt-in76.0%
sqr-neg76.0%
distribute-rgt-in76.0%
Simplified76.0%
Taylor expanded in a around 0 76.1%
+-commutative76.1%
associate-+l+76.1%
+-commutative76.1%
fma-def76.1%
unpow276.1%
unpow276.1%
swap-sqr76.1%
unpow276.1%
*-commutative76.1%
Simplified76.1%
Taylor expanded in a around inf 62.4%
*-commutative62.4%
metadata-eval62.4%
pow-plus62.3%
distribute-lft-out81.4%
Simplified81.4%
if 1.7e14 < b Initial program 59.1%
associate--l+59.1%
fma-def59.1%
distribute-rgt-in59.1%
sqr-neg59.1%
distribute-rgt-in59.1%
Simplified62.8%
Taylor expanded in b around inf 91.5%
Final simplification66.5%
(FPCore (a b) :precision binary64 (if (<= a -102000000.0) (* (pow a 3.0) (+ a 4.0)) (if (<= a 9e+21) (pow b 4.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -102000000.0) {
tmp = pow(a, 3.0) * (a + 4.0);
} else if (a <= 9e+21) {
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 <= (-102000000.0d0)) then
tmp = (a ** 3.0d0) * (a + 4.0d0)
else if (a <= 9d+21) 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 <= -102000000.0) {
tmp = Math.pow(a, 3.0) * (a + 4.0);
} else if (a <= 9e+21) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -102000000.0: tmp = math.pow(a, 3.0) * (a + 4.0) elif a <= 9e+21: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -102000000.0) tmp = Float64((a ^ 3.0) * Float64(a + 4.0)); elseif (a <= 9e+21) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -102000000.0) tmp = (a ^ 3.0) * (a + 4.0); elseif (a <= 9e+21) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -102000000.0], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 9e+21], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -102000000:\\
\;\;\;\;{a}^{3} \cdot \left(a + 4\right)\\
\mathbf{elif}\;a \leq 9 \cdot 10^{+21}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.02e8Initial program 15.4%
associate--l+15.4%
fma-def15.4%
distribute-rgt-in15.4%
sqr-neg15.4%
distribute-rgt-in15.4%
Simplified24.0%
Taylor expanded in a around 0 24.1%
+-commutative24.1%
associate-+l+24.1%
+-commutative24.1%
fma-def24.1%
unpow224.1%
unpow224.1%
swap-sqr24.1%
unpow224.1%
*-commutative24.1%
Simplified24.1%
Taylor expanded in a around inf 12.3%
*-commutative12.3%
metadata-eval12.3%
pow-plus12.2%
distribute-lft-out96.7%
Simplified96.7%
if -1.02e8 < a < 9e21Initial program 99.9%
associate--l+99.9%
fma-def99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in b around inf 59.7%
if 9e21 < a Initial program 62.4%
associate--l+62.4%
fma-def62.4%
distribute-rgt-in62.4%
sqr-neg62.4%
distribute-rgt-in62.4%
Simplified62.4%
Taylor expanded in a around inf 96.1%
Final simplification78.3%
(FPCore (a b) :precision binary64 (if (or (<= a -5800000000000.0) (not (<= a 2.9e+20))) (pow a 4.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((a <= -5800000000000.0) || !(a <= 2.9e+20)) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-5800000000000.0d0)) .or. (.not. (a <= 2.9d+20))) then
tmp = a ** 4.0d0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -5800000000000.0) || !(a <= 2.9e+20)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -5800000000000.0) or not (a <= 2.9e+20): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -5800000000000.0) || !(a <= 2.9e+20)) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -5800000000000.0) || ~((a <= 2.9e+20))) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -5800000000000.0], N[Not[LessEqual[a, 2.9e+20]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5800000000000 \lor \neg \left(a \leq 2.9 \cdot 10^{+20}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if a < -5.8e12 or 2.9e20 < a Initial program 41.4%
associate--l+41.4%
fma-def41.4%
distribute-rgt-in41.4%
sqr-neg41.4%
distribute-rgt-in41.4%
Simplified45.2%
Taylor expanded in a around inf 96.3%
if -5.8e12 < a < 2.9e20Initial program 99.9%
associate--l+99.9%
fma-def99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
Simplified99.9%
Taylor expanded in b around inf 59.7%
Final simplification78.3%
(FPCore (a b) :precision binary64 (pow a 4.0))
double code(double a, double b) {
return pow(a, 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a ** 4.0d0
end function
public static double code(double a, double b) {
return Math.pow(a, 4.0);
}
def code(a, b): return math.pow(a, 4.0)
function code(a, b) return a ^ 4.0 end
function tmp = code(a, b) tmp = a ^ 4.0; end
code[a_, b_] := N[Power[a, 4.0], $MachinePrecision]
\begin{array}{l}
\\
{a}^{4}
\end{array}
Initial program 70.2%
associate--l+70.2%
fma-def70.2%
distribute-rgt-in70.2%
sqr-neg70.2%
distribute-rgt-in70.2%
Simplified72.1%
Taylor expanded in a around inf 50.3%
Final simplification50.3%
herbie shell --seed 2024011
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))