I am trying solve an integration problem. The result takes around 4-5 minutes to solve. I want to reduce the runtime to max 10seconds. Please help me with the same.
1 view (last 30 days)
Show older comments
w_p=2*pi/T_p;
syms w;
H_s=5.4;
WD=42.5;
T_p=10.4;
%Generalised Phillip's Constant
alpha=vpa(5*H_s^2*w_p^4*(1-0.287*log(gamma1))/(16*g^2),3);
S_nn=alpha*g^2*w^(-5)*(exp(-(5/4)*(w/w_p)^(-4)))*(gamma1^(exp(-0.5*((w-w_p)/(sigma*w_p))^2)));
syms n;
ss=(w^2)*WD/g;
f=1+0.666*(ss)+0.445*(ss)^2-0.105*(ss)^3+0.272*(ss)^4;
lambda=(2*pi/w)*sqrt(WD*g*(f/(1+ss*f)));
k=2*pi/lambda;
G(w)=w/(sinh(k*WD));
S_UU=G(w)^2*S_nn;
M=vpa(int(S_UU*w^n,0,12.78));
tt=double(M(0));
set(handles.text119,'String',tt);
7 Comments
Walter Roberson
on 1 Aug 2015
You could try,
f = w*S_UU(w);
fh = matlabFunction(f,w);
M_n = integrate(fh, 0, 1);
Answers (1)
Walter Roberson
on 25 Jul 2015
Provided that the integral is with respect to n, then it is
-(729/58492928) * Pi^4 * exp(-(3125/1827904) * Pi^4/w^4) * gamma1^(exp(-(1/50) * (-26*w + 5*Pi)^2 /(sigma^2 * Pi^2))) * (-1000 + 287 * ln(gamma1)) * (w^(639/50)-1) / (ln(w) * w^3 * (cosh( (1/2) * w * 85^(1/2) / ((170382840*g^2*w^8 - 1547595*g^3*w^6 + 154326*g^4*w^4 + 5440*g^5*w^2 + 192*g^6) / (14482541400*w^10 - 131545575*g*w^8 + 13117710*g^2*w^6 + 462400*g^3*w^4 + 16320*g^4*w^2 + 384*g^5))^(1/2))^2 - 1))
Assuming that the coefficients should be real and that the results should be real, then the equations have singularities for all non-positive g but not for positive g.
3 Comments
Walter Roberson
on 25 Jul 2015
If you are integrating with respect to w and n does not have a value then you cannot use numeric integration, and there does not happen to be a closed form symbolic integration for that formula.
If your M(0) is intended to mean to evaluate the integral at n = 0, then you should make that substitution before the int() call; the result would be an expression dependent only on w and so it can be integrated numerically.
You might want to decrease DIGITS for faster numeric integration.
I do not think that it is a good idea to use vpa() on the calculation of alpha; the effect on accuracy could be quite large.
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!