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

15 ビュー (過去 30 日間)
John Barton 2021 年 2 月 26 日
コメント済み: Rik 2021 年 2 月 26 日
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:

サインインしてコメントする。

### 採用された回答

Rik 2021 年 2 月 26 日
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
[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
##### 2 件のコメント表示非表示 1 件の古いコメント
Rik 2021 年 2 月 26 日
The best advice I can give you is here. To learn the basics you can de the Onramp tutorial.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by