
(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-def5.5%
+-commutative5.5%
metadata-eval5.5%
Simplified5.5%
Taylor expanded in a around inf 91.6%
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.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-def5.5%
+-commutative5.5%
metadata-eval5.5%
Simplified5.5%
Taylor expanded in a around inf 91.6%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+48) (+ -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) <= 2e+48) {
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) <= 2d+48) 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) <= 2e+48) {
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) <= 2e+48: 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) <= 2e+48) 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) <= 2e+48) 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], 2e+48], 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 2 \cdot 10^{+48}:\\
\;\;\;\;-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) < 2.00000000000000009e48Initial 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 95.9%
if 2.00000000000000009e48 < (*.f64 b b) Initial program 72.1%
sub-neg72.1%
fma-def72.1%
fma-def74.5%
+-commutative74.5%
metadata-eval74.5%
Simplified74.5%
Taylor expanded in a around 0 66.1%
associate-+r+66.1%
associate-*r*66.1%
distribute-rgt-out78.8%
metadata-eval78.8%
distribute-lft-in78.8%
unpow278.8%
distribute-rgt-in78.8%
metadata-eval78.8%
Simplified78.8%
Taylor expanded in a around 0 94.0%
unpow294.0%
Simplified94.0%
sqr-pow93.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
distribute-rgt-out93.9%
Applied egg-rr93.9%
Final simplification94.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+48) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+48) {
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) <= 2d+48) 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) <= 2e+48) {
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) <= 2e+48: 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) <= 2e+48) 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) <= 2e+48) 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], 2e+48], 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 2 \cdot 10^{+48}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.00000000000000009e48Initial 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 95.9%
if 2.00000000000000009e48 < (*.f64 b b) Initial program 72.1%
sub-neg72.1%
fma-def72.1%
fma-def74.5%
+-commutative74.5%
metadata-eval74.5%
Simplified74.5%
Taylor expanded in b around inf 94.0%
Final simplification95.0%
(FPCore (a b)
:precision binary64
(if (<= a -3.6e+102)
(+ -1.0 (* 4.0 (* (* a a) (- 1.0 a))))
(if (<= a 6.6e+153)
(+ -1.0 (* (* b b) (+ (* b b) 12.0)))
(+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -3.6e+102) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6.6e+153) {
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 <= (-3.6d+102)) then
tmp = (-1.0d0) + (4.0d0 * ((a * a) * (1.0d0 - a)))
else if (a <= 6.6d+153) 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 <= -3.6e+102) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6.6e+153) {
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 <= -3.6e+102: tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))) elif a <= 6.6e+153: 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 <= -3.6e+102) tmp = Float64(-1.0 + Float64(4.0 * Float64(Float64(a * a) * Float64(1.0 - a)))); elseif (a <= 6.6e+153) 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 <= -3.6e+102) tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))); elseif (a <= 6.6e+153) 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, -3.6e+102], N[(-1.0 + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.6e+153], 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 -3.6 \cdot 10^{+102}:\\
\;\;\;\;-1 + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\\
\mathbf{elif}\;a \leq 6.6 \cdot 10^{+153}:\\
\;\;\;\;-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 < -3.6000000000000002e102Initial program 67.6%
sub-neg67.6%
fma-def67.6%
fma-def67.6%
+-commutative67.6%
metadata-eval67.6%
Simplified67.6%
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%
*-commutative100.0%
metadata-eval100.0%
swap-sqr100.0%
unpow2100.0%
*-lft-identity100.0%
unpow3100.0%
associate-*r*100.0%
metadata-eval100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
metadata-eval100.0%
swap-sqr100.0%
unpow2100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-in100.0%
unpow2100.0%
swap-sqr100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
associate-*r*100.0%
Simplified100.0%
*-un-lft-identity100.0%
cube-mult100.0%
distribute-rgt-out--100.0%
Applied egg-rr100.0%
if -3.6000000000000002e102 < a < 6.59999999999999989e153Initial program 91.9%
sub-neg91.9%
fma-def91.9%
fma-def93.5%
+-commutative93.5%
metadata-eval93.5%
Simplified93.5%
Taylor expanded in a around 0 69.6%
associate-+r+69.6%
associate-*r*69.6%
distribute-rgt-out78.0%
metadata-eval78.0%
distribute-lft-in78.0%
unpow278.0%
distribute-rgt-in78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in a around 0 83.2%
unpow283.2%
Simplified83.2%
sqr-pow83.1%
metadata-eval83.1%
pow283.1%
metadata-eval83.1%
pow283.1%
distribute-rgt-out83.1%
Applied egg-rr83.1%
if 6.59999999999999989e153 < 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 100.0%
unpow2100.0%
Simplified100.0%
Final simplification87.4%
(FPCore (a b) :precision binary64 (if (<= a -4.4e+98) (+ -1.0 (* 4.0 (* (* a a) (- 1.0 a)))) (if (<= a 6e+153) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -4.4e+98) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6e+153) {
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 <= (-4.4d+98)) then
tmp = (-1.0d0) + (4.0d0 * ((a * a) * (1.0d0 - a)))
else if (a <= 6d+153) 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 <= -4.4e+98) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6e+153) {
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 <= -4.4e+98: tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))) elif a <= 6e+153: 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 <= -4.4e+98) tmp = Float64(-1.0 + Float64(4.0 * Float64(Float64(a * a) * Float64(1.0 - a)))); elseif (a <= 6e+153) 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 <= -4.4e+98) tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))); elseif (a <= 6e+153) 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, -4.4e+98], N[(-1.0 + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6e+153], 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 -4.4 \cdot 10^{+98}:\\
\;\;\;\;-1 + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\\
\mathbf{elif}\;a \leq 6 \cdot 10^{+153}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\end{array}
\end{array}
if a < -4.40000000000000017e98Initial program 68.4%
sub-neg68.4%
fma-def68.4%
fma-def68.4%
+-commutative68.4%
metadata-eval68.4%
Simplified68.4%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 97.7%
unpow297.7%
*-commutative97.7%
metadata-eval97.7%
swap-sqr97.7%
unpow297.7%
*-lft-identity97.7%
unpow397.7%
associate-*r*97.7%
metadata-eval97.7%
distribute-lft-neg-in97.7%
*-commutative97.7%
metadata-eval97.7%
swap-sqr97.7%
unpow297.7%
distribute-lft-neg-in97.7%
*-commutative97.7%
distribute-lft-neg-out97.7%
distribute-rgt-in97.7%
unpow297.7%
swap-sqr97.7%
metadata-eval97.7%
*-commutative97.7%
sub-neg97.7%
associate-*r*97.7%
Simplified97.7%
*-un-lft-identity97.7%
cube-mult97.7%
distribute-rgt-out--97.7%
Applied egg-rr97.7%
if -4.40000000000000017e98 < a < 6.00000000000000037e153Initial program 91.9%
sub-neg91.9%
fma-def91.9%
fma-def93.5%
+-commutative93.5%
metadata-eval93.5%
Simplified93.5%
Taylor expanded in a around 0 69.4%
associate-+r+69.4%
associate-*r*69.4%
distribute-rgt-out77.8%
metadata-eval77.8%
distribute-lft-in77.8%
unpow277.8%
distribute-rgt-in77.8%
metadata-eval77.8%
Simplified77.8%
Taylor expanded in a around 0 83.1%
unpow283.1%
Simplified83.1%
sqr-pow83.0%
metadata-eval83.0%
pow283.0%
metadata-eval83.0%
pow283.0%
distribute-rgt-out83.0%
Applied egg-rr83.0%
Taylor expanded in b around 0 54.3%
unpow254.3%
Simplified54.3%
if 6.00000000000000037e153 < 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 100.0%
unpow2100.0%
Simplified100.0%
Final simplification65.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+228) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+228) {
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) <= 1d+228) 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) <= 1e+228) {
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) <= 1e+228: 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) <= 1e+228) 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) <= 1e+228) 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], 1e+228], 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 10^{+228}:\\
\;\;\;\;-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) < 9.9999999999999992e227Initial program 83.0%
sub-neg83.0%
fma-def83.0%
fma-def83.0%
+-commutative83.0%
metadata-eval83.0%
Simplified83.0%
Taylor expanded in b around 0 65.8%
associate-*r*65.8%
unpow265.8%
Simplified65.8%
Taylor expanded in a around 0 58.0%
unpow258.0%
Simplified58.0%
if 9.9999999999999992e227 < (*.f64 b b) Initial program 67.5%
sub-neg67.5%
fma-def67.5%
fma-def71.4%
+-commutative71.4%
metadata-eval71.4%
Simplified71.4%
Taylor expanded in a around 0 58.4%
associate-+r+58.4%
associate-*r*58.4%
distribute-rgt-out79.2%
metadata-eval79.2%
distribute-lft-in79.2%
unpow279.2%
distribute-rgt-in79.2%
metadata-eval79.2%
Simplified79.2%
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 72.4%
unpow272.4%
Simplified72.4%
Final simplification62.3%
(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 78.4%
sub-neg78.4%
fma-def78.4%
fma-def79.5%
+-commutative79.5%
metadata-eval79.5%
Simplified79.5%
Taylor expanded in b around 0 51.2%
associate-*r*51.2%
unpow251.2%
Simplified51.2%
Taylor expanded in a around 0 45.1%
unpow245.1%
Simplified45.1%
Final simplification45.1%
(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 78.4%
sub-neg78.4%
fma-def78.4%
fma-def79.5%
+-commutative79.5%
metadata-eval79.5%
Simplified79.5%
Taylor expanded in a around 0 55.6%
associate-+r+55.6%
associate-*r*55.6%
distribute-rgt-out61.9%
metadata-eval61.9%
distribute-lft-in61.9%
unpow261.9%
distribute-rgt-in61.9%
metadata-eval61.9%
Simplified61.9%
Taylor expanded in a around 0 69.4%
unpow269.4%
Simplified69.4%
Taylor expanded in b around 0 21.9%
Final simplification21.9%
herbie shell --seed 2023255
(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))