I have a question regarding the order of accuracy for certain function using the trapezoidal formula.
I know that from theory the formula is second order accurate, but when working with matlab I get different answers.
I calculated the order of accuracy by plotting the logarithm of the error vs the logarithm of the step size $H$.
When using functions which are infinitely differentiable, for example $\sin(x)$ or $e^x$, I get a slope of $-2$, as expected.
But when using the formula $\arctan(\sqrt{x})$ I get a slope of about -1.5.
Why does the order of accuracy depend on the function that is integrated?
Possible solution: The error term involves a second derivative of the function being integrated. And your example is not differentiable at 0. (So I suggested testing it on an interval where the second derivative exists).