2012-12-05 31 views
3

我已經試圖使用MATLAB解方程所示:如何使用MATLAB數值求解未知嵌入積分的方程?

B =阿爾法* Y0 * SQRT(ε)/(PI * LN(B/A)* SQRT(epsilon_t))*積分從 0到 的pi(2 * sinint(k0 * sqrt(epsilon *(a^2 + b ^2-2abcosθ)) - sinint(2 * k0 * sqrt(epsilon)* a * sin(theta/2)) - sinint(2 * K0 *的sqrt(ε)* b * SIN(THETA/2))) 關於THETA

小量是未知

我知道如何通過使用int()solve()來象徵性地求解未知嵌入積分的方程式,但使用符號積分器int()需要太長時間才能使方程式變得複雜。當我嘗試使用quad(),quadl()quadgk()時,我無法處理如何將未知嵌入到積分中。

+0

http://www.mathworks.com/matlabcentral/fileexchange/34241-integral-equation-solver – 0x90

+0

上面定義了所有其他的常量嗎? (即α,Y0等) – nicktruesdale

+0

這些常數只是用於計算目的的任意常數,只有epsilon是未知的。 theta只是整合變量(如dx,dy,dz等) – user1880273

回答

2

這類事情變得非常複雜。雖然可以用一個內聯方程來完成,但我建議您將其分解爲多個嵌套函數(如果僅用於可讀性)。

爲什麼可讀性很重要的最佳示例:您在發佈的公式中存在包圍問題;沒有足夠的右括號,所以我不能完全肯定式的樣子在數學符號:)

總之,這裏的同版本做這件事我--think--你的意思是:

function test 

    % some random values for testing  

    Y0 = rand; 
    b = rand; 
    a = rand; 
    k0 = rand; 
    alpha  = rand; 
    epsilon_t = rand; 

    % D is your B 
    D = -0.015; 

    % define SIMPLE anonymous function 
    Bb = @(ep) F(ep).*main_integral(ep) - D; 

    % aaaand...solve it! 
    sol = fsolve(Bb, 1) 

    % The anonymous function above is only simple, because of these: 

    % the main integral  
    function val = main_integral(epsilon) 

     % we need for loop through epsilon, due to how quad(gk) solves things 
     val = zeros(size(epsilon)); 
     for ii = 1:numel(epsilon) 

      ep = epsilon(ii); 

      % NOTE how the sinint's all have a different function as argument: 
      val(ii) = quadgk(@(th)... 
       2*sinint(A(ep,th)) - sinint(B(ep,th)) - sinint(C(ep,th)), ... 
       0, pi);    
     end 

    end 

    % factor in front of integral 
    function f = F(epsilon)   
     f = alpha*Y0*sqrt(epsilon)./(pi*log(b/a)*sqrt(epsilon_t)); end 

    % first sinint argument 
    function val = A(epsilon, theta) 
     val = k0*sqrt(epsilon*(a^2+b^2-2*a*b*cos(theta))); end 

    % second sinint argument 
    function val = B(epsilon, theta) 
     val = 2*k0*sqrt(epsilon)*a*sin(theta/2); end 

    % third sinint argument 
    function val = C(epsilon, theta) 
     val = 2*k0*sqrt(epsilon)*b*sin(theta/2); end  

end 

上述解決方案仍然很慢,但我認爲這是非常正常的積分這很複雜。

我不認爲實現自己的sinint會有很大的幫助,因爲大部分速度損失是由於非內建函數的for循環引起的......如果速度要求,我會去MEX用自己的Gauss-Kronrod自適應正交例程實現。