Numerical integration twice wrt same variable

15 views (last 30 days)
Hello people,
I have afunctionand it is calculated by only numerical methods. As an example let's say;
where
And I am asked to calculate; at some points of x, let's say at
I do not how to it. I need to calculate y, and use it as a function of x by numerical integration methods. I write my algortihm down below, and I get of course error. Can someone help me fix it?
Thanks in advanced.
clear
clc
r = 1:5; x = 1:5;
for k = 1:length(x)
y(k) = integral(@(r) ((r+1).^2+1)./r,1,x(k))
I(k) = integral(@(x) (1+y(k)),0,1)
end
  5 Comments
madhan ravi
madhan ravi on 4 Feb 2019
Have a look into "ArrayValued" option in integral.
Esra Akdogan
Esra Akdogan on 4 Feb 2019
Thanks for the answer guys. Actually I do not need the value of y(x). It is just an intermediate step in the way of reaching the main integral I. Maybe there is a way for this.

Sign in to comment.

Accepted Answer

Torsten
Torsten on 5 Feb 2019
fun1 = @(x)integral(@(r)((r+1).^2+1)./r,1,x);
fun2 = integral(@(x)(1+fun1(x)),0,1,'ArrayValued',true)
  1 Comment
Esra Akdogan
Esra Akdogan on 5 Feb 2019
hello, I have another question. Are you god or something????
Thank you very much!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!