I want to solve this integral with numerical method (for example Trapezoidal). $u$ in It's dominant is variable. My question is Can I use the numerical methods for solve these integrals?
- 59
1 Answers
Given a function $g(x;u,t)$ with parameters $u$ and $t$ you could try the trapezoidal rule:
$$\int_a^b g(x;u,t)dx = \frac{h}{2}\left(y_0+2(y_1+y_2+\cdots+y_{n-1})+y_n\right),$$ where $h=(b-a)/n$. In your case $g(v;u,t)=(v-u)f(v;t)$ for some function $f(v;t)$.
You would need to fix parameters $u$ and $t$ to get an actual numerical value.
Whether this method gives you a satisfactory result depends on the function $g$, e.g. pathological functions may prove problematic!
For example, suppose we want to evaluate $$\int_0^1x^2dx$$ using the trapezoidal rule. Here the function $g$ is $g(x)=x^2$. Let's choose $n=5$ partitions of the domain $[0,1]$. Then $h=(1-0)/5 = 0.2$. The values $y_k$ are just the values of the function $g(x)$ evaluated at $x=a$, $x=a+h$, $x=a+2h$, $\ldots$, $x=b$. So the integral becomes $$\int_0^1 x^2dx = \frac{0.2}{2}(g(0)+2(g(0.2)+g(0.4)+g(0.6)+g(0.8))+g(1)) = 0.34.$$ The exact value of the integral is $1/3$, which is approximately $0.33$. The more partitions you use the better the approximation.
- 10,565
-
Thanks a lot. Would you please explain How can we create g function – user115927 Feb 01 '14 at 12:49
-
The function $g$ can be any function you want ! - See example above. – pshmath0 Feb 01 '14 at 13:16