フィルターのクリア

Suprising results using matlabs quad to solve a simple double definite integral.

3 ビュー (過去 30 日間)
Hi everyone, i have a complex function which i have written a matlab function to execute, but before that i did a simple example of definite integral of the form
int_0^1 log int_0^1 x+y dxdy .(here 'int' is the integral sign, underscore 0 hat 1 are the limits of integration, done w.r.t x and y)
doing this by pen and paper gives me -1.33333... but using this code below.i get a wrong answer.
function z1=intlog(y)
%intlog is a function executing the inner integral with respect to %x.
n=length(y);
z=zeros(size(y));
for j=1:n
a=0;b=1;
h=@(x) (x+y(j));
z(j)=quad(h,a,b);
z1=log(z);
end
to run this write in command window:
q=quad(@intlog,0,1)
which gives me a wrong answer. any explanation for this. I am using matlab release 2009a.
Thanks in anticipation.
  3 件のコメント
Jan
Jan 2011 年 8 月 1 日
Can you explain the similarities to http://www.mathworks.com/matlabcentral/answers/12775-matlab-quad-function-results-wrong ?
Silibelo Kamwi
Silibelo Kamwi 2011 年 8 月 1 日
Jan, i posted the question twice and once i was in the office the other one i was at home and i was not sure of whether i did post the first question.
Thanks

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

採用された回答

the cyclist
the cyclist 2011 年 7 月 31 日
Your pen and paper solution is incorrect. The correct analytic answer is 3*ln(3)/2 - ln(2) - 1 ~= -0.0452, which is spot-on with your code. [Here "ln" is natural log.]
  1 件のコメント
Silibelo Kamwi
Silibelo Kamwi 2011 年 8 月 1 日
Thanks everyone for pointing me in the right direction.
thanks
Innocent

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by