
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(if (<= (* b b) 5e-201)
(fma (pow a 2.0) (+ 4.0 (* a (+ a -4.0))) -1.0)
(+
(+
(* (pow a 2.0) 4.0)
(+ (* (pow b 2.0) (+ (pow b 2.0) (* 2.0 (pow a 2.0)))) (pow a 4.0)))
-1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-201) {
tmp = fma(pow(a, 2.0), (4.0 + (a * (a + -4.0))), -1.0);
} else {
tmp = ((pow(a, 2.0) * 4.0) + ((pow(b, 2.0) * (pow(b, 2.0) + (2.0 * pow(a, 2.0)))) + pow(a, 4.0))) + -1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-201) tmp = fma((a ^ 2.0), Float64(4.0 + Float64(a * Float64(a + -4.0))), -1.0); else tmp = Float64(Float64(Float64((a ^ 2.0) * 4.0) + Float64(Float64((b ^ 2.0) * Float64((b ^ 2.0) + Float64(2.0 * (a ^ 2.0)))) + (a ^ 4.0))) + -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-201], N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(N[Power[a, 2.0], $MachinePrecision] * 4.0), $MachinePrecision] + N[(N[(N[Power[b, 2.0], $MachinePrecision] * N[(N[Power[b, 2.0], $MachinePrecision] + N[(2.0 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-201}:\\
\;\;\;\;\mathsf{fma}\left({a}^{2}, 4 + a \cdot \left(a + -4\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left({a}^{2} \cdot 4 + \left({b}^{2} \cdot \left({b}^{2} + 2 \cdot {a}^{2}\right) + {a}^{4}\right)\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999999e-201Initial program 90.0%
associate--l+90.0%
fma-define90.0%
sqr-neg90.0%
fma-define90.0%
distribute-rgt-in90.0%
sqr-neg90.0%
distribute-rgt-in90.0%
fma-define90.0%
sqr-neg90.0%
Simplified90.0%
Taylor expanded in b around 0 90.0%
Taylor expanded in b around 0 90.1%
sub-neg90.1%
+-commutative90.1%
associate-*r*90.1%
*-commutative90.1%
metadata-eval90.1%
associate-+l+90.1%
+-commutative90.1%
associate-*r*90.1%
*-commutative90.1%
sub-neg90.1%
+-commutative90.1%
distribute-lft1-in90.1%
distribute-lft-neg-out90.1%
distribute-rgt-neg-in90.1%
metadata-eval90.1%
fma-define90.1%
Simplified90.1%
Taylor expanded in a around 0 99.9%
fma-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
if 4.9999999999999999e-201 < (*.f64 b b) Initial program 68.3%
associate--l+68.3%
fma-define68.3%
sqr-neg68.3%
fma-define68.3%
distribute-rgt-in68.3%
sqr-neg68.3%
distribute-rgt-in68.3%
fma-define68.3%
sqr-neg68.3%
Simplified71.4%
Taylor expanded in b around 0 80.8%
Taylor expanded in b around 0 80.8%
Taylor expanded in a around 0 98.4%
Final simplification98.9%
(FPCore (a b) :precision binary64 (if (<= a 1e+77) (+ (pow (fma a a (* b b)) 2.0) (+ (* 4.0 (* (pow a 2.0) (- 1.0 a))) -1.0)) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 1e+77) {
tmp = pow(fma(a, a, (b * b)), 2.0) + ((4.0 * (pow(a, 2.0) * (1.0 - a))) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= 1e+77) tmp = Float64((fma(a, a, Float64(b * b)) ^ 2.0) + Float64(Float64(4.0 * Float64((a ^ 2.0) * Float64(1.0 - a))) + -1.0)); else tmp = a ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[a, 1e+77], N[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(4.0 * N[(N[Power[a, 2.0], $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 10^{+77}:\\
\;\;\;\;{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 9.99999999999999983e76Initial program 89.0%
associate--l+89.0%
fma-define89.0%
sqr-neg89.0%
fma-define89.0%
distribute-rgt-in89.0%
sqr-neg89.0%
distribute-rgt-in89.0%
fma-define89.0%
sqr-neg89.0%
Simplified89.0%
Taylor expanded in b around 0 98.7%
if 9.99999999999999983e76 < a Initial program 11.6%
associate--l+11.6%
fma-define11.6%
sqr-neg11.6%
fma-define11.6%
distribute-rgt-in11.6%
sqr-neg11.6%
distribute-rgt-in11.6%
fma-define11.6%
sqr-neg11.6%
Simplified23.3%
Taylor expanded in a around inf 100.0%
Final simplification98.9%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (+ (* (- 1.0 a) (* a a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double t_0 = pow(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) + -1.0 return tmp
function code(a, b) t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(1.0 - a) * Float64(a * a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = (((b * b) + (a * a)) ^ 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(1.0 - a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(\left(1 - a\right) \cdot \left(a \cdot a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\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%
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%
Simplified8.2%
Taylor expanded in b around 0 37.7%
Taylor expanded in b around 0 37.7%
Taylor expanded in a around inf 90.7%
Final simplification97.6%
(FPCore (a b) :precision binary64 (if (<= b 3.2e+15) (+ (* (pow a 2.0) (+ 4.0 (* a (- a 4.0)))) -1.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 3.2e+15) {
tmp = (pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = pow(b, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3.2d+15) then
tmp = ((a ** 2.0d0) * (4.0d0 + (a * (a - 4.0d0)))) + (-1.0d0)
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3.2e+15) {
tmp = (Math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.2e+15: tmp = (math.pow(a, 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0 else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 3.2e+15) tmp = Float64(Float64((a ^ 2.0) * Float64(4.0 + Float64(a * Float64(a - 4.0)))) + -1.0); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.2e+15) tmp = ((a ^ 2.0) * (4.0 + (a * (a - 4.0)))) + -1.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.2e+15], N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{+15}:\\
\;\;\;\;{a}^{2} \cdot \left(4 + a \cdot \left(a - 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if b < 3.2e15Initial program 80.5%
associate--l+80.5%
fma-define80.5%
sqr-neg80.5%
fma-define80.5%
distribute-rgt-in80.5%
sqr-neg80.5%
distribute-rgt-in80.5%
fma-define80.5%
sqr-neg80.5%
Simplified81.0%
Taylor expanded in b around 0 84.8%
Taylor expanded in b around 0 63.5%
sub-neg63.5%
+-commutative63.5%
associate-*r*63.5%
*-commutative63.5%
metadata-eval63.5%
associate-+l+63.5%
+-commutative63.5%
associate-*r*63.5%
*-commutative63.5%
sub-neg63.5%
+-commutative63.5%
distribute-lft1-in63.5%
distribute-lft-neg-out63.5%
distribute-rgt-neg-in63.5%
metadata-eval63.5%
fma-define63.5%
Simplified63.5%
Taylor expanded in a around 0 77.2%
if 3.2e15 < b Initial program 61.5%
associate--l+61.5%
fma-define61.5%
sqr-neg61.5%
fma-define61.5%
distribute-rgt-in61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
fma-define61.5%
sqr-neg61.5%
Simplified68.2%
Taylor expanded in b around 0 81.5%
Taylor expanded in a around 0 86.6%
Final simplification79.4%
(FPCore (a b) :precision binary64 (if (or (<= a -1.95) (not (<= a 3.8e-5))) (pow a 4.0) (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0))))
double code(double a, double b) {
double tmp;
if ((a <= -1.95) || !(a <= 3.8e-5)) {
tmp = pow(a, 4.0);
} else {
tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-1.95d0)) .or. (.not. (a <= 3.8d-5))) then
tmp = a ** 4.0d0
else
tmp = (1.0d0 + (a * 2.0d0)) * ((a * 2.0d0) + (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.95) || !(a <= 3.8e-5)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.95) or not (a <= 3.8e-5): tmp = math.pow(a, 4.0) else: tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.95) || !(a <= 3.8e-5)) tmp = a ^ 4.0; else tmp = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.95) || ~((a <= 3.8e-5))) tmp = a ^ 4.0; else tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.95], N[Not[LessEqual[a, 3.8e-5]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.95 \lor \neg \left(a \leq 3.8 \cdot 10^{-5}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)\\
\end{array}
\end{array}
if a < -1.94999999999999996 or 3.8000000000000002e-5 < a Initial program 52.5%
associate--l+52.5%
fma-define52.5%
sqr-neg52.5%
fma-define52.5%
distribute-rgt-in52.5%
sqr-neg52.5%
distribute-rgt-in52.5%
fma-define52.5%
sqr-neg52.5%
Simplified56.4%
Taylor expanded in a around inf 82.6%
if -1.94999999999999996 < a < 3.8000000000000002e-5Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 97.9%
Taylor expanded in b around 0 55.0%
sub-neg55.0%
+-commutative55.0%
associate-*r*55.0%
*-commutative55.0%
metadata-eval55.0%
associate-+l+55.1%
+-commutative55.1%
associate-*r*55.1%
*-commutative55.1%
sub-neg55.1%
+-commutative55.1%
distribute-lft1-in55.1%
distribute-lft-neg-out55.1%
distribute-rgt-neg-in55.1%
metadata-eval55.1%
fma-define55.1%
Simplified55.1%
Taylor expanded in a around 0 54.4%
add-sqr-sqrt54.4%
difference-of-sqr-154.4%
*-commutative54.4%
sqrt-prod54.4%
sqrt-pow154.0%
metadata-eval54.0%
pow154.0%
metadata-eval54.0%
*-commutative54.0%
sqrt-prod54.0%
sqrt-pow154.4%
metadata-eval54.4%
pow154.4%
metadata-eval54.4%
Applied egg-rr54.4%
Final simplification68.6%
(FPCore (a b) :precision binary64 (if (<= b 3.2e+15) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 3.2e+15) {
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 <= 3.2d+15) 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 <= 3.2e+15) {
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 <= 3.2e+15: 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 (b <= 3.2e+15) 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 <= 3.2e+15) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.2e+15], 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 \leq 3.2 \cdot 10^{+15}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3.2e15Initial program 80.5%
associate--l+80.5%
fma-define80.5%
sqr-neg80.5%
fma-define80.5%
distribute-rgt-in80.5%
sqr-neg80.5%
distribute-rgt-in80.5%
fma-define80.5%
sqr-neg80.5%
Simplified81.0%
Taylor expanded in b around 0 84.8%
Taylor expanded in b around 0 82.8%
Taylor expanded in a around inf 76.4%
if 3.2e15 < b Initial program 61.5%
associate--l+61.5%
fma-define61.5%
sqr-neg61.5%
fma-define61.5%
distribute-rgt-in61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
fma-define61.5%
sqr-neg61.5%
Simplified68.2%
Taylor expanded in b around inf 86.6%
Final simplification78.8%
(FPCore (a b) :precision binary64 (if (<= b 3.2e+15) (+ (pow a 4.0) -1.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 3.2e+15) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3.2d+15) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3.2e+15) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.2e+15: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (b <= 3.2e+15) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.2e+15) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.2e+15], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{+15}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if b < 3.2e15Initial program 80.5%
associate--l+80.5%
fma-define80.5%
sqr-neg80.5%
fma-define80.5%
distribute-rgt-in80.5%
sqr-neg80.5%
distribute-rgt-in80.5%
fma-define80.5%
sqr-neg80.5%
Simplified81.0%
Taylor expanded in b around 0 84.8%
Taylor expanded in b around 0 82.8%
Taylor expanded in a around inf 76.4%
if 3.2e15 < b Initial program 61.5%
associate--l+61.5%
fma-define61.5%
sqr-neg61.5%
fma-define61.5%
distribute-rgt-in61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
fma-define61.5%
sqr-neg61.5%
Simplified68.2%
Taylor expanded in b around 0 81.5%
Taylor expanded in a around 0 86.6%
Final simplification78.8%
(FPCore (a b) :precision binary64 (if (<= b 75.0) (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 75.0) {
tmp = (1.0 + (a * 2.0)) * ((a * 2.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 <= 75.0d0) then
tmp = (1.0d0 + (a * 2.0d0)) * ((a * 2.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 <= 75.0) {
tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 75.0: tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 75.0) tmp = Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 75.0) tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 75.0], N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 75:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 75Initial program 80.3%
associate--l+80.3%
fma-define80.3%
sqr-neg80.3%
fma-define80.3%
distribute-rgt-in80.3%
sqr-neg80.3%
distribute-rgt-in80.3%
fma-define80.3%
sqr-neg80.3%
Simplified80.8%
Taylor expanded in b around 0 84.9%
Taylor expanded in b around 0 63.6%
sub-neg63.6%
+-commutative63.6%
associate-*r*63.6%
*-commutative63.6%
metadata-eval63.6%
associate-+l+63.7%
+-commutative63.7%
associate-*r*63.7%
*-commutative63.7%
sub-neg63.7%
+-commutative63.7%
distribute-lft1-in63.7%
distribute-lft-neg-out63.7%
distribute-rgt-neg-in63.7%
metadata-eval63.7%
fma-define63.7%
Simplified63.7%
Taylor expanded in a around 0 58.8%
add-sqr-sqrt58.8%
difference-of-sqr-158.8%
*-commutative58.8%
sqrt-prod58.8%
sqrt-pow148.4%
metadata-eval48.4%
pow148.4%
metadata-eval48.4%
*-commutative48.4%
sqrt-prod48.4%
sqrt-pow158.8%
metadata-eval58.8%
pow158.8%
metadata-eval58.8%
Applied egg-rr58.8%
if 75 < b Initial program 62.8%
associate--l+62.8%
fma-define62.8%
sqr-neg62.8%
fma-define62.8%
distribute-rgt-in62.8%
sqr-neg62.8%
distribute-rgt-in62.8%
fma-define62.8%
sqr-neg62.8%
Simplified69.2%
Taylor expanded in b around inf 84.6%
Final simplification65.0%
(FPCore (a b) :precision binary64 (* (+ 1.0 (* a 2.0)) (+ (* a 2.0) -1.0)))
double code(double a, double b) {
return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (1.0d0 + (a * 2.0d0)) * ((a * 2.0d0) + (-1.0d0))
end function
public static double code(double a, double b) {
return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0);
}
def code(a, b): return (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0)
function code(a, b) return Float64(Float64(1.0 + Float64(a * 2.0)) * Float64(Float64(a * 2.0) + -1.0)) end
function tmp = code(a, b) tmp = (1.0 + (a * 2.0)) * ((a * 2.0) + -1.0); end
code[a_, b_] := N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(a * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + a \cdot 2\right) \cdot \left(a \cdot 2 + -1\right)
\end{array}
Initial program 76.0%
associate--l+76.0%
fma-define76.0%
sqr-neg76.0%
fma-define76.0%
distribute-rgt-in76.0%
sqr-neg76.0%
distribute-rgt-in76.0%
fma-define76.0%
sqr-neg76.0%
Simplified78.0%
Taylor expanded in b around 0 84.0%
Taylor expanded in b around 0 54.4%
sub-neg54.4%
+-commutative54.4%
associate-*r*54.4%
*-commutative54.4%
metadata-eval54.4%
associate-+l+54.4%
+-commutative54.4%
associate-*r*54.4%
*-commutative54.4%
sub-neg54.4%
+-commutative54.4%
distribute-lft1-in54.4%
distribute-lft-neg-out54.4%
distribute-rgt-neg-in54.4%
metadata-eval54.4%
fma-define54.4%
Simplified54.4%
Taylor expanded in a around 0 48.4%
add-sqr-sqrt48.4%
difference-of-sqr-148.4%
*-commutative48.4%
sqrt-prod48.4%
sqrt-pow138.7%
metadata-eval38.7%
pow138.7%
metadata-eval38.7%
*-commutative38.7%
sqrt-prod38.7%
sqrt-pow148.4%
metadata-eval48.4%
pow148.4%
metadata-eval48.4%
Applied egg-rr48.4%
Final simplification48.4%
(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 76.0%
associate--l+76.0%
fma-define76.0%
sqr-neg76.0%
fma-define76.0%
distribute-rgt-in76.0%
sqr-neg76.0%
distribute-rgt-in76.0%
fma-define76.0%
sqr-neg76.0%
Simplified78.0%
Taylor expanded in b around 0 84.0%
Taylor expanded in b around 0 54.4%
sub-neg54.4%
+-commutative54.4%
associate-*r*54.4%
*-commutative54.4%
metadata-eval54.4%
associate-+l+54.4%
+-commutative54.4%
associate-*r*54.4%
*-commutative54.4%
sub-neg54.4%
+-commutative54.4%
distribute-lft1-in54.4%
distribute-lft-neg-out54.4%
distribute-rgt-neg-in54.4%
metadata-eval54.4%
fma-define54.4%
Simplified54.4%
Taylor expanded in a around 0 27.3%
Final simplification27.3%
herbie shell --seed 2024053
(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))