
(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 8 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) 1e+154)
(+
(+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (+ (* a a) (* (* b b) (+ a 3.0)))))
-1.0)
(pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+154) {
tmp = (pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.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+154) then
tmp = ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * (a + 3.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+154) {
tmp = (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+154: tmp = (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+154) tmp = Float64(Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * Float64(a + 3.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+154) tmp = ((((b * b) + (a * a)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * (a + 3.0))))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+154], 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] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+154}:\\
\;\;\;\;\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1.00000000000000004e154Initial program 73.3%
Taylor expanded in a around 0 97.1%
if 1.00000000000000004e154 < (*.f64 b b) Initial program 61.9%
associate--l+61.9%
fma-define61.9%
distribute-rgt-in61.9%
sqr-neg61.9%
distribute-rgt-in61.9%
Simplified66.7%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around inf 100.0%
Final simplification98.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+154) (+ (+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (+ (* a a) (* (* b b) a)))) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+154) {
tmp = (pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -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+154) then
tmp = ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * ((a * a) + ((b * b) * a)))) + (-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+154) {
tmp = (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+154: tmp = (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+154) tmp = Float64(Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(Float64(a * a) + Float64(Float64(b * b) * a)))) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+154) tmp = ((((b * b) + (a * a)) ^ 2.0) + (4.0 * ((a * a) + ((b * b) * a)))) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+154], 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] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+154}:\\
\;\;\;\;\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot a\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1.00000000000000004e154Initial program 73.3%
Taylor expanded in a around 0 97.1%
Taylor expanded in a around inf 96.4%
if 1.00000000000000004e154 < (*.f64 b b) Initial program 61.9%
associate--l+61.9%
fma-define61.9%
distribute-rgt-in61.9%
sqr-neg61.9%
distribute-rgt-in61.9%
Simplified66.7%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around inf 100.0%
Final simplification97.9%
(FPCore (a b)
:precision binary64
(if (<= a -1.05e+15)
(pow a 4.0)
(if (<= a 140000000000.0)
(+ (+ (pow b 4.0) (* (* b b) 12.0)) -1.0)
(* (pow a 3.0) (- a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -1.05e+15) {
tmp = pow(a, 4.0);
} else if (a <= 140000000000.0) {
tmp = (pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
} else {
tmp = pow(a, 3.0) * (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 <= (-1.05d+15)) then
tmp = a ** 4.0d0
else if (a <= 140000000000.0d0) then
tmp = ((b ** 4.0d0) + ((b * b) * 12.0d0)) + (-1.0d0)
else
tmp = (a ** 3.0d0) * (a - 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.05e+15) {
tmp = Math.pow(a, 4.0);
} else if (a <= 140000000000.0) {
tmp = (Math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0;
} else {
tmp = Math.pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.05e+15: tmp = math.pow(a, 4.0) elif a <= 140000000000.0: tmp = (math.pow(b, 4.0) + ((b * b) * 12.0)) + -1.0 else: tmp = math.pow(a, 3.0) * (a - 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.05e+15) tmp = a ^ 4.0; elseif (a <= 140000000000.0) tmp = Float64(Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0)) + -1.0); else tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.05e+15) tmp = a ^ 4.0; elseif (a <= 140000000000.0) tmp = ((b ^ 4.0) + ((b * b) * 12.0)) + -1.0; else tmp = (a ^ 3.0) * (a - 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.05e+15], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 140000000000.0], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.05 \cdot 10^{+15}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 140000000000:\\
\;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if a < -1.05e15Initial program 57.7%
associate--l+57.7%
fma-define57.7%
distribute-rgt-in57.7%
sqr-neg57.7%
distribute-rgt-in57.7%
Simplified57.7%
Taylor expanded in a around inf 93.7%
associate-*r/93.7%
metadata-eval93.7%
Simplified93.7%
Taylor expanded in a around inf 93.7%
if -1.05e15 < a < 1.4e11Initial program 98.4%
associate--l+98.4%
fma-define98.4%
distribute-rgt-in98.4%
sqr-neg98.4%
distribute-rgt-in98.4%
Simplified98.4%
Taylor expanded in a around 0 99.9%
pow299.9%
Applied egg-rr99.9%
if 1.4e11 < a Initial program 22.3%
associate--l+22.3%
fma-define22.3%
distribute-rgt-in22.3%
sqr-neg22.3%
distribute-rgt-in22.3%
Simplified28.9%
Taylor expanded in a around inf 96.4%
associate-*r/96.4%
metadata-eval96.4%
Simplified96.4%
Taylor expanded in a around 0 96.4%
Final simplification97.8%
(FPCore (a b) :precision binary64 (if (<= a -1.35e+14) (pow a 4.0) (if (<= a 3400000000000.0) (+ (pow b 4.0) -1.0) (* (pow a 3.0) (- a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -1.35e+14) {
tmp = pow(a, 4.0);
} else if (a <= 3400000000000.0) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 3.0) * (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 <= (-1.35d+14)) then
tmp = a ** 4.0d0
else if (a <= 3400000000000.0d0) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = (a ** 3.0d0) * (a - 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.35e+14) {
tmp = Math.pow(a, 4.0);
} else if (a <= 3400000000000.0) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.35e+14: tmp = math.pow(a, 4.0) elif a <= 3400000000000.0: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 3.0) * (a - 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.35e+14) tmp = a ^ 4.0; elseif (a <= 3400000000000.0) tmp = Float64((b ^ 4.0) + -1.0); else tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.35e+14) tmp = a ^ 4.0; elseif (a <= 3400000000000.0) tmp = (b ^ 4.0) + -1.0; else tmp = (a ^ 3.0) * (a - 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.35e+14], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 3400000000000.0], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35 \cdot 10^{+14}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 3400000000000:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if a < -1.35e14Initial program 57.7%
associate--l+57.7%
fma-define57.7%
distribute-rgt-in57.7%
sqr-neg57.7%
distribute-rgt-in57.7%
Simplified57.7%
Taylor expanded in a around inf 93.7%
associate-*r/93.7%
metadata-eval93.7%
Simplified93.7%
Taylor expanded in a around inf 93.7%
if -1.35e14 < a < 3.4e12Initial program 98.4%
Taylor expanded in a around 0 98.4%
Taylor expanded in a around inf 82.0%
Taylor expanded in a around 0 99.1%
if 3.4e12 < a Initial program 22.3%
associate--l+22.3%
fma-define22.3%
distribute-rgt-in22.3%
sqr-neg22.3%
distribute-rgt-in22.3%
Simplified28.9%
Taylor expanded in a around inf 96.4%
associate-*r/96.4%
metadata-eval96.4%
Simplified96.4%
Taylor expanded in a around 0 96.4%
Final simplification97.4%
(FPCore (a b) :precision binary64 (if (or (<= a -24500000000000.0) (not (<= a 340000000000.0))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -24500000000000.0) || !(a <= 340000000000.0)) {
tmp = pow(a, 4.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 <= (-24500000000000.0d0)) .or. (.not. (a <= 340000000000.0d0))) then
tmp = a ** 4.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 <= -24500000000000.0) || !(a <= 340000000000.0)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -24500000000000.0) or not (a <= 340000000000.0): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -24500000000000.0) || !(a <= 340000000000.0)) tmp = a ^ 4.0; else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -24500000000000.0) || ~((a <= 340000000000.0))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -24500000000000.0], N[Not[LessEqual[a, 340000000000.0]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -24500000000000 \lor \neg \left(a \leq 340000000000\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -2.45e13 or 3.4e11 < a Initial program 35.5%
associate--l+35.5%
fma-define35.5%
distribute-rgt-in35.5%
sqr-neg35.5%
distribute-rgt-in35.5%
Simplified39.6%
Taylor expanded in a around inf 95.4%
associate-*r/95.4%
metadata-eval95.4%
Simplified95.4%
Taylor expanded in a around inf 95.3%
if -2.45e13 < a < 3.4e11Initial program 98.4%
Taylor expanded in a around 0 98.4%
Taylor expanded in a around inf 82.0%
Taylor expanded in a around 0 99.1%
Final simplification97.3%
(FPCore (a b) :precision binary64 (if (or (<= a -75000000000000.0) (not (<= a 1250000000000.0))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -75000000000000.0) || !(a <= 1250000000000.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 <= (-75000000000000.0d0)) .or. (.not. (a <= 1250000000000.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 <= -75000000000000.0) || !(a <= 1250000000000.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 <= -75000000000000.0) or not (a <= 1250000000000.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 <= -75000000000000.0) || !(a <= 1250000000000.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 <= -75000000000000.0) || ~((a <= 1250000000000.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, -75000000000000.0], N[Not[LessEqual[a, 1250000000000.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 -75000000000000 \lor \neg \left(a \leq 1250000000000\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -7.5e13 or 1.25e12 < a Initial program 35.5%
associate--l+35.5%
fma-define35.5%
distribute-rgt-in35.5%
sqr-neg35.5%
distribute-rgt-in35.5%
Simplified39.6%
Taylor expanded in a around inf 95.4%
associate-*r/95.4%
metadata-eval95.4%
Simplified95.4%
Taylor expanded in a around inf 95.3%
if -7.5e13 < a < 1.25e12Initial program 98.4%
associate--l+98.4%
fma-define98.4%
distribute-rgt-in98.4%
sqr-neg98.4%
distribute-rgt-in98.4%
Simplified98.4%
Taylor expanded in a around 0 99.9%
Taylor expanded in b around 0 73.0%
pow299.9%
Applied egg-rr73.0%
Final simplification83.5%
(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 68.7%
associate--l+68.7%
fma-define68.7%
distribute-rgt-in68.7%
sqr-neg68.7%
distribute-rgt-in68.7%
Simplified70.6%
Taylor expanded in a around 0 70.5%
Taylor expanded in b around 0 52.5%
pow270.5%
Applied egg-rr52.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 68.7%
associate--l+68.7%
fma-define68.7%
distribute-rgt-in68.7%
sqr-neg68.7%
distribute-rgt-in68.7%
Simplified70.6%
Taylor expanded in a around 0 70.5%
Taylor expanded in b around 0 21.6%
herbie shell --seed 2024182
(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))