
(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) 1e+147)
(+
(+
(* (pow a 2.0) (+ 4.0 (+ (* 2.0 (pow b 2.0)) (* a (- a 4.0)))))
(pow b 4.0))
-1.0)
(pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+147) {
tmp = ((pow(a, 2.0) * (4.0 + ((2.0 * pow(b, 2.0)) + (a * (a - 4.0))))) + pow(b, 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 * b) <= 1d+147) then
tmp = (((a ** 2.0d0) * (4.0d0 + ((2.0d0 * (b ** 2.0d0)) + (a * (a - 4.0d0))))) + (b ** 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 * b) <= 1e+147) {
tmp = ((Math.pow(a, 2.0) * (4.0 + ((2.0 * Math.pow(b, 2.0)) + (a * (a - 4.0))))) + Math.pow(b, 4.0)) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+147: tmp = ((math.pow(a, 2.0) * (4.0 + ((2.0 * math.pow(b, 2.0)) + (a * (a - 4.0))))) + math.pow(b, 4.0)) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+147) tmp = Float64(Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(Float64(2.0 * (b ^ 2.0)) + Float64(a * Float64(a - 4.0))))) + (b ^ 4.0)) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+147) tmp = (((a ^ 2.0) * (4.0 + ((2.0 * (b ^ 2.0)) + (a * (a - 4.0))))) + (b ^ 4.0)) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+147], N[(N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(N[(2.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+147}:\\
\;\;\;\;\left({a}^{2} \cdot \left(4 + \left(2 \cdot {b}^{2} + a \cdot \left(a - 4\right)\right)\right) + {b}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999998e146Initial program 83.6%
associate--l+83.6%
fma-define83.6%
distribute-rgt-in83.6%
sqr-neg83.6%
distribute-rgt-in83.6%
Simplified83.6%
Taylor expanded in b around 0 84.2%
Taylor expanded in a around 0 99.9%
if 9.9999999999999998e146 < (*.f64 b b) Initial program 75.2%
associate--l+75.2%
fma-define75.2%
distribute-rgt-in75.2%
sqr-neg75.2%
distribute-rgt-in75.2%
Simplified76.2%
Taylor expanded in b around inf 100.0%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (<= a 2.25e+74) (+ (pow (fma a a (* b b)) 2.0) (+ (* 4.0 (* (pow a 2.0) (- 1.0 a))) -1.0)) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 2.25e+74) {
tmp = pow(fma(a, a, (b * b)), 2.0) + ((4.0 * (pow(a, 2.0) * (1.0 - a))) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= 2.25e+74) tmp = Float64((fma(a, a, Float64(b * b)) ^ 2.0) + Float64(Float64(4.0 * Float64((a ^ 2.0) * Float64(1.0 - a))) + -1.0)); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, 2.25e+74], N[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(4.0 * N[(N[Power[a, 2.0], $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.25 \cdot 10^{+74}:\\
\;\;\;\;{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 2.25e74Initial program 91.1%
associate--l+91.1%
fma-define91.1%
distribute-rgt-in91.1%
sqr-neg91.1%
distribute-rgt-in91.1%
Simplified91.1%
Taylor expanded in b around 0 99.8%
if 2.25e74 < a Initial program 18.4%
associate--l+18.4%
fma-define18.4%
distribute-rgt-in18.4%
sqr-neg18.4%
distribute-rgt-in18.4%
Simplified21.1%
Taylor expanded in a around inf 100.0%
Final simplification99.8%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (+ (* (- 1.0 a) (* a 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(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * 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(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * 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(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * 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(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(1.0 - a) * Float64(a * 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 = (((b * b) + (a * a)) ^ 2.0) + (4.0 * (((1.0 - a) * (a * 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[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(1.0 - a), $MachinePrecision] * N[(a * 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(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(\left(1 - a\right) \cdot \left(a \cdot 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)) #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%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified2.0%
Taylor expanded in a around inf 96.1%
Final simplification99.1%
(FPCore (a b)
:precision binary64
(if (<= b 6.5e-249)
-1.0
(if (<= b 7.6e-89)
(pow a 4.0)
(if (<= b 2.85e-34)
-1.0
(if (<= b 24500000.0) (pow a 4.0) (pow b 4.0))))))
double code(double a, double b) {
double tmp;
if (b <= 6.5e-249) {
tmp = -1.0;
} else if (b <= 7.6e-89) {
tmp = pow(a, 4.0);
} else if (b <= 2.85e-34) {
tmp = -1.0;
} else if (b <= 24500000.0) {
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 (b <= 6.5d-249) then
tmp = -1.0d0
else if (b <= 7.6d-89) then
tmp = a ** 4.0d0
else if (b <= 2.85d-34) then
tmp = -1.0d0
else if (b <= 24500000.0d0) 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 (b <= 6.5e-249) {
tmp = -1.0;
} else if (b <= 7.6e-89) {
tmp = Math.pow(a, 4.0);
} else if (b <= 2.85e-34) {
tmp = -1.0;
} else if (b <= 24500000.0) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6.5e-249: tmp = -1.0 elif b <= 7.6e-89: tmp = math.pow(a, 4.0) elif b <= 2.85e-34: tmp = -1.0 elif b <= 24500000.0: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 6.5e-249) tmp = -1.0; elseif (b <= 7.6e-89) tmp = a ^ 4.0; elseif (b <= 2.85e-34) tmp = -1.0; elseif (b <= 24500000.0) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 6.5e-249) tmp = -1.0; elseif (b <= 7.6e-89) tmp = a ^ 4.0; elseif (b <= 2.85e-34) tmp = -1.0; elseif (b <= 24500000.0) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6.5e-249], -1.0, If[LessEqual[b, 7.6e-89], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 2.85e-34], -1.0, If[LessEqual[b, 24500000.0], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{-249}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-89}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 2.85 \cdot 10^{-34}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 24500000:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 6.50000000000000016e-249 or 7.6000000000000002e-89 < b < 2.84999999999999987e-34Initial program 85.6%
associate--l+85.6%
fma-define85.6%
distribute-rgt-in85.6%
sqr-neg85.6%
distribute-rgt-in85.6%
Simplified85.6%
Taylor expanded in b around 0 89.2%
Taylor expanded in a around 0 67.7%
Taylor expanded in b around 0 30.0%
if 6.50000000000000016e-249 < b < 7.6000000000000002e-89 or 2.84999999999999987e-34 < b < 2.45e7Initial program 75.8%
associate--l+75.8%
fma-define75.8%
distribute-rgt-in75.8%
sqr-neg75.8%
distribute-rgt-in75.8%
Simplified75.8%
Taylor expanded in a around inf 72.8%
if 2.45e7 < b Initial program 69.5%
associate--l+69.5%
fma-define69.5%
distribute-rgt-in69.5%
sqr-neg69.5%
distribute-rgt-in69.5%
Simplified71.0%
Taylor expanded in b around inf 92.9%
Final simplification51.1%
(FPCore (a b) :precision binary64 (if (or (<= a -2.4e+17) (not (<= a 1.75e+15))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.4e+17) || !(a <= 1.75e+15)) {
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 <= (-2.4d+17)) .or. (.not. (a <= 1.75d+15))) 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 <= -2.4e+17) || !(a <= 1.75e+15)) {
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 <= -2.4e+17) or not (a <= 1.75e+15): 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 <= -2.4e+17) || !(a <= 1.75e+15)) 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 <= -2.4e+17) || ~((a <= 1.75e+15))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.4e+17], N[Not[LessEqual[a, 1.75e+15]], $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 -2.4 \cdot 10^{+17} \lor \neg \left(a \leq 1.75 \cdot 10^{+15}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -2.4e17 or 1.75e15 < a Initial program 57.1%
associate--l+57.1%
fma-define57.1%
distribute-rgt-in57.1%
sqr-neg57.1%
distribute-rgt-in57.1%
Simplified58.0%
Taylor expanded in a around inf 92.6%
if -2.4e17 < a < 1.75e15Initial program 98.4%
associate--l+98.4%
fma-define98.4%
distribute-rgt-in98.4%
sqr-neg98.4%
distribute-rgt-in98.4%
Simplified98.4%
Taylor expanded in b around 0 99.8%
Taylor expanded in a around 0 97.9%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (<= a -59000000000000.0) (* (pow a 4.0) (- 1.0 (/ 4.0 a))) (if (<= a 3.8e+22) (+ (pow b 4.0) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -59000000000000.0) {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 3.8e+22) {
tmp = pow(b, 4.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 <= (-59000000000000.0d0)) then
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
else if (a <= 3.8d+22) then
tmp = (b ** 4.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 <= -59000000000000.0) {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
} else if (a <= 3.8e+22) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -59000000000000.0: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) elif a <= 3.8e+22: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -59000000000000.0) tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); elseif (a <= 3.8e+22) tmp = Float64((b ^ 4.0) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -59000000000000.0) tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); elseif (a <= 3.8e+22) tmp = (b ^ 4.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -59000000000000.0], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.8e+22], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -59000000000000:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\mathbf{elif}\;a \leq 3.8 \cdot 10^{+22}:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -5.9e13Initial program 73.7%
associate--l+73.7%
fma-define73.7%
distribute-rgt-in73.7%
sqr-neg73.7%
distribute-rgt-in73.7%
Simplified73.7%
Taylor expanded in a around inf 92.8%
associate-*r/92.8%
metadata-eval92.8%
Simplified92.8%
if -5.9e13 < a < 3.8000000000000004e22Initial program 98.4%
associate--l+98.4%
fma-define98.4%
distribute-rgt-in98.4%
sqr-neg98.4%
distribute-rgt-in98.4%
Simplified98.4%
Taylor expanded in b around 0 99.8%
Taylor expanded in a around 0 98.5%
if 3.8000000000000004e22 < a Initial program 36.7%
associate--l+36.7%
fma-define36.7%
distribute-rgt-in36.7%
sqr-neg36.7%
distribute-rgt-in36.7%
Simplified38.7%
Taylor expanded in a around inf 90.5%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (or (<= a -0.41) (not (<= a 2.5))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -0.41) || !(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 <= (-0.41d0)) .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 <= -0.41) || !(a <= 2.5)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -0.41) 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 <= -0.41) || !(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 <= -0.41) || ~((a <= 2.5))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -0.41], 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 -0.41 \lor \neg \left(a \leq 2.5\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -0.409999999999999976 or 2.5 < a Initial program 58.2%
associate--l+58.2%
fma-define58.2%
distribute-rgt-in58.2%
sqr-neg58.2%
distribute-rgt-in58.2%
Simplified59.1%
Taylor expanded in a around inf 87.7%
if -0.409999999999999976 < a < 2.5Initial program 99.8%
associate--l+99.8%
fma-define99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
Simplified99.8%
Taylor expanded in b around 0 99.7%
Taylor expanded in a around 0 99.1%
Taylor expanded in b around 0 40.7%
Final simplification62.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 80.3%
associate--l+80.3%
fma-define80.3%
distribute-rgt-in80.3%
sqr-neg80.3%
distribute-rgt-in80.3%
Simplified80.7%
Taylor expanded in b around 0 87.7%
Taylor expanded in a around 0 69.4%
Taylor expanded in b around 0 22.0%
Final simplification22.0%
herbie shell --seed 2024076
(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))