
(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 11 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.9%
associate--l+99.9%
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-def4.8%
+-commutative4.8%
metadata-eval4.8%
Simplified4.8%
Taylor expanded in a around inf 92.4%
Final simplification98.2%
(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.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 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def4.8%
+-commutative4.8%
metadata-eval4.8%
Simplified4.8%
Taylor expanded in a around inf 92.4%
Final simplification98.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 150.0) (+ -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 ((b * b) <= 150.0) {
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 ((b * b) <= 150.0d0) 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 ((b * b) <= 150.0) {
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 (b * b) <= 150.0: 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 (Float64(b * b) <= 150.0) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 150.0) 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[LessEqual[N[(b * b), $MachinePrecision], 150.0], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 150:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 150Initial program 84.9%
sub-neg84.9%
fma-def84.9%
fma-def84.9%
+-commutative84.9%
metadata-eval84.9%
Simplified84.9%
Taylor expanded in a around inf 98.2%
if 150 < (*.f64 b b) Initial program 65.8%
sub-neg65.8%
fma-def65.8%
fma-def68.2%
+-commutative68.2%
metadata-eval68.2%
Simplified68.2%
Taylor expanded in a around 0 69.5%
associate-+r+69.5%
associate-*r*69.5%
distribute-rgt-out76.8%
metadata-eval76.8%
distribute-lft-in76.8%
unpow276.8%
distribute-rgt-in76.8%
metadata-eval76.8%
Simplified76.8%
Taylor expanded in a around 0 89.2%
unpow289.2%
Simplified89.2%
Final simplification93.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 126.0) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 126.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 ((b * b) <= 126.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 ((b * b) <= 126.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 (b * b) <= 126.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 (Float64(b * b) <= 126.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 ((b * b) <= 126.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[LessEqual[N[(b * b), $MachinePrecision], 126.0], 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}\;b \cdot b \leq 126:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 126Initial program 84.9%
sub-neg84.9%
fma-def84.9%
fma-def84.9%
+-commutative84.9%
metadata-eval84.9%
Simplified84.9%
Taylor expanded in a around inf 98.2%
if 126 < (*.f64 b b) Initial program 65.8%
sub-neg65.8%
fma-def65.8%
fma-def68.2%
+-commutative68.2%
metadata-eval68.2%
Simplified68.2%
Taylor expanded in a around 0 69.5%
associate-+r+69.5%
associate-*r*69.5%
distribute-rgt-out76.8%
metadata-eval76.8%
distribute-lft-in76.8%
unpow276.8%
distribute-rgt-in76.8%
metadata-eval76.8%
Simplified76.8%
Taylor expanded in a around 0 89.2%
unpow289.2%
Simplified89.2%
sqr-pow89.1%
metadata-eval89.1%
pow289.1%
metadata-eval89.1%
pow289.1%
distribute-rgt-out89.1%
Applied egg-rr89.1%
Final simplification93.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1000000.0) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1000000.0) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.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 ((b * b) <= 1000000.0d0) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1000000.0) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1000000.0: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1000000.0) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1000000.0) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1000000.0], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 1000000:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1e6Initial program 84.4%
sub-neg84.4%
fma-def84.4%
fma-def84.4%
+-commutative84.4%
metadata-eval84.4%
Simplified84.4%
Taylor expanded in a around inf 97.5%
if 1e6 < (*.f64 b b) Initial program 66.0%
sub-neg66.0%
fma-def66.0%
fma-def68.5%
+-commutative68.5%
metadata-eval68.5%
Simplified68.5%
Taylor expanded in b around inf 89.8%
Final simplification93.9%
(FPCore (a b)
:precision binary64
(if (<= a -8.8e+74)
(+ -1.0 (/ (* (- 1.0 (* a a)) (* a (* a 4.0))) (+ a 1.0)))
(if (<= a 3.9e+130)
(+ -1.0 (* (* b b) (+ (* b b) 12.0)))
(+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -8.8e+74) {
tmp = -1.0 + (((1.0 - (a * a)) * (a * (a * 4.0))) / (a + 1.0));
} else if (a <= 3.9e+130) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + ((a * 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 <= (-8.8d+74)) then
tmp = (-1.0d0) + (((1.0d0 - (a * a)) * (a * (a * 4.0d0))) / (a + 1.0d0))
else if (a <= 3.9d+130) then
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
else
tmp = (-1.0d0) + ((a * a) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -8.8e+74) {
tmp = -1.0 + (((1.0 - (a * a)) * (a * (a * 4.0))) / (a + 1.0));
} else if (a <= 3.9e+130) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + ((a * a) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -8.8e+74: tmp = -1.0 + (((1.0 - (a * a)) * (a * (a * 4.0))) / (a + 1.0)) elif a <= 3.9e+130: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) else: tmp = -1.0 + ((a * a) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -8.8e+74) tmp = Float64(-1.0 + Float64(Float64(Float64(1.0 - Float64(a * a)) * Float64(a * Float64(a * 4.0))) / Float64(a + 1.0))); elseif (a <= 3.9e+130) tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); else tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -8.8e+74) tmp = -1.0 + (((1.0 - (a * a)) * (a * (a * 4.0))) / (a + 1.0)); elseif (a <= 3.9e+130) tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); else tmp = -1.0 + ((a * a) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -8.8e+74], N[(-1.0 + N[(N[(N[(1.0 - N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.9e+130], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.8 \cdot 10^{+74}:\\
\;\;\;\;-1 + \frac{\left(1 - a \cdot a\right) \cdot \left(a \cdot \left(a \cdot 4\right)\right)}{a + 1}\\
\mathbf{elif}\;a \leq 3.9 \cdot 10^{+130}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\end{array}
\end{array}
if a < -8.8000000000000005e74Initial program 63.1%
sub-neg63.1%
fma-def63.1%
fma-def63.1%
+-commutative63.1%
metadata-eval63.1%
Simplified63.1%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 92.9%
unpow292.9%
*-commutative92.9%
metadata-eval92.9%
swap-sqr92.9%
unpow292.9%
*-lft-identity92.9%
unpow392.9%
associate-*r*92.9%
metadata-eval92.9%
distribute-lft-neg-in92.9%
*-commutative92.9%
metadata-eval92.9%
swap-sqr92.9%
unpow292.9%
distribute-lft-neg-in92.9%
*-commutative92.9%
distribute-lft-neg-out92.9%
distribute-rgt-in92.9%
unpow292.9%
swap-sqr92.9%
metadata-eval92.9%
sub-neg92.9%
Simplified92.9%
*-un-lft-identity92.9%
cube-mult92.9%
distribute-rgt-out--92.9%
Applied egg-rr92.9%
associate-*r*92.9%
flip--92.9%
associate-*r/97.5%
*-commutative97.5%
metadata-eval97.5%
+-commutative97.5%
Applied egg-rr97.5%
*-commutative97.5%
associate-*l*97.5%
Simplified97.5%
if -8.8000000000000005e74 < a < 3.9000000000000002e130Initial program 94.9%
sub-neg94.9%
fma-def94.9%
fma-def96.6%
+-commutative96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in a around 0 79.7%
associate-+r+79.7%
associate-*r*79.7%
distribute-rgt-out84.7%
metadata-eval84.7%
distribute-lft-in84.7%
unpow284.7%
distribute-rgt-in84.7%
metadata-eval84.7%
Simplified84.7%
Taylor expanded in a around 0 87.5%
unpow287.5%
Simplified87.5%
sqr-pow87.5%
metadata-eval87.5%
pow287.5%
metadata-eval87.5%
pow287.5%
distribute-rgt-out87.5%
Applied egg-rr87.5%
if 3.9000000000000002e130 < a Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def0.0%
+-commutative0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in b around 0 0.0%
associate-*r*0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in a around 0 88.4%
unpow288.4%
Simplified88.4%
Final simplification89.1%
(FPCore (a b)
:precision binary64
(if (<= a -8.8e+74)
(+ -1.0 (* 4.0 (* (* a a) (- 1.0 a))))
(if (<= a 3.9e+130)
(+ -1.0 (* (* b b) (+ (* b b) 12.0)))
(+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -8.8e+74) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 3.9e+130) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + ((a * 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 <= (-8.8d+74)) then
tmp = (-1.0d0) + (4.0d0 * ((a * a) * (1.0d0 - a)))
else if (a <= 3.9d+130) then
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
else
tmp = (-1.0d0) + ((a * a) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -8.8e+74) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 3.9e+130) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + ((a * a) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -8.8e+74: tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))) elif a <= 3.9e+130: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) else: tmp = -1.0 + ((a * a) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -8.8e+74) tmp = Float64(-1.0 + Float64(4.0 * Float64(Float64(a * a) * Float64(1.0 - a)))); elseif (a <= 3.9e+130) tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); else tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -8.8e+74) tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))); elseif (a <= 3.9e+130) tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); else tmp = -1.0 + ((a * a) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -8.8e+74], N[(-1.0 + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.9e+130], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.8 \cdot 10^{+74}:\\
\;\;\;\;-1 + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\\
\mathbf{elif}\;a \leq 3.9 \cdot 10^{+130}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\end{array}
\end{array}
if a < -8.8000000000000005e74Initial program 63.1%
sub-neg63.1%
fma-def63.1%
fma-def63.1%
+-commutative63.1%
metadata-eval63.1%
Simplified63.1%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 92.9%
unpow292.9%
*-commutative92.9%
metadata-eval92.9%
swap-sqr92.9%
unpow292.9%
*-lft-identity92.9%
unpow392.9%
associate-*r*92.9%
metadata-eval92.9%
distribute-lft-neg-in92.9%
*-commutative92.9%
metadata-eval92.9%
swap-sqr92.9%
unpow292.9%
distribute-lft-neg-in92.9%
*-commutative92.9%
distribute-lft-neg-out92.9%
distribute-rgt-in92.9%
unpow292.9%
swap-sqr92.9%
metadata-eval92.9%
sub-neg92.9%
Simplified92.9%
*-un-lft-identity92.9%
cube-mult92.9%
distribute-rgt-out--92.9%
Applied egg-rr92.9%
if -8.8000000000000005e74 < a < 3.9000000000000002e130Initial program 94.9%
sub-neg94.9%
fma-def94.9%
fma-def96.6%
+-commutative96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in a around 0 79.7%
associate-+r+79.7%
associate-*r*79.7%
distribute-rgt-out84.7%
metadata-eval84.7%
distribute-lft-in84.7%
unpow284.7%
distribute-rgt-in84.7%
metadata-eval84.7%
Simplified84.7%
Taylor expanded in a around 0 87.5%
unpow287.5%
Simplified87.5%
sqr-pow87.5%
metadata-eval87.5%
pow287.5%
metadata-eval87.5%
pow287.5%
distribute-rgt-out87.5%
Applied egg-rr87.5%
if 3.9000000000000002e130 < a Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def0.0%
+-commutative0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in b around 0 0.0%
associate-*r*0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in a around 0 88.4%
unpow288.4%
Simplified88.4%
Final simplification88.4%
(FPCore (a b) :precision binary64 (if (<= a -7.6e+74) (+ -1.0 (* 4.0 (* (* a a) (- 1.0 a)))) (if (<= a 6.2e+124) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -7.6e+74) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6.2e+124) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + ((a * 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 <= (-7.6d+74)) then
tmp = (-1.0d0) + (4.0d0 * ((a * a) * (1.0d0 - a)))
else if (a <= 6.2d+124) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + ((a * a) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -7.6e+74) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6.2e+124) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + ((a * a) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -7.6e+74: tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))) elif a <= 6.2e+124: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + ((a * a) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -7.6e+74) tmp = Float64(-1.0 + Float64(4.0 * Float64(Float64(a * a) * Float64(1.0 - a)))); elseif (a <= 6.2e+124) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -7.6e+74) tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))); elseif (a <= 6.2e+124) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + ((a * a) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -7.6e+74], N[(-1.0 + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.2e+124], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.6 \cdot 10^{+74}:\\
\;\;\;\;-1 + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{+124}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\end{array}
\end{array}
if a < -7.5999999999999997e74Initial program 64.1%
sub-neg64.1%
fma-def64.1%
fma-def64.1%
+-commutative64.1%
metadata-eval64.1%
Simplified64.1%
Taylor expanded in b around 0 97.7%
associate-*r*97.7%
unpow297.7%
Simplified97.7%
Taylor expanded in a around 0 90.7%
unpow290.7%
*-commutative90.7%
metadata-eval90.7%
swap-sqr90.7%
unpow290.7%
*-lft-identity90.7%
unpow390.7%
associate-*r*90.7%
metadata-eval90.7%
distribute-lft-neg-in90.7%
*-commutative90.7%
metadata-eval90.7%
swap-sqr90.7%
unpow290.7%
distribute-lft-neg-in90.7%
*-commutative90.7%
distribute-lft-neg-out90.7%
distribute-rgt-in90.7%
unpow290.7%
swap-sqr90.7%
metadata-eval90.7%
sub-neg90.7%
Simplified90.7%
*-un-lft-identity90.7%
cube-mult90.7%
distribute-rgt-out--90.7%
Applied egg-rr90.7%
if -7.5999999999999997e74 < a < 6.2000000000000004e124Initial program 95.9%
sub-neg95.9%
fma-def95.9%
fma-def97.1%
+-commutative97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in a around 0 79.9%
associate-+r+79.9%
associate-*r*79.9%
distribute-rgt-out85.0%
metadata-eval85.0%
distribute-lft-in85.0%
unpow285.0%
distribute-rgt-in85.0%
metadata-eval85.0%
Simplified85.0%
Taylor expanded in a around 0 87.9%
unpow287.9%
Simplified87.9%
sqr-pow87.8%
metadata-eval87.8%
pow287.8%
metadata-eval87.8%
pow287.8%
distribute-rgt-out87.8%
Applied egg-rr87.8%
Taylor expanded in b around 0 64.2%
unpow264.2%
Simplified64.2%
if 6.2000000000000004e124 < a Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def2.4%
+-commutative2.4%
metadata-eval2.4%
Simplified2.4%
Taylor expanded in b around 0 0.0%
associate-*r*0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in a around 0 84.4%
unpow284.4%
Simplified84.4%
Final simplification71.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1.5e+307) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1.5e+307) {
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) <= 1.5d+307) 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) <= 1.5e+307) {
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) <= 1.5e+307: 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) <= 1.5e+307) 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) <= 1.5e+307) 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], 1.5e+307], 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 1.5 \cdot 10^{+307}:\\
\;\;\;\;-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) < 1.4999999999999999e307Initial program 80.5%
sub-neg80.5%
fma-def80.5%
fma-def81.0%
+-commutative81.0%
metadata-eval81.0%
Simplified81.0%
Taylor expanded in b around 0 61.7%
associate-*r*61.7%
unpow261.7%
Simplified61.7%
Taylor expanded in a around 0 59.8%
unpow259.8%
Simplified59.8%
if 1.4999999999999999e307 < (*.f64 b b) Initial program 58.2%
sub-neg58.2%
fma-def58.2%
fma-def61.8%
+-commutative61.8%
metadata-eval61.8%
Simplified61.8%
Taylor expanded in a around 0 63.6%
associate-+r+63.6%
associate-*r*63.6%
distribute-rgt-out80.0%
metadata-eval80.0%
distribute-lft-in80.0%
unpow280.0%
distribute-rgt-in80.0%
metadata-eval80.0%
Simplified80.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
distribute-rgt-out100.0%
Applied egg-rr100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification68.4%
(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 75.7%
sub-neg75.7%
fma-def75.7%
fma-def76.9%
+-commutative76.9%
metadata-eval76.9%
Simplified76.9%
Taylor expanded in b around 0 52.2%
associate-*r*52.2%
unpow252.2%
Simplified52.2%
Taylor expanded in a around 0 53.2%
unpow253.2%
Simplified53.2%
Final simplification53.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 75.7%
sub-neg75.7%
fma-def75.7%
fma-def76.9%
+-commutative76.9%
metadata-eval76.9%
Simplified76.9%
Taylor expanded in a around 0 61.9%
associate-+r+61.9%
associate-*r*61.9%
distribute-rgt-out65.5%
metadata-eval65.5%
distribute-lft-in65.5%
unpow265.5%
distribute-rgt-in65.5%
metadata-eval65.5%
Simplified65.5%
Taylor expanded in a around 0 71.3%
unpow271.3%
Simplified71.3%
Taylor expanded in b around 0 28.5%
Final simplification28.5%
herbie shell --seed 2023185
(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))