
(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 (+ (+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (+ (* a a) (* (* b b) 3.0)))) -1.0))
double code(double a, double b) {
return (pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * 3.0d0)))) + (-1.0d0)
end function
public static double code(double a, double b) {
return (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0;
}
def code(a, b): return (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0
function code(a, b) return Float64(Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * 3.0)))) + -1.0) end
function tmp = code(a, b) tmp = ((((b * b) + (a * a)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * 3.0)))) + -1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right)\right) + -1
\end{array}
Initial program 71.8%
Taylor expanded in a around 0 90.7%
Taylor expanded in a around 0 99.3%
Final simplification99.3%
(FPCore (a b)
:precision binary64
(if (<= a -1.05e+14)
(+ (+ (* 4.0 (+ (* a a) (* (* b b) 3.0))) (pow a 4.0)) -1.0)
(if (<= a 1.6e+24)
(+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)
(+ (+ (pow a 4.0) (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0))))) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= -1.05e+14) {
tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + pow(a, 4.0)) + -1.0;
} else if (a <= 1.6e+24) {
tmp = (((b * b) * 12.0) + pow(b, 4.0)) + -1.0;
} else {
tmp = (pow(a, 4.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.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.05d+14)) then
tmp = ((4.0d0 * ((a * a) + ((b * b) * 3.0d0))) + (a ** 4.0d0)) + (-1.0d0)
else if (a <= 1.6d+24) then
tmp = (((b * b) * 12.0d0) + (b ** 4.0d0)) + (-1.0d0)
else
tmp = ((a ** 4.0d0) + (4.0d0 * ((a * a) + ((b * b) * (a + 3.0d0))))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.05e+14) {
tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + Math.pow(a, 4.0)) + -1.0;
} else if (a <= 1.6e+24) {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
} else {
tmp = (Math.pow(a, 4.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.05e+14: tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + math.pow(a, 4.0)) + -1.0 elif a <= 1.6e+24: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 else: tmp = (math.pow(a, 4.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -1.05e+14) tmp = Float64(Float64(Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * 3.0))) + (a ^ 4.0)) + -1.0); elseif (a <= 1.6e+24) tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); else tmp = Float64(Float64((a ^ 4.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.05e+14) tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + (a ^ 4.0)) + -1.0; elseif (a <= 1.6e+24) tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; else tmp = ((a ^ 4.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.05e+14], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 1.6e+24], N[(N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[Power[a, 4.0], $MachinePrecision] + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.05 \cdot 10^{+14}:\\
\;\;\;\;\left(4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right) + {a}^{4}\right) + -1\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{+24}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left({a}^{4} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\
\end{array}
\end{array}
if a < -1.05e14Initial program 58.5%
Taylor expanded in a around 0 58.5%
Taylor expanded in a around 0 100.0%
Taylor expanded in a around inf 97.2%
if -1.05e14 < a < 1.5999999999999999e24Initial 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 a around 0 97.6%
pow297.6%
Applied egg-rr97.6%
if 1.5999999999999999e24 < a Initial program 33.3%
Taylor expanded in a around 0 100.0%
Taylor expanded in a around inf 98.2%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (or (<= a -2.1e+15) (not (<= a 1.6e+24))) (+ (+ (* 4.0 (+ (* a a) (* (* b b) 3.0))) (pow a 4.0)) -1.0) (+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.1e+15) || !(a <= 1.6e+24)) {
tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + pow(a, 4.0)) + -1.0;
} else {
tmp = (((b * b) * 12.0) + 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 ((a <= (-2.1d+15)) .or. (.not. (a <= 1.6d+24))) then
tmp = ((4.0d0 * ((a * a) + ((b * b) * 3.0d0))) + (a ** 4.0d0)) + (-1.0d0)
else
tmp = (((b * b) * 12.0d0) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.1e+15) || !(a <= 1.6e+24)) {
tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + Math.pow(a, 4.0)) + -1.0;
} else {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.1e+15) or not (a <= 1.6e+24): tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + math.pow(a, 4.0)) + -1.0 else: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.1e+15) || !(a <= 1.6e+24)) tmp = Float64(Float64(Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * 3.0))) + (a ^ 4.0)) + -1.0); else tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.1e+15) || ~((a <= 1.6e+24))) tmp = ((4.0 * ((a * a) + ((b * b) * 3.0))) + (a ^ 4.0)) + -1.0; else tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.1e+15], N[Not[LessEqual[a, 1.6e+24]], $MachinePrecision]], N[(N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.1 \cdot 10^{+15} \lor \neg \left(a \leq 1.6 \cdot 10^{+24}\right):\\
\;\;\;\;\left(4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot 3\right) + {a}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if a < -2.1e15 or 1.5999999999999999e24 < a Initial program 43.7%
Taylor expanded in a around 0 82.8%
Taylor expanded in a around 0 100.0%
Taylor expanded in a around inf 96.4%
if -2.1e15 < a < 1.5999999999999999e24Initial 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 a around 0 97.6%
pow297.6%
Applied egg-rr97.6%
Final simplification97.0%
(FPCore (a b) :precision binary64 (if (or (<= a -1e+39) (not (<= a 2.05e+24))) (* a (pow a 3.0)) (+ (+ (* (* b b) 12.0) (pow b 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -1e+39) || !(a <= 2.05e+24)) {
tmp = a * pow(a, 3.0);
} else {
tmp = (((b * b) * 12.0) + 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 ((a <= (-1d+39)) .or. (.not. (a <= 2.05d+24))) then
tmp = a * (a ** 3.0d0)
else
tmp = (((b * b) * 12.0d0) + (b ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1e+39) || !(a <= 2.05e+24)) {
tmp = a * Math.pow(a, 3.0);
} else {
tmp = (((b * b) * 12.0) + Math.pow(b, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1e+39) or not (a <= 2.05e+24): tmp = a * math.pow(a, 3.0) else: tmp = (((b * b) * 12.0) + math.pow(b, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -1e+39) || !(a <= 2.05e+24)) tmp = Float64(a * (a ^ 3.0)); else tmp = Float64(Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1e+39) || ~((a <= 2.05e+24))) tmp = a * (a ^ 3.0); else tmp = (((b * b) * 12.0) + (b ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1e+39], N[Not[LessEqual[a, 2.05e+24]], $MachinePrecision]], N[(a * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+39} \lor \neg \left(a \leq 2.05 \cdot 10^{+24}\right):\\
\;\;\;\;a \cdot {a}^{3}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\
\end{array}
\end{array}
if a < -9.9999999999999994e38 or 2.05e24 < a Initial program 43.5%
associate--l+43.5%
fma-define43.5%
sqr-neg43.5%
fma-define43.5%
distribute-rgt-in43.5%
sqr-neg43.5%
distribute-rgt-in43.5%
fma-define43.5%
sqr-neg43.5%
Simplified49.2%
Taylor expanded in a around inf 95.5%
associate-*r/95.5%
metadata-eval95.5%
Simplified95.5%
Taylor expanded in a around 0 95.5%
Taylor expanded in a around inf 95.5%
if -9.9999999999999994e38 < a < 2.05e24Initial program 98.4%
associate--l+98.4%
fma-define98.4%
sqr-neg98.4%
fma-define98.4%
distribute-rgt-in98.4%
sqr-neg98.4%
distribute-rgt-in98.4%
fma-define98.4%
sqr-neg98.4%
Simplified98.4%
Taylor expanded in a around 0 96.9%
pow296.9%
Applied egg-rr96.9%
Final simplification96.2%
(FPCore (a b) :precision binary64 (if (or (<= a -2.7e+39) (not (<= a 2.15e+24))) (* a (pow a 3.0)) (+ (* b (* b (fma b b 12.0))) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.7e+39) || !(a <= 2.15e+24)) {
tmp = a * pow(a, 3.0);
} else {
tmp = (b * (b * fma(b, b, 12.0))) + -1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -2.7e+39) || !(a <= 2.15e+24)) tmp = Float64(a * (a ^ 3.0)); else tmp = Float64(Float64(b * Float64(b * fma(b, b, 12.0))) + -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -2.7e+39], N[Not[LessEqual[a, 2.15e+24]], $MachinePrecision]], N[(a * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(b * N[(b * b + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.7 \cdot 10^{+39} \lor \neg \left(a \leq 2.15 \cdot 10^{+24}\right):\\
\;\;\;\;a \cdot {a}^{3}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 12\right)\right) + -1\\
\end{array}
\end{array}
if a < -2.70000000000000003e39 or 2.14999999999999994e24 < a Initial program 43.5%
associate--l+43.5%
fma-define43.5%
sqr-neg43.5%
fma-define43.5%
distribute-rgt-in43.5%
sqr-neg43.5%
distribute-rgt-in43.5%
fma-define43.5%
sqr-neg43.5%
Simplified49.2%
Taylor expanded in a around inf 95.5%
associate-*r/95.5%
metadata-eval95.5%
Simplified95.5%
Taylor expanded in a around 0 95.5%
Taylor expanded in a around inf 95.5%
if -2.70000000000000003e39 < a < 2.14999999999999994e24Initial program 98.4%
associate--l+98.4%
fma-define98.4%
sqr-neg98.4%
fma-define98.4%
distribute-rgt-in98.4%
sqr-neg98.4%
distribute-rgt-in98.4%
fma-define98.4%
sqr-neg98.4%
Simplified98.4%
Taylor expanded in a around 0 96.9%
pow296.9%
Applied egg-rr96.9%
metadata-eval96.9%
pow-prod-up96.8%
pow-prod-down96.8%
pow296.8%
distribute-rgt-in96.9%
*-commutative96.9%
associate-*r*96.9%
+-commutative96.9%
fma-define96.9%
Applied egg-rr96.9%
Final simplification96.2%
(FPCore (a b) :precision binary64 (if (or (<= a -1.5e+40) (not (<= a 1.55e+25))) (* a (pow a 3.0)) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -1.5e+40) || !(a <= 1.55e+25)) {
tmp = a * pow(a, 3.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 ((a <= (-1.5d+40)) .or. (.not. (a <= 1.55d+25))) then
tmp = a * (a ** 3.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 ((a <= -1.5e+40) || !(a <= 1.55e+25)) {
tmp = a * Math.pow(a, 3.0);
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.5e+40) or not (a <= 1.55e+25): tmp = a * math.pow(a, 3.0) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.5e+40) || !(a <= 1.55e+25)) tmp = Float64(a * (a ^ 3.0)); else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.5e+40) || ~((a <= 1.55e+25))) tmp = a * (a ^ 3.0); else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.5e+40], N[Not[LessEqual[a, 1.55e+25]], $MachinePrecision]], N[(a * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.5 \cdot 10^{+40} \lor \neg \left(a \leq 1.55 \cdot 10^{+25}\right):\\
\;\;\;\;a \cdot {a}^{3}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -1.5000000000000001e40 or 1.5499999999999999e25 < a Initial program 43.5%
associate--l+43.5%
fma-define43.5%
sqr-neg43.5%
fma-define43.5%
distribute-rgt-in43.5%
sqr-neg43.5%
distribute-rgt-in43.5%
fma-define43.5%
sqr-neg43.5%
Simplified49.2%
Taylor expanded in a around inf 95.5%
associate-*r/95.5%
metadata-eval95.5%
Simplified95.5%
Taylor expanded in a around 0 95.5%
Taylor expanded in a around inf 95.5%
if -1.5000000000000001e40 < a < 1.5499999999999999e25Initial program 98.4%
Taylor expanded in a around 0 97.1%
Taylor expanded in a around 0 98.7%
Taylor expanded in b around inf 94.1%
Final simplification94.8%
(FPCore (a b) :precision binary64 (if (or (<= a -8.2e+35) (not (<= a 700000000.0))) (* a (pow a 3.0)) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -8.2e+35) || !(a <= 700000000.0)) {
tmp = a * pow(a, 3.0);
} else {
tmp = ((b * b) * 12.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 <= (-8.2d+35)) .or. (.not. (a <= 700000000.0d0))) then
tmp = a * (a ** 3.0d0)
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -8.2e+35) || !(a <= 700000000.0)) {
tmp = a * Math.pow(a, 3.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -8.2e+35) or not (a <= 700000000.0): tmp = a * math.pow(a, 3.0) else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -8.2e+35) || !(a <= 700000000.0)) tmp = Float64(a * (a ^ 3.0)); else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -8.2e+35) || ~((a <= 700000000.0))) tmp = a * (a ^ 3.0); else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -8.2e+35], N[Not[LessEqual[a, 700000000.0]], $MachinePrecision]], N[(a * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2 \cdot 10^{+35} \lor \neg \left(a \leq 700000000\right):\\
\;\;\;\;a \cdot {a}^{3}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -8.1999999999999997e35 or 7e8 < a Initial program 45.3%
associate--l+45.3%
fma-define45.3%
sqr-neg45.3%
fma-define45.3%
distribute-rgt-in45.3%
sqr-neg45.3%
distribute-rgt-in45.3%
fma-define45.3%
sqr-neg45.3%
Simplified50.7%
Taylor expanded in a around inf 93.4%
associate-*r/93.4%
metadata-eval93.4%
Simplified93.4%
Taylor expanded in a around 0 93.4%
Taylor expanded in a around inf 93.2%
if -8.1999999999999997e35 < a < 7e8Initial program 98.3%
associate--l+98.3%
fma-define98.3%
sqr-neg98.3%
fma-define98.3%
distribute-rgt-in98.3%
sqr-neg98.3%
distribute-rgt-in98.3%
fma-define98.3%
sqr-neg98.3%
Simplified98.3%
Taylor expanded in a around 0 97.6%
Taylor expanded in b around 0 97.5%
Taylor expanded in b around 0 77.1%
pow297.6%
Applied egg-rr77.1%
Final simplification85.1%
(FPCore (a b) :precision binary64 (if (or (<= a -8.2e+35) (not (<= a 1500000000.0))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -8.2e+35) || !(a <= 1500000000.0)) {
tmp = pow(a, 4.0);
} else {
tmp = ((b * b) * 12.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 <= (-8.2d+35)) .or. (.not. (a <= 1500000000.0d0))) then
tmp = a ** 4.0d0
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -8.2e+35) || !(a <= 1500000000.0)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -8.2e+35) or not (a <= 1500000000.0): tmp = math.pow(a, 4.0) else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -8.2e+35) || !(a <= 1500000000.0)) tmp = a ^ 4.0; else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -8.2e+35) || ~((a <= 1500000000.0))) tmp = a ^ 4.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -8.2e+35], N[Not[LessEqual[a, 1500000000.0]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2 \cdot 10^{+35} \lor \neg \left(a \leq 1500000000\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -8.1999999999999997e35 or 1.5e9 < a Initial program 45.3%
associate--l+45.3%
fma-define45.3%
sqr-neg45.3%
fma-define45.3%
distribute-rgt-in45.3%
sqr-neg45.3%
distribute-rgt-in45.3%
fma-define45.3%
sqr-neg45.3%
Simplified50.7%
Taylor expanded in a around inf 93.2%
if -8.1999999999999997e35 < a < 1.5e9Initial program 98.3%
associate--l+98.3%
fma-define98.3%
sqr-neg98.3%
fma-define98.3%
distribute-rgt-in98.3%
sqr-neg98.3%
distribute-rgt-in98.3%
fma-define98.3%
sqr-neg98.3%
Simplified98.3%
Taylor expanded in a around 0 97.6%
Taylor expanded in b around 0 97.5%
Taylor expanded in b around 0 77.1%
pow297.6%
Applied egg-rr77.1%
Final simplification85.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+53) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+53) {
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 * b) <= 1d+53) 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 * b) <= 1e+53) {
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 * b) <= 1e+53: 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 (Float64(b * b) <= 1e+53) 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 * b) <= 1e+53) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+53], 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 \cdot b \leq 10^{+53}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999999e52Initial program 80.9%
Taylor expanded in a around 0 98.1%
Taylor expanded in a around 0 98.8%
Taylor expanded in a around inf 91.7%
if 9.9999999999999999e52 < (*.f64 b b) Initial program 59.6%
associate--l+59.6%
fma-define59.6%
sqr-neg59.6%
fma-define59.6%
distribute-rgt-in59.6%
sqr-neg59.6%
distribute-rgt-in59.6%
fma-define59.6%
sqr-neg59.6%
Simplified66.0%
Taylor expanded in b around inf 92.6%
Final simplification92.1%
(FPCore (a b) :precision binary64 (+ (* (* b b) 12.0) -1.0))
double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * 12.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
def code(a, b): return ((b * b) * 12.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 12.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 12.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Initial program 71.8%
associate--l+71.8%
fma-define71.8%
sqr-neg71.8%
fma-define71.8%
distribute-rgt-in71.8%
sqr-neg71.8%
distribute-rgt-in71.8%
fma-define71.8%
sqr-neg71.8%
Simplified74.5%
Taylor expanded in a around 0 67.8%
Taylor expanded in b around 0 67.8%
Taylor expanded in b around 0 52.3%
pow267.8%
Applied egg-rr52.3%
Final simplification52.3%
(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%
associate--l+71.8%
fma-define71.8%
sqr-neg71.8%
fma-define71.8%
distribute-rgt-in71.8%
sqr-neg71.8%
distribute-rgt-in71.8%
fma-define71.8%
sqr-neg71.8%
Simplified74.5%
Taylor expanded in a around 0 67.8%
Taylor expanded in b around 0 24.6%
herbie shell --seed 2024123
(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))