
(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 6 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
(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 1e+302)
(+ t_0 -1.0)
(+ (cbrt (pow (pow (hypot a b) 2.0) 6.0)) (+ (* 4.0 (pow b 2.0)) -1.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 <= 1e+302) {
tmp = t_0 + -1.0;
} else {
tmp = cbrt(pow(pow(hypot(a, b), 2.0), 6.0)) + ((4.0 * pow(b, 2.0)) + -1.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 <= 1e+302) {
tmp = t_0 + -1.0;
} else {
tmp = Math.cbrt(Math.pow(Math.pow(Math.hypot(a, b), 2.0), 6.0)) + ((4.0 * Math.pow(b, 2.0)) + -1.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 <= 1e+302) tmp = Float64(t_0 + -1.0); else tmp = Float64(cbrt(((hypot(a, b) ^ 2.0) ^ 6.0)) + Float64(Float64(4.0 * (b ^ 2.0)) + -1.0)); end return 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, 1e+302], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[N[Power[N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision] + N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + -1.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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq 10^{+302}:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\right)}^{6}} + \left(4 \cdot {b}^{2} + -1\right)\\
\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)))))) < 1.0000000000000001e302Initial program 99.8%
if 1.0000000000000001e302 < (+.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 53.5%
associate--l+53.5%
fma-def53.5%
distribute-rgt-in53.5%
sqr-neg53.5%
distribute-rgt-in53.5%
Simplified56.1%
fma-def56.1%
add-cbrt-cube56.1%
pow356.1%
pow-pow56.1%
add-sqr-sqrt56.1%
pow256.1%
hypot-def56.1%
metadata-eval56.1%
Applied egg-rr56.1%
Taylor expanded in a around 0 100.0%
Final simplification99.9%
(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.9%
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%
Simplified5.6%
Taylor expanded in a around inf 93.5%
Final simplification98.1%
(FPCore (a b)
:precision binary64
(if (<= b 1.42e-139)
-1.0
(if (<= b 5.2e-54)
(pow a 4.0)
(if (<= b 5.9e-40)
-1.0
(if (or (<= b 3200000.0) (and (not (<= b 7.5e+21)) (<= b 3.25e+74)))
(pow a 4.0)
(pow b 4.0))))))
double code(double a, double b) {
double tmp;
if (b <= 1.42e-139) {
tmp = -1.0;
} else if (b <= 5.2e-54) {
tmp = pow(a, 4.0);
} else if (b <= 5.9e-40) {
tmp = -1.0;
} else if ((b <= 3200000.0) || (!(b <= 7.5e+21) && (b <= 3.25e+74))) {
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 <= 1.42d-139) then
tmp = -1.0d0
else if (b <= 5.2d-54) then
tmp = a ** 4.0d0
else if (b <= 5.9d-40) then
tmp = -1.0d0
else if ((b <= 3200000.0d0) .or. (.not. (b <= 7.5d+21)) .and. (b <= 3.25d+74)) 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 <= 1.42e-139) {
tmp = -1.0;
} else if (b <= 5.2e-54) {
tmp = Math.pow(a, 4.0);
} else if (b <= 5.9e-40) {
tmp = -1.0;
} else if ((b <= 3200000.0) || (!(b <= 7.5e+21) && (b <= 3.25e+74))) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.42e-139: tmp = -1.0 elif b <= 5.2e-54: tmp = math.pow(a, 4.0) elif b <= 5.9e-40: tmp = -1.0 elif (b <= 3200000.0) or (not (b <= 7.5e+21) and (b <= 3.25e+74)): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.42e-139) tmp = -1.0; elseif (b <= 5.2e-54) tmp = a ^ 4.0; elseif (b <= 5.9e-40) tmp = -1.0; elseif ((b <= 3200000.0) || (!(b <= 7.5e+21) && (b <= 3.25e+74))) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.42e-139) tmp = -1.0; elseif (b <= 5.2e-54) tmp = a ^ 4.0; elseif (b <= 5.9e-40) tmp = -1.0; elseif ((b <= 3200000.0) || (~((b <= 7.5e+21)) && (b <= 3.25e+74))) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.42e-139], -1.0, If[LessEqual[b, 5.2e-54], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 5.9e-40], -1.0, If[Or[LessEqual[b, 3200000.0], And[N[Not[LessEqual[b, 7.5e+21]], $MachinePrecision], LessEqual[b, 3.25e+74]]], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.42 \cdot 10^{-139}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-54}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 5.9 \cdot 10^{-40}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 3200000 \lor \neg \left(b \leq 7.5 \cdot 10^{+21}\right) \land b \leq 3.25 \cdot 10^{+74}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 1.41999999999999997e-139 or 5.20000000000000004e-54 < b < 5.89999999999999966e-40Initial program 78.3%
associate--l+78.3%
fma-def78.3%
distribute-rgt-in78.3%
sqr-neg78.3%
distribute-rgt-in78.3%
Simplified79.5%
fma-def79.5%
add-cbrt-cube70.5%
pow370.5%
pow-pow70.5%
add-sqr-sqrt70.5%
pow270.5%
hypot-def70.5%
metadata-eval70.5%
Applied egg-rr70.5%
Taylor expanded in a around 0 90.7%
Taylor expanded in a around 0 64.1%
Taylor expanded in b around 0 34.6%
if 1.41999999999999997e-139 < b < 5.20000000000000004e-54 or 5.89999999999999966e-40 < b < 3.2e6 or 7.5e21 < b < 3.24999999999999981e74Initial program 59.2%
associate--l+59.2%
fma-def59.2%
distribute-rgt-in59.2%
sqr-neg59.2%
distribute-rgt-in59.2%
Simplified59.2%
Taylor expanded in a around inf 78.7%
if 3.2e6 < b < 7.5e21 or 3.24999999999999981e74 < b Initial program 56.2%
associate--l+56.2%
fma-def56.2%
distribute-rgt-in56.2%
sqr-neg56.2%
distribute-rgt-in56.2%
Simplified60.4%
Taylor expanded in b around inf 97.6%
Final simplification51.9%
(FPCore (a b) :precision binary64 (if (or (<= a -8000000000000.0) (not (<= a 3400000.0))) (pow a 4.0) (+ (* 4.0 (pow b 2.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -8000000000000.0) || !(a <= 3400000.0)) {
tmp = pow(a, 4.0);
} else {
tmp = (4.0 * pow(b, 2.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 <= (-8000000000000.0d0)) .or. (.not. (a <= 3400000.0d0))) then
tmp = a ** 4.0d0
else
tmp = (4.0d0 * (b ** 2.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -8000000000000.0) || !(a <= 3400000.0)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (4.0 * Math.pow(b, 2.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -8000000000000.0) or not (a <= 3400000.0): tmp = math.pow(a, 4.0) else: tmp = (4.0 * math.pow(b, 2.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -8000000000000.0) || !(a <= 3400000.0)) tmp = a ^ 4.0; else tmp = Float64(Float64(4.0 * (b ^ 2.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -8000000000000.0) || ~((a <= 3400000.0))) tmp = a ^ 4.0; else tmp = (4.0 * (b ^ 2.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -8000000000000.0], N[Not[LessEqual[a, 3400000.0]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(4.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8000000000000 \lor \neg \left(a \leq 3400000\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot {b}^{2} + -1\\
\end{array}
\end{array}
if a < -8e12 or 3.4e6 < a Initial program 46.1%
associate--l+46.1%
fma-def46.1%
distribute-rgt-in46.1%
sqr-neg46.1%
distribute-rgt-in46.1%
Simplified49.1%
Taylor expanded in a around inf 93.4%
if -8e12 < a < 3.4e6Initial program 99.1%
associate--l+99.1%
fma-def99.1%
distribute-rgt-in99.1%
sqr-neg99.1%
distribute-rgt-in99.1%
Simplified99.1%
fma-def99.1%
add-cbrt-cube96.1%
pow396.1%
pow-pow96.1%
add-sqr-sqrt96.1%
pow296.1%
hypot-def96.1%
metadata-eval96.1%
Applied egg-rr96.1%
Taylor expanded in a around 0 96.6%
Taylor expanded in a around 0 96.0%
Taylor expanded in b around 0 79.7%
Final simplification86.8%
(FPCore (a b) :precision binary64 (if (or (<= a -2.4) (not (<= a 0.41))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -2.4) || !(a <= 0.41)) {
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 <= 0.41d0))) 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 <= 0.41)) {
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 <= 0.41): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.4) || !(a <= 0.41)) 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 <= 0.41))) 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, 0.41]], $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 0.41\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -2.39999999999999991 or 0.409999999999999976 < a Initial program 46.6%
associate--l+46.6%
fma-def46.6%
distribute-rgt-in46.6%
sqr-neg46.6%
distribute-rgt-in46.6%
Simplified49.5%
Taylor expanded in a around inf 91.9%
if -2.39999999999999991 < a < 0.409999999999999976Initial program 100.0%
associate--l+100.0%
fma-def100.0%
distribute-rgt-in100.0%
sqr-neg100.0%
distribute-rgt-in100.0%
Simplified100.0%
fma-def100.0%
add-cbrt-cube96.8%
pow396.8%
pow-pow96.8%
add-sqr-sqrt96.8%
pow296.8%
hypot-def96.8%
metadata-eval96.8%
Applied egg-rr96.8%
Taylor expanded in a around 0 96.7%
Taylor expanded in a around 0 96.7%
Taylor expanded in b around 0 53.8%
Final simplification73.9%
(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.8%
associate--l+71.8%
fma-def71.8%
distribute-rgt-in71.8%
sqr-neg71.8%
distribute-rgt-in71.8%
Simplified73.4%
fma-def73.4%
add-cbrt-cube65.4%
pow365.4%
pow-pow65.4%
add-sqr-sqrt65.4%
pow265.4%
hypot-def65.4%
metadata-eval65.4%
Applied egg-rr65.4%
Taylor expanded in a around 0 91.7%
Taylor expanded in a around 0 67.2%
Taylor expanded in b around 0 25.8%
Final simplification25.8%
herbie shell --seed 2023318
(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))