I want to make a series using max & mins of this Integral and show that the series converges and has the limit pi/2.

1 view (last 30 days)
clc
close all
clear all
fun=@(w)(sin(w)/w);
f=zeros(1,1000);
for u=1:1000
f(u)=integral(fun,1,u,'ArrayValued',true);
end
plot(f)
I've done the first part but I'm stuck in making a series.
Original question:

Accepted Answer

Rik
Rik on 26 Feb 2021
Your code already is making a series. You could add the envelope, but the only thing you're missing in my opinion is adding the pi/2 line.
You misunderstood the ArrayValued flag: "Set this flag to true or 1 to indicate that fun is a function that accepts a scalar input and returns a vector, matrix, or N-D array output." Your function does not return an array. A small modification will allow array input.
%clc,close all,clear all
%these are not needed here and are a sign of cargo cult programming.
fun=@(w)(sin(w)./w);
% ^ use elementwise division to allow array input
f=zeros(1,1000);
for u=1:1000
f(u)=integral(fun,1,u,'ArrayValued',false);
end
plot(f)
hold on
%add the envelope
[y_hi,y_lo]=envelope(f,300);plot(y_hi),plot(y_lo)
%add pi/2 to see if that is the value this converges to
yline(pi/2)
%as it apparently doesn't, lets see what it seems to converge to:
fprintf('pi/%.2f\n',pi/f(end))
pi/5.03
%We can repeat this assuming the sine should be computed for degrees instead of radians:
fprintf('pi/%.2f\n',pi/(integral(@(w)(sind(w)./w),1,u)))
pi/2.03

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!