
I need help on the error part. I know the formula for finding the error but I am having trouble determining what $k$ should be. Is $k$ just any number?

I need help on the error part. I know the formula for finding the error but I am having trouble determining what $k$ should be. Is $k$ just any number?
On
Let's do the analysis for TRAP. The formula that you wrote that you know probably reads something like $$\frac{(b-a)^3}{12n^2}|f''(\xi)|,$$ where $\xi$ is a number between $a$ and $b$.
In our case, $b=2$, and $a=0$. Also, our function $f(x)$ is $\cos(x^3)$. Then $f'(x)=- 3x^2\sin(x^3)$ and therefore $f''(x)=-9x^4\cos(x^3)-6x\sin(x^3)$. We want to find an upper bound $B$ on $|f''(x)|$ in our interval. It is not clear how hard we should work to get a cheap upper bound. A crude one is that since $\sin$ and $\cos$ are never bigger than $1$, we have $|f''(x)|\le 9(2^4)+12=156$.
So our error if we use $n$ intervals is $\le \frac{8}{12n^2}(156)=\frac{104}{n^2}$.
To make sure this is less than $10^{-4}$, we solve the inequality $\frac{104}{n^2}\lt 10^{-4}$, or equivalently $n^2\gt (104)(10000)$. The smallest integer that works is $n=1020$.
Remark: Note that our calculation does not show that $n=1020$ is needed, only that for sure it will do the job.
For one thing, the maximum of the second derivative over our interval is under $50$.
Far more relevant is that when we use the maximum for our estimate of $|f''(\xi)|)$ we are for most functions being very pessimistic. The error will usually be far smaller than the pessimistic estimate we made, and the required $n$ therefore far smaller. The estimates are not used in practical work. Roughly speaking, one doubles the number of points used until the answer becomes stable enough.
For the midpoint and trapezoidal rules $K$ is the maximum magnitude of the second derivative over the interval.
$$K=\max_{x\in[a,b]}|f''(x)|.$$
For Simpsons rule is of the fourth derivative
$$K_S=\max_{x\in[a,b]}|f^{iv}(x)|.$$
I am guessing that the functions have to be twice respectively four times continuously differentiable as your one is.
For part (b) they have given you an upper bound for $K$.