
(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 (<=
(+
(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-def8.3%
+-commutative8.3%
metadata-eval8.3%
Simplified8.3%
Taylor expanded in a around inf 92.1%
Final simplification97.8%
(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-def8.3%
+-commutative8.3%
metadata-eval8.3%
Simplified8.3%
Taylor expanded in a around inf 92.1%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+301) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
tmp = -1.0 + pow(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+301) then
tmp = (-1.0d0) + (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+301) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+301: tmp = -1.0 + math.pow(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+301) tmp = Float64(-1.0 + (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+301) tmp = -1.0 + (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+301], N[(-1.0 + N[Power[a, 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^{+301}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000004e301Initial program 76.5%
sub-neg76.5%
fma-def76.5%
fma-def78.1%
+-commutative78.1%
metadata-eval78.1%
Simplified78.1%
Taylor expanded in a around inf 81.5%
if 5.0000000000000004e301 < (*.f64 b b) Initial program 58.8%
sub-neg58.8%
fma-def58.8%
fma-def63.2%
+-commutative63.2%
metadata-eval63.2%
Simplified63.2%
Taylor expanded in a around 0 51.5%
associate-+r+51.5%
associate-*r*51.5%
distribute-rgt-out72.1%
metadata-eval72.1%
distribute-lft-in72.1%
unpow272.1%
distribute-rgt-in72.1%
metadata-eval72.1%
Simplified72.1%
Taylor expanded in b around 0 72.1%
+-commutative72.1%
fma-def72.1%
unpow272.1%
Simplified72.1%
Taylor expanded in a around 0 98.7%
unpow298.7%
Simplified98.7%
Final simplification86.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+80) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+80) {
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) <= 5d+80) 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) <= 5e+80) {
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) <= 5e+80: 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) <= 5e+80) 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) <= 5e+80) 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], 5e+80], 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 5 \cdot 10^{+80}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4.99999999999999961e80Initial program 85.1%
sub-neg85.1%
fma-def85.1%
fma-def85.1%
+-commutative85.1%
metadata-eval85.1%
Simplified85.1%
Taylor expanded in a around inf 96.1%
if 4.99999999999999961e80 < (*.f64 b b) Initial program 57.0%
sub-neg57.0%
fma-def57.0%
fma-def61.9%
+-commutative61.9%
metadata-eval61.9%
Simplified61.9%
Taylor expanded in b around inf 95.4%
Final simplification95.8%
(FPCore (a b) :precision binary64 (if (<= a -1020000000.0) (pow a 4.0) (if (<= a 2.95e+29) (+ -1.0 (* (* b b) 12.0)) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -1020000000.0) {
tmp = pow(a, 4.0);
} else if (a <= 2.95e+29) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1020000000.0d0)) then
tmp = a ** 4.0d0
else if (a <= 2.95d+29) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1020000000.0) {
tmp = Math.pow(a, 4.0);
} else if (a <= 2.95e+29) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1020000000.0: tmp = math.pow(a, 4.0) elif a <= 2.95e+29: tmp = -1.0 + ((b * b) * 12.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1020000000.0) tmp = a ^ 4.0; elseif (a <= 2.95e+29) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1020000000.0) tmp = a ^ 4.0; elseif (a <= 2.95e+29) tmp = -1.0 + ((b * b) * 12.0); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1020000000.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 2.95e+29], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1020000000:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 2.95 \cdot 10^{+29}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.02e9 or 2.9499999999999999e29 < a Initial program 41.8%
sub-neg41.8%
fma-def41.8%
fma-def46.7%
+-commutative46.7%
metadata-eval46.7%
Simplified46.7%
Taylor expanded in a around inf 89.9%
sqr-pow89.8%
metadata-eval89.8%
pow289.8%
metadata-eval89.8%
pow289.8%
fma-def89.8%
Applied egg-rr89.8%
Taylor expanded in a around inf 89.9%
if -1.02e9 < a < 2.9499999999999999e29Initial program 100.0%
sub-neg100.0%
fma-def100.0%
fma-def100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around 0 88.0%
associate-+r+88.0%
associate-*r*88.0%
distribute-rgt-out98.6%
metadata-eval98.6%
distribute-lft-in98.6%
unpow298.6%
distribute-rgt-in98.6%
metadata-eval98.6%
Simplified98.6%
Taylor expanded in b around 0 78.7%
+-commutative78.7%
fma-def78.7%
unpow278.7%
Simplified78.7%
Taylor expanded in a around 0 78.7%
unpow278.7%
Simplified78.7%
Final simplification84.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* a a) 4.0)))
(if (<= a -2.1e+64)
(+ -1.0 (/ (* (- 1.0 (* a a)) t_0) (+ a 1.0)))
(if (<= a 6.8e+153) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 t_0)))))
double code(double a, double b) {
double t_0 = (a * a) * 4.0;
double tmp;
if (a <= -2.1e+64) {
tmp = -1.0 + (((1.0 - (a * a)) * t_0) / (a + 1.0));
} else if (a <= 6.8e+153) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + t_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 <= (-2.1d+64)) then
tmp = (-1.0d0) + (((1.0d0 - (a * a)) * t_0) / (a + 1.0d0))
else if (a <= 6.8d+153) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + t_0
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 <= -2.1e+64) {
tmp = -1.0 + (((1.0 - (a * a)) * t_0) / (a + 1.0));
} else if (a <= 6.8e+153) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + t_0;
}
return tmp;
}
def code(a, b): t_0 = (a * a) * 4.0 tmp = 0 if a <= -2.1e+64: tmp = -1.0 + (((1.0 - (a * a)) * t_0) / (a + 1.0)) elif a <= 6.8e+153: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + t_0 return tmp
function code(a, b) t_0 = Float64(Float64(a * a) * 4.0) tmp = 0.0 if (a <= -2.1e+64) tmp = Float64(-1.0 + Float64(Float64(Float64(1.0 - Float64(a * a)) * t_0) / Float64(a + 1.0))); elseif (a <= 6.8e+153) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + t_0); end return tmp end
function tmp_2 = code(a, b) t_0 = (a * a) * 4.0; tmp = 0.0; if (a <= -2.1e+64) tmp = -1.0 + (((1.0 - (a * a)) * t_0) / (a + 1.0)); elseif (a <= 6.8e+153) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]}, If[LessEqual[a, -2.1e+64], N[(-1.0 + N[(N[(N[(1.0 - N[(a * a), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.8e+153], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(a \cdot a\right) \cdot 4\\
\mathbf{if}\;a \leq -2.1 \cdot 10^{+64}:\\
\;\;\;\;-1 + \frac{\left(1 - a \cdot a\right) \cdot t_0}{a + 1}\\
\mathbf{elif}\;a \leq 6.8 \cdot 10^{+153}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + t_0\\
\end{array}
\end{array}
if a < -2.1e64Initial program 56.8%
sub-neg56.8%
fma-def56.8%
fma-def56.8%
+-commutative56.8%
metadata-eval56.8%
Simplified56.8%
Taylor expanded in b around 0 98.2%
associate-*r*98.2%
unpow298.2%
Simplified98.2%
Taylor expanded in a around 0 89.0%
unpow289.0%
*-commutative89.0%
associate-*r*89.0%
metadata-eval89.0%
cancel-sign-sub-inv89.0%
unpow389.0%
associate-*l*89.0%
*-commutative89.0%
associate-*r*89.0%
unsub-neg89.0%
*-rgt-identity89.0%
distribute-rgt-neg-out89.0%
distribute-lft-in89.0%
associate-*r*89.0%
*-commutative89.0%
sub-neg89.0%
associate-*r*89.0%
sub-neg89.0%
distribute-lft-in89.0%
distribute-rgt-neg-in89.0%
unpow389.0%
unsub-neg89.0%
Simplified89.0%
*-un-lft-identity89.0%
cube-mult89.0%
distribute-rgt-out--89.0%
Applied egg-rr89.0%
associate-*r*89.0%
flip--89.0%
associate-*r/92.6%
*-commutative92.6%
metadata-eval92.6%
+-commutative92.6%
Applied egg-rr92.6%
if -2.1e64 < a < 6.7999999999999995e153Initial program 91.1%
sub-neg91.1%
fma-def91.1%
fma-def94.6%
+-commutative94.6%
metadata-eval94.6%
Simplified94.6%
Taylor expanded in a around 0 76.1%
associate-+r+76.1%
associate-*r*76.1%
distribute-rgt-out84.3%
metadata-eval84.3%
distribute-lft-in84.3%
unpow284.3%
distribute-rgt-in84.3%
metadata-eval84.3%
Simplified84.3%
Taylor expanded in b around 0 67.7%
+-commutative67.7%
fma-def67.7%
unpow267.7%
Simplified67.7%
Taylor expanded in a around 0 67.6%
unpow267.6%
Simplified67.6%
if 6.7999999999999995e153 < 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 simplification77.0%
(FPCore (a b) :precision binary64 (if (<= a -6.2e+80) (+ -1.0 (* 4.0 (* (* a a) (- 1.0 a)))) (if (<= a 6.1e+153) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -6.2e+80) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6.1e+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 <= (-6.2d+80)) then
tmp = (-1.0d0) + (4.0d0 * ((a * a) * (1.0d0 - a)))
else if (a <= 6.1d+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 <= -6.2e+80) {
tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a)));
} else if (a <= 6.1e+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 <= -6.2e+80: tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))) elif a <= 6.1e+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 <= -6.2e+80) tmp = Float64(-1.0 + Float64(4.0 * Float64(Float64(a * a) * Float64(1.0 - a)))); elseif (a <= 6.1e+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 <= -6.2e+80) tmp = -1.0 + (4.0 * ((a * a) * (1.0 - a))); elseif (a <= 6.1e+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, -6.2e+80], N[(-1.0 + N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.1e+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 -6.2 \cdot 10^{+80}:\\
\;\;\;\;-1 + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\\
\mathbf{elif}\;a \leq 6.1 \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 < -6.19999999999999976e80Initial program 54.3%
sub-neg54.3%
fma-def54.3%
fma-def54.3%
+-commutative54.3%
metadata-eval54.3%
Simplified54.3%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 98.0%
unpow298.0%
*-commutative98.0%
associate-*r*98.0%
metadata-eval98.0%
cancel-sign-sub-inv98.0%
unpow398.0%
associate-*l*98.0%
*-commutative98.0%
associate-*r*98.0%
unsub-neg98.0%
*-rgt-identity98.0%
distribute-rgt-neg-out98.0%
distribute-lft-in98.0%
associate-*r*98.0%
*-commutative98.0%
sub-neg98.0%
associate-*r*98.0%
sub-neg98.0%
distribute-lft-in98.0%
distribute-rgt-neg-in98.0%
unpow398.0%
unsub-neg98.0%
Simplified98.0%
*-un-lft-identity98.0%
cube-mult98.0%
distribute-rgt-out--98.0%
Applied egg-rr98.0%
if -6.19999999999999976e80 < a < 6.0999999999999998e153Initial program 90.8%
sub-neg90.8%
fma-def90.8%
fma-def94.2%
+-commutative94.2%
metadata-eval94.2%
Simplified94.2%
Taylor expanded in a around 0 74.5%
associate-+r+74.5%
associate-*r*74.5%
distribute-rgt-out82.5%
metadata-eval82.5%
distribute-lft-in82.5%
unpow282.5%
distribute-rgt-in82.5%
metadata-eval82.5%
Simplified82.5%
Taylor expanded in b around 0 65.8%
+-commutative65.8%
fma-def65.8%
unpow265.8%
Simplified65.8%
Taylor expanded in a around 0 66.3%
unpow266.3%
Simplified66.3%
if 6.0999999999999998e153 < 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 simplification76.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+301) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+301) {
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+301) 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+301) {
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+301: 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+301) 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+301) 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+301], 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^{+301}:\\
\;\;\;\;-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) < 5.0000000000000004e301Initial program 76.5%
sub-neg76.5%
fma-def76.5%
fma-def78.1%
+-commutative78.1%
metadata-eval78.1%
Simplified78.1%
Taylor expanded in b around 0 63.9%
associate-*r*63.9%
unpow263.9%
Simplified63.9%
Taylor expanded in a around 0 63.3%
unpow263.3%
Simplified63.3%
if 5.0000000000000004e301 < (*.f64 b b) Initial program 58.8%
sub-neg58.8%
fma-def58.8%
fma-def63.2%
+-commutative63.2%
metadata-eval63.2%
Simplified63.2%
Taylor expanded in a around 0 51.5%
associate-+r+51.5%
associate-*r*51.5%
distribute-rgt-out72.1%
metadata-eval72.1%
distribute-lft-in72.1%
unpow272.1%
distribute-rgt-in72.1%
metadata-eval72.1%
Simplified72.1%
Taylor expanded in b around 0 72.1%
+-commutative72.1%
fma-def72.1%
unpow272.1%
Simplified72.1%
Taylor expanded in a around 0 98.7%
unpow298.7%
Simplified98.7%
Final simplification72.7%
(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 71.8%
sub-neg71.8%
fma-def71.8%
fma-def74.2%
+-commutative74.2%
metadata-eval74.2%
Simplified74.2%
Taylor expanded in b around 0 53.1%
associate-*r*53.1%
unpow253.1%
Simplified53.1%
Taylor expanded in a around 0 52.5%
unpow252.5%
Simplified52.5%
Final simplification52.5%
(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 71.8%
sub-neg71.8%
fma-def71.8%
fma-def74.2%
+-commutative74.2%
metadata-eval74.2%
Simplified74.2%
Taylor expanded in a around inf 69.6%
Taylor expanded in a around 0 26.2%
Final simplification26.2%
herbie shell --seed 2023181
(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))