1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Some problems about the Numerical Integration

  1. Nov 20, 2007 #1
    there are 5 examples as follows:

    %%% example01 %%%%
    z=linspace(-0.1,0.1);
    a=0.1;
    kesi=(z+sqrt(z.^2-a^2))./a;
    for j=1:length(z)
    f=@(b) log(1-((b+sqrt(b.^2-a^2))./a)./kesi(j));
    I(j)=quadl(f,-0.1+eps,0.1+eps,1e-8);
    end


    %%% example02 %%%%
    z=linspace(-0.1,0.1);
    a=0.1;
    kesi=(z+sqrt(z.^2-a^2))./a;
    for i=1:length(z)
    k=kesi(i);
    fun=strcat('log(1-((b+sqrt(b.^2-0.1^2))./0.1)./',num2str(k),')');
    II(i)=quadl(inline(fun),-0.1+eps,0.1+eps);
    end

    %%% example03 %%%%
    z=linspace(-0.1,0.1);
    a=0.1;
    kesi=(z+sqrt(z.^2-a^2))./a;
    for i=1:length(z)
    k=kesi(i);
    fun=inline(subs('log(1-((b+sqrt(b^2-0.1^2))/0.1)/kesi)','kesi',k));
    III(i)=quadl(fun,-0.1+eps,0.1+eps);
    end


    %%% example04 %%%%
    z=linspace(-0.1,0.1);
    a=0.1;
    kesi=(z+sqrt(z.^2-a^2))./a;
    ff=@(k) ['log(1-((b+sqrt(b.^2-0.1^2))./0.1)./',num2str(k),')'];
    f=@(k) quadl(ff(k),-0.1+eps,0.1+eps);
    for i=1:length(z)
    IIII(i)=f(kesi(i));
    end

    %%% example05 %%%%
    clear all;clc;
    a=0.1;
    f=@(kesi) quadl(@(b) log(1-((b+sqrt(b.^2-a^2))./a)./kesi),-0.1+eps,0.1+eps)
    z=linspace(-0.1,0.1);
    kesi=(z+sqrt(z.^2-a^2))./a;
    y=zeros(size(z));
    for ii=1:length(z)
    IIIII(ii)=f(kesi(ii));
    end


    %%example06 %%%%
    a=0.1;
    z=linspace(-0.1,0.1);
    kesi=(z+sqrt(z.^2-a^2))./a;
    IIIIII=arrayfun(@(kesi) quad(@(b) log(1-((b+sqrt(b.^2-a^2))./a)./kesi),-0.1+eps,0.1+eps),kesi);


    example 1,3,5,6 get the same results, but 2,4 get the anoth results.

    anybody know why?
     
  2. jcsd
  3. Nov 20, 2007 #2
    please help..................
    thanks
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Some problems about the Numerical Integration
  1. Numeric Integration (Replies: 0)

Loading...