Getting 0 when using quad

7 ビュー (過去 30 日間)
Aldo
Aldo 2016 年 11 月 11 日
コメント済み: Walter Roberson 2016 年 11 月 11 日
fun = @(x) 80*exp(-((x-pi)/0.002).^2);
I = quad(fun,0,6)
I2= integral(fun,0,6)
I =
0
I2 =
1.464129900321425e-69
Why do I get 0 when using quad?
Best regards Aldo

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 11 月 11 日
編集済み: Walter Roberson 2016 年 11 月 11 日
The two use different adaptive techniques. The function has a sharp peak at Pi and one technique misses it completely and the other barely catches it. The actual integral over that range is (2/25*(erf(500*Pi)+erf(3000-500*Pi)))*sqrt(Pi) which is about 0.284
To get a better answer:
integral(fun,0,6,'Waypoints', pi)
  2 件のコメント
Aldo
Aldo 2016 年 11 月 11 日
And how should you go about to solve it with Quad?
Walter Roberson
Walter Roberson 2016 年 11 月 11 日
I wouldn't solve it with quad(). I might solve it with quadgk
quadgk(fun,0,6, 'waypoints', pi)

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


KSSV
KSSV 2016 年 11 月 11 日
You are trying to calculate the area under the curve as shown in the attached image. See the values on the axes, so I think getting zero is legitimate.

カテゴリ

Help Center および File ExchangeMarine and Underwater Vehicles についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by