
(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 12 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 (hypot a b) 2.0)))
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(fma
t_0
t_0
(* 4.0 (fma (pow b 2.0) (+ a 3.0) (* (- 1.0 a) (pow a 2.0)))))
-1.0)
(+
(* (pow a 4.0) (+ 1.0 (/ (- (/ (+ 4.0 (* 2.0 (pow b 2.0))) a) 4.0) a)))
-1.0))))
double code(double a, double b) {
double t_0 = pow(hypot(a, b), 2.0);
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = fma(t_0, t_0, (4.0 * fma(pow(b, 2.0), (a + 3.0), ((1.0 - a) * pow(a, 2.0))))) + -1.0;
} else {
tmp = (pow(a, 4.0) * (1.0 + ((((4.0 + (2.0 * pow(b, 2.0))) / a) - 4.0) / a))) + -1.0;
}
return tmp;
}
function code(a, b) t_0 = hypot(a, b) ^ 2.0 tmp = 0.0 if (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))))) <= Inf) tmp = Float64(fma(t_0, t_0, Float64(4.0 * fma((b ^ 2.0), Float64(a + 3.0), Float64(Float64(1.0 - a) * (a ^ 2.0))))) + -1.0); else tmp = Float64(Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(Float64(Float64(4.0 + Float64(2.0 * (b ^ 2.0))) / a) - 4.0) / a))) + -1.0); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[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], Infinity], N[(N[(t$95$0 * t$95$0 + N[(4.0 * N[(N[Power[b, 2.0], $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(N[(1.0 - a), $MachinePrecision] * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(N[(N[(4.0 + N[(2.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] - 4.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\\
\mathbf{if}\;{\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) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_0, 4 \cdot \mathsf{fma}\left({b}^{2}, a + 3, \left(1 - a\right) \cdot {a}^{2}\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{\frac{4 + 2 \cdot {b}^{2}}{a} - 4}{a}\right) + -1\\
\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%
unpow299.8%
+-commutative99.8%
associate-*r*99.8%
fma-undefine99.8%
fma-define99.8%
fma-define99.8%
add-sqr-sqrt99.8%
pow299.8%
fma-define99.8%
hypot-define99.8%
fma-define99.8%
add-sqr-sqrt99.8%
pow299.8%
fma-define99.8%
hypot-define99.8%
Applied egg-rr99.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%
sub-neg0.0%
flip3-+0.0%
metadata-eval0.0%
metadata-eval0.0%
*-un-lft-identity0.0%
Applied egg-rr0.0%
Taylor expanded in a around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification99.9%
(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) (+ 1.0 (/ (- (/ (+ 4.0 (* 2.0 (pow b 2.0))) a) 4.0) a)))
-1.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) * (1.0 + ((((4.0 + (2.0 * pow(b, 2.0))) / a) - 4.0) / a))) + -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) * (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) * (1.0 + ((((4.0 + (2.0 * Math.pow(b, 2.0))) / a) - 4.0) / a))) + -1.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) * (1.0 + ((((4.0 + (2.0 * math.pow(b, 2.0))) / a) - 4.0) / a))) + -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(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 = Float64(Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(Float64(Float64(4.0 + Float64(2.0 * (b ^ 2.0))) / a) - 4.0) / a))) + -1.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) * (1.0 + ((((4.0 + (2.0 * (b ^ 2.0))) / a) - 4.0) / a))) + -1.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[(N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(N[(N[(4.0 + N[(2.0 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] - 4.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.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} \cdot \left(1 + \frac{\frac{4 + 2 \cdot {b}^{2}}{a} - 4}{a}\right) + -1\\
\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%
sub-neg0.0%
flip3-+0.0%
metadata-eval0.0%
metadata-eval0.0%
*-un-lft-identity0.0%
Applied egg-rr0.0%
Taylor expanded in a around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification99.9%
(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 3.0) (- 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, 3.0) * (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, 3.0) * (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, 3.0) * (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 = Float64((a ^ 3.0) * Float64(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 ^ 3.0) * (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[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.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(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}^{3} \cdot \left(a - 4\right)\\
\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%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified7.2%
Taylor expanded in a around inf 93.1%
associate-*r/93.1%
metadata-eval93.1%
Simplified93.1%
Taylor expanded in a around 0 93.1%
Final simplification98.0%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 1e-9)
(- -1.0 (* (pow a 2.0) (- (* a (- 4.0 a)) 4.0)))
(if (<= (* b b) 2e+89)
(+ (+ (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0)))) (pow b 4.0)) -1.0)
(pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-9) {
tmp = -1.0 - (pow(a, 2.0) * ((a * (4.0 - a)) - 4.0));
} else if ((b * b) <= 2e+89) {
tmp = ((4.0 * ((a * a) + ((b * b) * (a + 3.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-9) then
tmp = (-1.0d0) - ((a ** 2.0d0) * ((a * (4.0d0 - a)) - 4.0d0))
else if ((b * b) <= 2d+89) then
tmp = ((4.0d0 * ((a * a) + ((b * b) * (a + 3.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-9) {
tmp = -1.0 - (Math.pow(a, 2.0) * ((a * (4.0 - a)) - 4.0));
} else if ((b * b) <= 2e+89) {
tmp = ((4.0 * ((a * a) + ((b * b) * (a + 3.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-9: tmp = -1.0 - (math.pow(a, 2.0) * ((a * (4.0 - a)) - 4.0)) elif (b * b) <= 2e+89: tmp = ((4.0 * ((a * a) + ((b * b) * (a + 3.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-9) tmp = Float64(-1.0 - Float64((a ^ 2.0) * Float64(Float64(a * Float64(4.0 - a)) - 4.0))); elseif (Float64(b * b) <= 2e+89) tmp = Float64(Float64(Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.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-9) tmp = -1.0 - ((a ^ 2.0) * ((a * (4.0 - a)) - 4.0)); elseif ((b * b) <= 2e+89) tmp = ((4.0 * ((a * a) + ((b * b) * (a + 3.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-9], N[(-1.0 - N[(N[Power[a, 2.0], $MachinePrecision] * N[(N[(a * N[(4.0 - a), $MachinePrecision]), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 2e+89], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $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^{-9}:\\
\;\;\;\;-1 - {a}^{2} \cdot \left(a \cdot \left(4 - a\right) - 4\right)\\
\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+89}:\\
\;\;\;\;\left(4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) + {b}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1.00000000000000006e-9Initial program 76.1%
sub-neg76.1%
flip3-+64.7%
metadata-eval64.7%
metadata-eval64.7%
*-un-lft-identity64.7%
Applied egg-rr64.7%
Taylor expanded in a around -inf 78.6%
mul-1-neg78.6%
unsub-neg78.6%
mul-1-neg78.6%
unsub-neg78.6%
Simplified78.6%
Taylor expanded in b around 0 78.6%
associate-*r/78.6%
metadata-eval78.6%
Simplified78.6%
Taylor expanded in a around 0 99.9%
if 1.00000000000000006e-9 < (*.f64 b b) < 1.99999999999999999e89Initial program 80.3%
Taylor expanded in a around 0 99.6%
Taylor expanded in a around 0 81.7%
if 1.99999999999999999e89 < (*.f64 b b) Initial program 66.9%
associate--l+66.9%
fma-define66.9%
sqr-neg66.9%
fma-define66.9%
distribute-rgt-in66.9%
sqr-neg66.9%
distribute-rgt-in66.9%
fma-define66.9%
sqr-neg66.9%
Simplified71.8%
Taylor expanded in a around 0 97.3%
pow297.3%
Applied egg-rr97.3%
Taylor expanded in b around inf 97.3%
Final simplification96.7%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 1e+125)
(+
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0)))))
-1.0)
(+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+125) {
tmp = (pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = (((b * b) * 12.0) + 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 ((b * b) <= 1d+125) then
tmp = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * (a + 3.0d0))))) + (-1.0d0)
else
tmp = (((b * b) * 12.0d0) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+125) {
tmp = (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+125: tmp = (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0 else: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+125) tmp = Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0); else tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+125) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0; else tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+125], N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+125}:\\
\;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999992e124Initial program 77.2%
Taylor expanded in a around 0 97.2%
if 9.9999999999999992e124 < (*.f64 b b) Initial program 65.9%
associate--l+65.9%
fma-define65.9%
sqr-neg65.9%
fma-define65.9%
distribute-rgt-in65.9%
sqr-neg65.9%
distribute-rgt-in65.9%
fma-define65.9%
sqr-neg65.9%
Simplified71.1%
Taylor expanded in a around 0 99.1%
pow299.1%
Applied egg-rr99.1%
Final simplification97.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-6) (- -1.0 (* (pow a 2.0) (- (* a (- 4.0 a)) 4.0))) (+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-6) {
tmp = -1.0 - (pow(a, 2.0) * ((a * (4.0 - a)) - 4.0));
} else {
tmp = (((b * b) * 12.0) + 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 ((b * b) <= 2d-6) then
tmp = (-1.0d0) - ((a ** 2.0d0) * ((a * (4.0d0 - a)) - 4.0d0))
else
tmp = (((b * b) * 12.0d0) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-6) {
tmp = -1.0 - (Math.pow(a, 2.0) * ((a * (4.0 - a)) - 4.0));
} else {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-6: tmp = -1.0 - (math.pow(a, 2.0) * ((a * (4.0 - a)) - 4.0)) else: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-6) tmp = Float64(-1.0 - Float64((a ^ 2.0) * Float64(Float64(a * Float64(4.0 - a)) - 4.0))); else tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-6) tmp = -1.0 - ((a ^ 2.0) * ((a * (4.0 - a)) - 4.0)); else tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-6], N[(-1.0 - N[(N[Power[a, 2.0], $MachinePrecision] * N[(N[(a * N[(4.0 - a), $MachinePrecision]), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-6}:\\
\;\;\;\;-1 - {a}^{2} \cdot \left(a \cdot \left(4 - a\right) - 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.99999999999999991e-6Initial program 75.7%
sub-neg75.7%
flip3-+63.6%
metadata-eval63.6%
metadata-eval63.6%
*-un-lft-identity63.6%
Applied egg-rr63.6%
Taylor expanded in a around -inf 79.0%
mul-1-neg79.0%
unsub-neg79.0%
mul-1-neg79.0%
unsub-neg79.0%
Simplified79.0%
Taylor expanded in b around 0 79.0%
associate-*r/79.0%
metadata-eval79.0%
Simplified79.0%
Taylor expanded in a around 0 99.9%
if 1.99999999999999991e-6 < (*.f64 b b) Initial program 70.3%
associate--l+70.3%
fma-define70.3%
sqr-neg70.3%
fma-define70.3%
distribute-rgt-in70.3%
sqr-neg70.3%
distribute-rgt-in70.3%
fma-define70.3%
sqr-neg70.3%
Simplified74.1%
Taylor expanded in a around 0 88.4%
pow288.4%
Applied egg-rr88.4%
Final simplification94.0%
(FPCore (a b)
:precision binary64
(if (<= a -15500000000.0)
(pow a 4.0)
(if (<= a 3.5e-17)
(+ (* (* b b) 12.0) -1.0)
(if (<= a 6.8e+22) (pow b 4.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -15500000000.0) {
tmp = pow(a, 4.0);
} else if (a <= 3.5e-17) {
tmp = ((b * b) * 12.0) + -1.0;
} else if (a <= 6.8e+22) {
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 <= (-15500000000.0d0)) then
tmp = a ** 4.0d0
else if (a <= 3.5d-17) then
tmp = ((b * b) * 12.0d0) + (-1.0d0)
else if (a <= 6.8d+22) 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 <= -15500000000.0) {
tmp = Math.pow(a, 4.0);
} else if (a <= 3.5e-17) {
tmp = ((b * b) * 12.0) + -1.0;
} else if (a <= 6.8e+22) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -15500000000.0: tmp = math.pow(a, 4.0) elif a <= 3.5e-17: tmp = ((b * b) * 12.0) + -1.0 elif a <= 6.8e+22: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -15500000000.0) tmp = a ^ 4.0; elseif (a <= 3.5e-17) tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); elseif (a <= 6.8e+22) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -15500000000.0) tmp = a ^ 4.0; elseif (a <= 3.5e-17) tmp = ((b * b) * 12.0) + -1.0; elseif (a <= 6.8e+22) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -15500000000.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 3.5e-17], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 6.8e+22], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -15500000000:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{-17}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\mathbf{elif}\;a \leq 6.8 \cdot 10^{+22}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.55e10 or 6.8e22 < a Initial program 43.7%
associate--l+43.7%
fma-define43.7%
sqr-neg43.7%
fma-define43.7%
distribute-rgt-in43.7%
sqr-neg43.7%
distribute-rgt-in43.7%
fma-define43.7%
sqr-neg43.7%
Simplified47.8%
Taylor expanded in a around inf 91.3%
associate-*r/91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in a around 0 91.3%
Taylor expanded in a around inf 90.9%
if -1.55e10 < a < 3.5000000000000002e-17Initial program 99.1%
associate--l+99.1%
fma-define99.1%
sqr-neg99.1%
fma-define99.1%
distribute-rgt-in99.1%
sqr-neg99.1%
distribute-rgt-in99.1%
fma-define99.1%
sqr-neg99.1%
Simplified99.1%
Taylor expanded in a around 0 98.4%
Taylor expanded in b around 0 76.0%
*-commutative76.0%
Simplified76.0%
pow298.4%
Applied egg-rr76.0%
if 3.5000000000000002e-17 < a < 6.8e22Initial program 99.6%
associate--l+99.6%
fma-define99.6%
sqr-neg99.6%
fma-define99.6%
distribute-rgt-in99.6%
sqr-neg99.6%
distribute-rgt-in99.6%
fma-define99.6%
sqr-neg99.6%
Simplified99.6%
Taylor expanded in a around 0 77.3%
pow277.3%
Applied egg-rr77.3%
Taylor expanded in b around inf 77.9%
Final simplification83.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-6) (+ (pow a 4.0) -1.0) (+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-6) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = (((b * b) * 12.0) + 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 ((b * b) <= 2d-6) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (((b * b) * 12.0d0) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-6) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-6: tmp = math.pow(a, 4.0) + -1.0 else: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-6) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-6) tmp = (a ^ 4.0) + -1.0; else tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-6], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-6}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 1.99999999999999991e-6Initial program 75.7%
sub-neg75.7%
flip3-+63.6%
metadata-eval63.6%
metadata-eval63.6%
*-un-lft-identity63.6%
Applied egg-rr63.6%
Taylor expanded in a around -inf 79.0%
mul-1-neg79.0%
unsub-neg79.0%
mul-1-neg79.0%
unsub-neg79.0%
Simplified79.0%
Taylor expanded in b around 0 79.0%
associate-*r/79.0%
metadata-eval79.0%
Simplified79.0%
Taylor expanded in a around inf 97.3%
if 1.99999999999999991e-6 < (*.f64 b b) Initial program 70.3%
associate--l+70.3%
fma-define70.3%
sqr-neg70.3%
fma-define70.3%
distribute-rgt-in70.3%
sqr-neg70.3%
distribute-rgt-in70.3%
fma-define70.3%
sqr-neg70.3%
Simplified74.1%
Taylor expanded in a around 0 88.4%
pow288.4%
Applied egg-rr88.4%
Final simplification92.7%
(FPCore (a b) :precision binary64 (if (or (<= a -10500000000.0) (not (<= a 4.4e+19))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -10500000000.0) || !(a <= 4.4e+19)) {
tmp = pow(a, 4.0);
} else {
tmp = ((b * b) * 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 <= (-10500000000.0d0)) .or. (.not. (a <= 4.4d+19))) then
tmp = a ** 4.0d0
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -10500000000.0) || !(a <= 4.4e+19)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -10500000000.0) or not (a <= 4.4e+19): tmp = math.pow(a, 4.0) else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -10500000000.0) || !(a <= 4.4e+19)) tmp = a ^ 4.0; else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -10500000000.0) || ~((a <= 4.4e+19))) tmp = a ^ 4.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -10500000000.0], N[Not[LessEqual[a, 4.4e+19]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -10500000000 \lor \neg \left(a \leq 4.4 \cdot 10^{+19}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -1.05e10 or 4.4e19 < a Initial program 43.7%
associate--l+43.7%
fma-define43.7%
sqr-neg43.7%
fma-define43.7%
distribute-rgt-in43.7%
sqr-neg43.7%
distribute-rgt-in43.7%
fma-define43.7%
sqr-neg43.7%
Simplified47.8%
Taylor expanded in a around inf 91.3%
associate-*r/91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in a around 0 91.3%
Taylor expanded in a around inf 90.9%
if -1.05e10 < a < 4.4e19Initial program 99.1%
associate--l+99.1%
fma-define99.1%
sqr-neg99.1%
fma-define99.1%
distribute-rgt-in99.1%
sqr-neg99.1%
distribute-rgt-in99.1%
fma-define99.1%
sqr-neg99.1%
Simplified99.1%
Taylor expanded in a around 0 96.3%
Taylor expanded in b around 0 72.6%
*-commutative72.6%
Simplified72.6%
pow296.3%
Applied egg-rr72.6%
Final simplification81.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 100000000.0) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 100000000.0) {
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 * b) <= 100000000.0d0) 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 * b) <= 100000000.0) {
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 * b) <= 100000000.0: 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 (Float64(b * b) <= 100000000.0) 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 * b) <= 100000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 100000000.0], 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 \cdot b \leq 100000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1e8Initial program 76.3%
sub-neg76.3%
flip3-+63.7%
metadata-eval63.7%
metadata-eval63.7%
*-un-lft-identity63.7%
Applied egg-rr63.7%
Taylor expanded in a around -inf 78.1%
mul-1-neg78.1%
unsub-neg78.1%
mul-1-neg78.1%
unsub-neg78.1%
Simplified78.1%
Taylor expanded in b around 0 78.1%
associate-*r/78.1%
metadata-eval78.1%
Simplified78.1%
Taylor expanded in a around inf 96.0%
if 1e8 < (*.f64 b b) Initial program 69.6%
associate--l+69.6%
fma-define69.6%
sqr-neg69.6%
fma-define69.6%
distribute-rgt-in69.6%
sqr-neg69.6%
distribute-rgt-in69.6%
fma-define69.6%
sqr-neg69.6%
Simplified73.5%
Taylor expanded in a around 0 88.9%
pow288.9%
Applied egg-rr88.9%
Taylor expanded in b around inf 88.3%
Final simplification92.1%
(FPCore (a b) :precision binary64 (+ (* (* b b) 12.0) -1.0))
double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * 12.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
def code(a, b): return ((b * b) * 12.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 12.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 12.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Initial program 72.9%
associate--l+72.9%
fma-define72.9%
sqr-neg72.9%
fma-define72.9%
distribute-rgt-in72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
fma-define72.9%
sqr-neg72.9%
Simplified74.9%
Taylor expanded in a around 0 66.5%
Taylor expanded in b around 0 48.2%
*-commutative48.2%
Simplified48.2%
pow266.5%
Applied egg-rr48.2%
Final simplification48.2%
(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.9%
associate--l+72.9%
fma-define72.9%
sqr-neg72.9%
fma-define72.9%
distribute-rgt-in72.9%
sqr-neg72.9%
distribute-rgt-in72.9%
fma-define72.9%
sqr-neg72.9%
Simplified74.9%
Taylor expanded in a around 0 66.5%
Taylor expanded in b around 0 21.4%
herbie shell --seed 2024135
(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))