
(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 (fma a a (* b b)) 2.0) (+ (* 4.0 (pow b 2.0)) -1.0)))
double code(double a, double b) {
return pow(fma(a, a, (b * b)), 2.0) + ((4.0 * pow(b, 2.0)) + -1.0);
}
function code(a, b) return Float64((fma(a, a, Float64(b * b)) ^ 2.0) + Float64(Float64(4.0 * (b ^ 2.0)) + -1.0)) end
code[a_, b_] := N[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(4 \cdot {b}^{2} + -1\right)
\end{array}
Initial program 72.1%
associate--l+72.1%
fma-def72.1%
distribute-rgt-in72.1%
sqr-neg72.1%
distribute-rgt-in72.1%
Simplified74.1%
Taylor expanded in a around 0 99.0%
Final simplification99.0%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* b b) (* a a)) 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(((b * b) + (a * a)), 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(((b * b) + (a * a)), 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(((b * b) + (a * a)), 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(b * b) + Float64(a * a)) ^ 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 = (((b * b) + (a * a)) ^ 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[(b * b), $MachinePrecision] + N[(a * a), $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(b \cdot b + a \cdot a\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%
Simplified7.0%
Taylor expanded in a around inf 96.0%
Final simplification98.8%
(FPCore (a b)
:precision binary64
(if (<= a -1.3e+49)
(pow a 4.0)
(if (<= a -9.8e-65)
(pow b 4.0)
(if (<= a -1.5e-202)
-1.0
(if (<= a -3.8e-282)
(pow b 4.0)
(if (<= a 5e-243)
-1.0
(if (<= a 8.2e-201)
(pow b 4.0)
(if (<= a 2.1e-119)
-1.0
(if (<= a 2.05e+25) (pow b 4.0) (pow a 4.0))))))))))
double code(double a, double b) {
double tmp;
if (a <= -1.3e+49) {
tmp = pow(a, 4.0);
} else if (a <= -9.8e-65) {
tmp = pow(b, 4.0);
} else if (a <= -1.5e-202) {
tmp = -1.0;
} else if (a <= -3.8e-282) {
tmp = pow(b, 4.0);
} else if (a <= 5e-243) {
tmp = -1.0;
} else if (a <= 8.2e-201) {
tmp = pow(b, 4.0);
} else if (a <= 2.1e-119) {
tmp = -1.0;
} else if (a <= 2.05e+25) {
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 <= (-1.3d+49)) then
tmp = a ** 4.0d0
else if (a <= (-9.8d-65)) then
tmp = b ** 4.0d0
else if (a <= (-1.5d-202)) then
tmp = -1.0d0
else if (a <= (-3.8d-282)) then
tmp = b ** 4.0d0
else if (a <= 5d-243) then
tmp = -1.0d0
else if (a <= 8.2d-201) then
tmp = b ** 4.0d0
else if (a <= 2.1d-119) then
tmp = -1.0d0
else if (a <= 2.05d+25) 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 <= -1.3e+49) {
tmp = Math.pow(a, 4.0);
} else if (a <= -9.8e-65) {
tmp = Math.pow(b, 4.0);
} else if (a <= -1.5e-202) {
tmp = -1.0;
} else if (a <= -3.8e-282) {
tmp = Math.pow(b, 4.0);
} else if (a <= 5e-243) {
tmp = -1.0;
} else if (a <= 8.2e-201) {
tmp = Math.pow(b, 4.0);
} else if (a <= 2.1e-119) {
tmp = -1.0;
} else if (a <= 2.05e+25) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.3e+49: tmp = math.pow(a, 4.0) elif a <= -9.8e-65: tmp = math.pow(b, 4.0) elif a <= -1.5e-202: tmp = -1.0 elif a <= -3.8e-282: tmp = math.pow(b, 4.0) elif a <= 5e-243: tmp = -1.0 elif a <= 8.2e-201: tmp = math.pow(b, 4.0) elif a <= 2.1e-119: tmp = -1.0 elif a <= 2.05e+25: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.3e+49) tmp = a ^ 4.0; elseif (a <= -9.8e-65) tmp = b ^ 4.0; elseif (a <= -1.5e-202) tmp = -1.0; elseif (a <= -3.8e-282) tmp = b ^ 4.0; elseif (a <= 5e-243) tmp = -1.0; elseif (a <= 8.2e-201) tmp = b ^ 4.0; elseif (a <= 2.1e-119) tmp = -1.0; elseif (a <= 2.05e+25) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.3e+49) tmp = a ^ 4.0; elseif (a <= -9.8e-65) tmp = b ^ 4.0; elseif (a <= -1.5e-202) tmp = -1.0; elseif (a <= -3.8e-282) tmp = b ^ 4.0; elseif (a <= 5e-243) tmp = -1.0; elseif (a <= 8.2e-201) tmp = b ^ 4.0; elseif (a <= 2.1e-119) tmp = -1.0; elseif (a <= 2.05e+25) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.3e+49], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -9.8e-65], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, -1.5e-202], -1.0, If[LessEqual[a, -3.8e-282], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 5e-243], -1.0, If[LessEqual[a, 8.2e-201], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 2.1e-119], -1.0, If[LessEqual[a, 2.05e+25], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.3 \cdot 10^{+49}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -9.8 \cdot 10^{-65}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq -1.5 \cdot 10^{-202}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq -3.8 \cdot 10^{-282}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 5 \cdot 10^{-243}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 8.2 \cdot 10^{-201}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 2.1 \cdot 10^{-119}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 2.05 \cdot 10^{+25}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.29999999999999994e49 or 2.04999999999999983e25 < a Initial program 40.1%
associate--l+40.1%
fma-def40.1%
distribute-rgt-in40.1%
sqr-neg40.1%
distribute-rgt-in40.1%
Simplified44.4%
Taylor expanded in a around inf 96.8%
if -1.29999999999999994e49 < a < -9.79999999999999929e-65 or -1.50000000000000005e-202 < a < -3.79999999999999992e-282 or 5e-243 < a < 8.20000000000000003e-201 or 2.1e-119 < a < 2.04999999999999983e25Initial program 98.5%
associate--l+98.5%
fma-def98.5%
distribute-rgt-in98.5%
sqr-neg98.5%
distribute-rgt-in98.5%
Simplified98.5%
Taylor expanded in b around inf 69.0%
if -9.79999999999999929e-65 < a < -1.50000000000000005e-202 or -3.79999999999999992e-282 < a < 5e-243 or 8.20000000000000003e-201 < a < 2.1e-119Initial 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 a around 0 100.0%
Taylor expanded in b around inf 96.3%
Taylor expanded in b around 0 73.9%
Final simplification82.9%
(FPCore (a b) :precision binary64 (if (or (<= a -9.2e+48) (not (<= a 1.18e+27))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -9.2e+48) || !(a <= 1.18e+27)) {
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 <= (-9.2d+48)) .or. (.not. (a <= 1.18d+27))) 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 <= -9.2e+48) || !(a <= 1.18e+27)) {
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 <= -9.2e+48) or not (a <= 1.18e+27): 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 <= -9.2e+48) || !(a <= 1.18e+27)) 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 <= -9.2e+48) || ~((a <= 1.18e+27))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -9.2e+48], N[Not[LessEqual[a, 1.18e+27]], $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 -9.2 \cdot 10^{+48} \lor \neg \left(a \leq 1.18 \cdot 10^{+27}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -9.2000000000000001e48 or 1.18000000000000006e27 < a Initial program 40.1%
associate--l+40.1%
fma-def40.1%
distribute-rgt-in40.1%
sqr-neg40.1%
distribute-rgt-in40.1%
Simplified44.4%
Taylor expanded in a around inf 96.8%
if -9.2000000000000001e48 < a < 1.18000000000000006e27Initial program 99.1%
associate--l+99.1%
fma-def99.1%
distribute-rgt-in99.1%
sqr-neg99.1%
distribute-rgt-in99.1%
Simplified99.1%
Taylor expanded in a around 0 95.9%
Taylor expanded in b around inf 93.5%
Final simplification95.0%
(FPCore (a b) :precision binary64 (if (or (<= a -2.4) (not (<= a 1.9e-32))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -2.4) || !(a <= 1.9e-32)) {
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 <= (-2.4d0)) .or. (.not. (a <= 1.9d-32))) 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 <= -2.4) || !(a <= 1.9e-32)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.4) or not (a <= 1.9e-32): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.4) || !(a <= 1.9e-32)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.4) || ~((a <= 1.9e-32))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.4], N[Not[LessEqual[a, 1.9e-32]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 1.9 \cdot 10^{-32}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -2.39999999999999991 or 1.90000000000000004e-32 < a Initial program 46.9%
associate--l+46.9%
fma-def46.9%
distribute-rgt-in46.9%
sqr-neg46.9%
distribute-rgt-in46.9%
Simplified50.6%
Taylor expanded in a around inf 87.2%
if -2.39999999999999991 < a < 1.90000000000000004e-32Initial program 99.8%
associate--l+99.8%
fma-def99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
Simplified99.8%
Taylor expanded in a around 0 98.9%
Taylor expanded in b around inf 96.3%
Taylor expanded in b around 0 51.6%
Final simplification70.2%
(FPCore (a b) :precision binary64 (if (<= b 7.2e+35) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 7.2e+35) {
tmp = pow(a, 4.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 <= 7.2d+35) then
tmp = (a ** 4.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 <= 7.2e+35) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 7.2e+35: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 7.2e+35) tmp = Float64((a ^ 4.0) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 7.2e+35) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 7.2e+35], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{+35}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 7.2000000000000001e35Initial program 73.7%
associate--l+73.7%
fma-def73.7%
distribute-rgt-in73.7%
sqr-neg73.7%
distribute-rgt-in73.7%
Simplified74.7%
Taylor expanded in b around 0 63.5%
Taylor expanded in a around inf 78.9%
if 7.2000000000000001e35 < b Initial program 66.6%
associate--l+66.6%
fma-def66.6%
distribute-rgt-in66.6%
sqr-neg66.6%
distribute-rgt-in66.6%
Simplified71.8%
Taylor expanded in b around inf 94.1%
Final simplification82.3%
(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 72.1%
associate--l+72.1%
fma-def72.1%
distribute-rgt-in72.1%
sqr-neg72.1%
distribute-rgt-in72.1%
Simplified74.1%
Taylor expanded in a around 0 70.1%
Taylor expanded in b around inf 68.8%
Taylor expanded in b around 0 25.0%
Final simplification25.0%
herbie shell --seed 2023322
(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))