
(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 9 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 (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(pow (hypot a b) 4.0)
(fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
(+ -1.0 (pow a 4.0))))
double code(double a, double b) {
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 = pow(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
function code(a, b) 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((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0)); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
code[a_, b_] := 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[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\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:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {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 3 a))))) < +inf.0Initial program 99.8%
associate--l+99.8%
Simplified100.0%
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 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def6.3%
+-commutative6.3%
metadata-eval6.3%
Simplified6.3%
Taylor expanded in a around inf 95.6%
Final simplification98.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) (+ -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) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + 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) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + 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) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = -1.0 + 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(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(-1.0 + (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 = -1.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[(-1.0 + N[Power[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}:\\
\;\;\;\;-1 + {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 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 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def6.3%
+-commutative6.3%
metadata-eval6.3%
Simplified6.3%
Taylor expanded in a around inf 95.6%
Final simplification98.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* a a) 4.0)))
(if (<= a -1.5e+154)
(+ -1.0 t_0)
(if (<= a -85000000.0)
(+ -1.0 (+ (pow a 4.0) (* (* a a) (* (* b b) 2.0))))
(if (<= a -4.6)
(+ -1.0 (+ (pow a 4.0) (* (- 1.0 a) t_0)))
(if (<= a 5e+16)
(+ -1.0 (+ (* b (* b 12.0)) (pow b 4.0)))
(+ -1.0 (pow a 4.0))))))))
double code(double a, double b) {
double t_0 = (a * a) * 4.0;
double tmp;
if (a <= -1.5e+154) {
tmp = -1.0 + t_0;
} else if (a <= -85000000.0) {
tmp = -1.0 + (pow(a, 4.0) + ((a * a) * ((b * b) * 2.0)));
} else if (a <= -4.6) {
tmp = -1.0 + (pow(a, 4.0) + ((1.0 - a) * t_0));
} else if (a <= 5e+16) {
tmp = -1.0 + ((b * (b * 12.0)) + pow(b, 4.0));
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = (a * a) * 4.0d0
if (a <= (-1.5d+154)) then
tmp = (-1.0d0) + t_0
else if (a <= (-85000000.0d0)) then
tmp = (-1.0d0) + ((a ** 4.0d0) + ((a * a) * ((b * b) * 2.0d0)))
else if (a <= (-4.6d0)) then
tmp = (-1.0d0) + ((a ** 4.0d0) + ((1.0d0 - a) * t_0))
else if (a <= 5d+16) then
tmp = (-1.0d0) + ((b * (b * 12.0d0)) + (b ** 4.0d0))
else
tmp = (-1.0d0) + (a ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = (a * a) * 4.0;
double tmp;
if (a <= -1.5e+154) {
tmp = -1.0 + t_0;
} else if (a <= -85000000.0) {
tmp = -1.0 + (Math.pow(a, 4.0) + ((a * a) * ((b * b) * 2.0)));
} else if (a <= -4.6) {
tmp = -1.0 + (Math.pow(a, 4.0) + ((1.0 - a) * t_0));
} else if (a <= 5e+16) {
tmp = -1.0 + ((b * (b * 12.0)) + Math.pow(b, 4.0));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = (a * a) * 4.0 tmp = 0 if a <= -1.5e+154: tmp = -1.0 + t_0 elif a <= -85000000.0: tmp = -1.0 + (math.pow(a, 4.0) + ((a * a) * ((b * b) * 2.0))) elif a <= -4.6: tmp = -1.0 + (math.pow(a, 4.0) + ((1.0 - a) * t_0)) elif a <= 5e+16: tmp = -1.0 + ((b * (b * 12.0)) + math.pow(b, 4.0)) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) t_0 = Float64(Float64(a * a) * 4.0) tmp = 0.0 if (a <= -1.5e+154) tmp = Float64(-1.0 + t_0); elseif (a <= -85000000.0) tmp = Float64(-1.0 + Float64((a ^ 4.0) + Float64(Float64(a * a) * Float64(Float64(b * b) * 2.0)))); elseif (a <= -4.6) tmp = Float64(-1.0 + Float64((a ^ 4.0) + Float64(Float64(1.0 - a) * t_0))); elseif (a <= 5e+16) tmp = Float64(-1.0 + Float64(Float64(b * Float64(b * 12.0)) + (b ^ 4.0))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (a * a) * 4.0; tmp = 0.0; if (a <= -1.5e+154) tmp = -1.0 + t_0; elseif (a <= -85000000.0) tmp = -1.0 + ((a ^ 4.0) + ((a * a) * ((b * b) * 2.0))); elseif (a <= -4.6) tmp = -1.0 + ((a ^ 4.0) + ((1.0 - a) * t_0)); elseif (a <= 5e+16) tmp = -1.0 + ((b * (b * 12.0)) + (b ^ 4.0)); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]}, If[LessEqual[a, -1.5e+154], N[(-1.0 + t$95$0), $MachinePrecision], If[LessEqual[a, -85000000.0], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -4.6], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(1.0 - a), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5e+16], N[(-1.0 + N[(N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(a \cdot a\right) \cdot 4\\
\mathbf{if}\;a \leq -1.5 \cdot 10^{+154}:\\
\;\;\;\;-1 + t_0\\
\mathbf{elif}\;a \leq -85000000:\\
\;\;\;\;-1 + \left({a}^{4} + \left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot 2\right)\right)\\
\mathbf{elif}\;a \leq -4.6:\\
\;\;\;\;-1 + \left({a}^{4} + \left(1 - a\right) \cdot t_0\right)\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+16}:\\
\;\;\;\;-1 + \left(b \cdot \left(b \cdot 12\right) + {b}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -1.50000000000000013e154Initial program 58.1%
sub-neg58.1%
fma-def58.1%
fma-def58.1%
+-commutative58.1%
metadata-eval58.1%
Simplified58.1%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
if -1.50000000000000013e154 < a < -8.5e7Initial program 71.1%
sub-neg71.1%
fma-def71.1%
fma-def71.1%
+-commutative71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in b around 0 97.1%
fma-def97.1%
fma-def97.1%
unpow297.1%
distribute-lft-in97.1%
metadata-eval97.1%
unpow297.1%
associate-*r*97.1%
unpow297.1%
Simplified97.1%
Taylor expanded in a around inf 97.1%
Taylor expanded in a around inf 71.4%
+-commutative71.4%
+-commutative71.4%
associate-+l+71.4%
unpow271.4%
associate-*r*71.4%
unpow271.4%
unpow271.4%
associate-*r*68.6%
distribute-rgt-in97.1%
unpow297.1%
*-commutative97.1%
unpow297.1%
associate-*r*97.1%
distribute-rgt-out97.1%
Simplified97.1%
Taylor expanded in a around inf 100.0%
unpow2100.0%
unpow2100.0%
associate-*r*97.1%
*-commutative97.1%
associate-*r*100.0%
Simplified100.0%
if -8.5e7 < a < -4.5999999999999996Initial program 100.0%
sub-neg100.0%
fma-def100.0%
fma-def100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in b around 0 98.4%
associate-*r*98.4%
unpow298.4%
Simplified98.4%
if -4.5999999999999996 < a < 5e16Initial program 99.9%
sub-neg99.9%
fma-def99.9%
fma-def99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around 0 87.4%
associate-+r+87.4%
associate-*r*87.4%
distribute-rgt-out99.9%
metadata-eval99.9%
distribute-lft-in99.9%
unpow299.9%
distribute-rgt-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around 0 99.9%
unpow299.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
Simplified99.9%
if 5e16 < a Initial program 32.7%
sub-neg32.7%
fma-def32.7%
fma-def39.2%
+-commutative39.2%
metadata-eval39.2%
Simplified39.2%
Taylor expanded in a around inf 95.4%
Final simplification98.8%
(FPCore (a b)
:precision binary64
(if (<= a -0.7)
(+ -1.0 (+ (pow a 4.0) (* (- 1.0 a) (* (* a a) 4.0))))
(if (<= a 1.32e+16)
(+ -1.0 (+ (* b (* b 12.0)) (pow b 4.0)))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -0.7) {
tmp = -1.0 + (pow(a, 4.0) + ((1.0 - a) * ((a * a) * 4.0)));
} else if (a <= 1.32e+16) {
tmp = -1.0 + ((b * (b * 12.0)) + pow(b, 4.0));
} else {
tmp = -1.0 + 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 <= (-0.7d0)) then
tmp = (-1.0d0) + ((a ** 4.0d0) + ((1.0d0 - a) * ((a * a) * 4.0d0)))
else if (a <= 1.32d+16) then
tmp = (-1.0d0) + ((b * (b * 12.0d0)) + (b ** 4.0d0))
else
tmp = (-1.0d0) + (a ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.7) {
tmp = -1.0 + (Math.pow(a, 4.0) + ((1.0 - a) * ((a * a) * 4.0)));
} else if (a <= 1.32e+16) {
tmp = -1.0 + ((b * (b * 12.0)) + Math.pow(b, 4.0));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.7: tmp = -1.0 + (math.pow(a, 4.0) + ((1.0 - a) * ((a * a) * 4.0))) elif a <= 1.32e+16: tmp = -1.0 + ((b * (b * 12.0)) + math.pow(b, 4.0)) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.7) tmp = Float64(-1.0 + Float64((a ^ 4.0) + Float64(Float64(1.0 - a) * Float64(Float64(a * a) * 4.0)))); elseif (a <= 1.32e+16) tmp = Float64(-1.0 + Float64(Float64(b * Float64(b * 12.0)) + (b ^ 4.0))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.7) tmp = -1.0 + ((a ^ 4.0) + ((1.0 - a) * ((a * a) * 4.0))); elseif (a <= 1.32e+16) tmp = -1.0 + ((b * (b * 12.0)) + (b ^ 4.0)); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.7], N[(-1.0 + N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(1.0 - a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.32e+16], N[(-1.0 + N[(N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.7:\\
\;\;\;\;-1 + \left({a}^{4} + \left(1 - a\right) \cdot \left(\left(a \cdot a\right) \cdot 4\right)\right)\\
\mathbf{elif}\;a \leq 1.32 \cdot 10^{+16}:\\
\;\;\;\;-1 + \left(b \cdot \left(b \cdot 12\right) + {b}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -0.69999999999999996Initial program 65.5%
sub-neg65.5%
fma-def65.5%
fma-def65.5%
+-commutative65.5%
metadata-eval65.5%
Simplified65.5%
Taylor expanded in b around 0 93.9%
associate-*r*93.9%
unpow293.9%
Simplified93.9%
if -0.69999999999999996 < a < 1.32e16Initial program 99.9%
sub-neg99.9%
fma-def99.9%
fma-def99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around 0 87.4%
associate-+r+87.4%
associate-*r*87.4%
distribute-rgt-out99.9%
metadata-eval99.9%
distribute-lft-in99.9%
unpow299.9%
distribute-rgt-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around 0 99.9%
unpow299.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
Simplified99.9%
if 1.32e16 < a Initial program 32.7%
sub-neg32.7%
fma-def32.7%
fma-def39.2%
+-commutative39.2%
metadata-eval39.2%
Simplified39.2%
Taylor expanded in a around inf 95.4%
Final simplification97.2%
(FPCore (a b) :precision binary64 (if (or (<= a -9.5e+21) (not (<= a 7e+16))) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (* b (* b 12.0)) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -9.5e+21) || !(a <= 7e+16)) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * (b * 12.0)) + pow(b, 4.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-9.5d+21)) .or. (.not. (a <= 7d+16))) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * (b * 12.0d0)) + (b ** 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -9.5e+21) || !(a <= 7e+16)) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * (b * 12.0)) + Math.pow(b, 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -9.5e+21) or not (a <= 7e+16): tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * (b * 12.0)) + math.pow(b, 4.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -9.5e+21) || !(a <= 7e+16)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * Float64(b * 12.0)) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -9.5e+21) || ~((a <= 7e+16))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * (b * 12.0)) + (b ^ 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -9.5e+21], N[Not[LessEqual[a, 7e+16]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.5 \cdot 10^{+21} \lor \neg \left(a \leq 7 \cdot 10^{+16}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot \left(b \cdot 12\right) + {b}^{4}\right)\\
\end{array}
\end{array}
if a < -9.500000000000001e21 or 7e16 < a Initial program 49.9%
sub-neg49.9%
fma-def49.9%
fma-def53.0%
+-commutative53.0%
metadata-eval53.0%
Simplified53.0%
Taylor expanded in a around inf 95.3%
if -9.500000000000001e21 < a < 7e16Initial program 99.1%
sub-neg99.1%
fma-def99.1%
fma-def99.1%
+-commutative99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in a around 0 86.0%
associate-+r+86.0%
associate-*r*86.0%
distribute-rgt-out98.3%
metadata-eval98.3%
distribute-lft-in98.3%
unpow298.3%
distribute-rgt-in98.3%
metadata-eval98.3%
Simplified98.3%
Taylor expanded in a around 0 99.1%
unpow299.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
Simplified99.1%
Final simplification97.2%
(FPCore (a b) :precision binary64 (if (or (<= a -8.2e+21) (not (<= a 41000000000000.0))) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -8.2e+21) || !(a <= 41000000000000.0)) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-8.2d+21)) .or. (.not. (a <= 41000000000000.0d0))) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -8.2e+21) || !(a <= 41000000000000.0)) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -8.2e+21) or not (a <= 41000000000000.0): tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -8.2e+21) || !(a <= 41000000000000.0)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -8.2e+21) || ~((a <= 41000000000000.0))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -8.2e+21], N[Not[LessEqual[a, 41000000000000.0]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2 \cdot 10^{+21} \lor \neg \left(a \leq 41000000000000\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if a < -8.2e21 or 4.1e13 < a Initial program 49.9%
sub-neg49.9%
fma-def49.9%
fma-def53.0%
+-commutative53.0%
metadata-eval53.0%
Simplified53.0%
Taylor expanded in a around inf 95.3%
if -8.2e21 < a < 4.1e13Initial program 99.1%
sub-neg99.1%
fma-def99.1%
fma-def99.1%
+-commutative99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in a around 0 86.0%
associate-+r+86.0%
associate-*r*86.0%
distribute-rgt-out98.3%
metadata-eval98.3%
distribute-lft-in98.3%
unpow298.3%
distribute-rgt-in98.3%
metadata-eval98.3%
Simplified98.3%
Taylor expanded in a around 0 99.1%
unpow299.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
Simplified99.1%
+-commutative99.1%
metadata-eval99.1%
pow-prod-up99.0%
pow299.0%
pow299.0%
fma-def99.0%
Applied egg-rr99.0%
fma-udef99.0%
*-commutative99.0%
associate-*r*99.0%
distribute-rgt-out99.0%
Applied egg-rr99.0%
Final simplification97.2%
(FPCore (a b) :precision binary64 (if (or (<= a -1.8e+148) (not (<= a 6.6e+145))) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -1.8e+148) || !(a <= 6.6e+145)) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.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.8d+148)) .or. (.not. (a <= 6.6d+145))) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.8e+148) || !(a <= 6.6e+145)) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.8e+148) or not (a <= 6.6e+145): tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.8e+148) || !(a <= 6.6e+145)) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.8e+148) || ~((a <= 6.6e+145))) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.8e+148], N[Not[LessEqual[a, 6.6e+145]], $MachinePrecision]], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{+148} \lor \neg \left(a \leq 6.6 \cdot 10^{+145}\right):\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if a < -1.80000000000000003e148 or 6.60000000000000054e145 < a Initial program 33.3%
sub-neg33.3%
fma-def33.3%
fma-def33.3%
+-commutative33.3%
metadata-eval33.3%
Simplified33.3%
Taylor expanded in b around 0 52.2%
associate-*r*52.2%
unpow252.2%
Simplified52.2%
Taylor expanded in a around 0 92.4%
unpow292.4%
Simplified92.4%
if -1.80000000000000003e148 < a < 6.60000000000000054e145Initial program 90.2%
sub-neg90.2%
fma-def90.2%
fma-def92.3%
+-commutative92.3%
metadata-eval92.3%
Simplified92.3%
Taylor expanded in a around 0 67.1%
associate-+r+67.1%
associate-*r*67.1%
distribute-rgt-out75.6%
metadata-eval75.6%
distribute-lft-in75.6%
unpow275.6%
distribute-rgt-in75.6%
metadata-eval75.6%
Simplified75.6%
Taylor expanded in a around 0 81.0%
unpow281.0%
*-commutative81.0%
associate-*r*81.0%
*-commutative81.0%
Simplified81.0%
+-commutative81.0%
metadata-eval81.0%
pow-prod-up80.9%
pow280.9%
pow280.9%
fma-def80.9%
Applied egg-rr80.9%
fma-udef80.9%
*-commutative80.9%
associate-*r*80.9%
distribute-rgt-out80.9%
Applied egg-rr80.9%
Final simplification84.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+284) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+284) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.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) <= 5d+284) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+284) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+284: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+284) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+284) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+284], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+284}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999999e284Initial program 82.3%
sub-neg82.3%
fma-def82.3%
fma-def82.3%
+-commutative82.3%
metadata-eval82.3%
Simplified82.3%
Taylor expanded in b around 0 66.7%
associate-*r*66.7%
unpow266.7%
Simplified66.7%
Taylor expanded in a around 0 57.0%
unpow257.0%
Simplified57.0%
if 4.9999999999999999e284 < (*.f64 b b) Initial program 53.7%
sub-neg53.7%
fma-def53.7%
fma-def59.7%
+-commutative59.7%
metadata-eval59.7%
Simplified59.7%
Taylor expanded in b around 0 73.9%
fma-def73.9%
fma-def73.9%
unpow273.9%
distribute-lft-in73.9%
metadata-eval73.9%
unpow273.9%
associate-*r*73.9%
unpow273.9%
Simplified73.9%
Taylor expanded in a around inf 94.8%
Taylor expanded in a around 0 93.4%
unpow293.4%
Simplified93.4%
Final simplification66.5%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* a a) 4.0)))
double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((a * a) * 4.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
def code(a, b): return -1.0 + ((a * a) * 4.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(a * a) * 4.0)) end
function tmp = code(a, b) tmp = -1.0 + ((a * a) * 4.0); end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Initial program 74.9%
sub-neg74.9%
fma-def74.9%
fma-def76.4%
+-commutative76.4%
metadata-eval76.4%
Simplified76.4%
Taylor expanded in b around 0 55.0%
associate-*r*55.0%
unpow255.0%
Simplified55.0%
Taylor expanded in a around 0 50.0%
unpow250.0%
Simplified50.0%
Final simplification50.0%
herbie shell --seed 2023242
(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))