We need to find an approximate solution for the generalized Fresnel integral:
$\int_0^S \cos(as+\frac{bs^2}{2}+\frac{cs^3}{3}+\frac{ds^4}{4})ds$
Our approach is to use the Simpsons rule: $\int_a^bf(x)dx\approx \frac{h}{3}(f(x_0)+2\sum_{j=1}^{n/2-1}f(x_{2j})+4\sum_{j=1}^{n/2}f(x_{2j-1})+f(x_n))$
where $h=\frac{b-a}{n}$ and $x_j=a+jh$ and $j\in{[0,n]}$.
We don't know if we can apply the Simpsons rule directly to the function as the argument of the cosine is a polynomial. Can we solve the argument for $s=x_0$ and then evaluate the cosine or do we have to treat the argument somehow to be able to apply the Simpsons rule?
Thanks in advance!
The application of Simpson's rule to any definite integral $I(f) = \int_a^b f(x)dx$ requires only that the integrand $f$ is continuous on the interval $[a,b]$. In particular, the application of Simpson's rule to the integral $$I(g) = \int_0^S \cos\left(a \cdot s+\frac{b \cdot s^2}{2}+\frac{c\cdot s^3}{3}+\frac{d\cdot s^4}{4}\right)ds$$ is perfectly valid because the integrand $g : [0,S] \rightarrow \mathbb{R}$ given by $$ g(s) = \cos\left(a \cdot s+\frac{b \cdot s^2}{2}+\frac{c\cdot s^3}{3}+\frac{d\cdot s^4}{4}\right)$$ is continuous for all $s \in [0,S]$. In fact, $g$ is infinitely often differentiable, i.e., $f \in C^{\infty}([0,S],\mathbb{R})$. In particular, $g \in C^4([0,S],\mathbb{R})$ and the classical error formula holds true. There exists at least one $\xi \in [0,S]$ such that $$ I(g) - S_h(g) = - \frac{S}{180} g^{(4)}(\xi) h^4$$ where $S_h(g)$ denotes the composite trapezoidal rule for $g$ corresponding to the uniform step size $h >0$. Now, given a positive integer $k$ you divide $[0,S]$ into $k$ subintervals of length $2h$, i.e., $h = S/(2k)$. Define $x_j = jh$ for $j=0,1,2,\dots,2k$. Then $S_h(g)$ is given by $$ S_h(g) = \frac{h}{3} \sum_{j=0}^{k-1} \Big[ g(x_{2j}) + 4 g(x_{2j+1}) + g(x_{2j+2})\Big].$$ Many textbooks will rewrite this sum to avoid repetitions. This is a dubious practice which invites index errors when implementing the rule.