# how can i integrate a function which has three variables but has to integrate it with respect to only one variable

8 views (last 30 days)
bhanu kiran vandrangi on 2 Aug 2021
Commented: Walter Roberson on 14 Aug 2021
my function F is f(d,e,t) but i only want to integrate the function with respect to t alone (from a to b , definite integration), by keeping other two variables not affected
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Answers (2)

David Hill on 2 Aug 2021
For example:
syms a b d e t;
f=d^2*cos(e)/exp(t);
I=int(f,e,a,b);
##### 1 CommentShowHide None
bhanu kiran vandrangi on 3 Aug 2021
Edited: bhanu kiran vandrangi on 3 Aug 2021
syms s t d e
y=((0.005659*s^2+0.05206*s+0.004496)/(s^3+9.357*s^2+2.228*s+0.06147))*((27.5084*d)+(27.5084*(e/s)))
z=vpa(ilaplace(y,s,t),5)
x=((0.003013)/(s^3+9.357*s^2+2.228*s+0.06147))*((-20.6533*d)+(-20.6533*(e/s)))
v=vpa(ilaplace(x,s,t),5)
C=z+v
B=sign(C-1)*(C-1)
w=(7.4513/B)
I=int(w,t,0,2000)
i need w to be always positive so used sign , i am not getting output with integral ,what to do

Sign in to comment.

Walter Roberson on 3 Aug 2021
You do not seem to be able to find a closed form solution with symbolic d or e.
Your ilaplace() involves the sum of an expression involving roots of a cubic function. Two of the roots are (probably) complex valued.
When I do some tests with the complex values, it looks as if the imaginary parts vanish. However, at the moment I do not see any way of proving that, as the coefficients of the imaginary terms are not small. I suspect you would have to prove that the phases cancel out because the two complex roots would have to be complex conjugates.
The symsum() of roots of a polynomial is a nuisance: mathworks does not define any way to expand the roots, just using root indices instead. Because it is only a cubic, it is possible to replace the indexed root with its closed form formula... getting a long formula, but something that has more potential to be integrated.
Substituting in closed form polynomial roots instead of the placeholders that ilaplace uses, is not trivial. This is the first time I have been able to put suitable code together, and I am not certain that I got it correct.
Taking sign(7.4513-z) implies that you think z is real-valued, which seems likely to be true in theory, but is difficult to prove, and might not be true numerically.
The ilaplace result would normally have a couple of derivatives of dirac deltas on t, and those derivatives of dirac(0) would normally contribute infinite values... it is not obvious to me that the ilaplace result has a well-defined value at t = 0. I skip the problem by adding an assumption that t is strictly greater than 0; in theory that is a problem for the integration starting from 0. The integration should probably start from realmin() instead of 0.
If you substitute in specific numeric values for d and e in the below, the int(w) might take a quite long time. You probably should not do that, and should probably use vpaintegral() instead of int() for that case.
Q = @(v) sym(v);
syms s t d e real
assume(t>0);
y = (Q(0.005659)*s^2+Q(0.05206)*s+Q(0.004496)/(s^3+Q(9.357)*s^2+Q(2.228)*s+Q(0.06147)))*(Q(27.5084)*d+Q(27.5084)*(e/s));
z = ilaplace(y,s,t);
Nth = @(expr,N) expr(N);
resolve_a_root = @(X6) Nth(solve(children(X6,1),children(X6,2),'maxdegree',4),children(X6,3));
resolve_a_summand = @(X5) mapSymType(X5, 'root', resolve_a_root);
resolve_nth_summand = @(X2,N) resolve_a_summand(subs(children(X2,1),children(X2,2),N));
map_symsum = @(X2) sum(arrayfun(resolve_nth_summand, repmat(X2,1,double(children(X2,4)-children(X2,3)+1)), children(X2,3):children(X2,4)));
expand_symsum = @(X1) mapSymType(X1, 'symsum', map_symsum);
ez = simplify(expand_symsum(z));
Bound = Q(7.4513);
w = piecewise(ez < Bound, Bound-ez, ez-Bound);
I = int(w, t, 0, 2000);
w20 = vpa(simplify(w),20);
w20z = vpa(real(mapSymType(w20, 'vpareal', @(X7) piecewise(abs(X7)<1e-10,0,X7))),20)
I20 = int(w20z, t, 0, 2000)
##### 4 CommentsShowHide 3 older comments
Walter Roberson on 14 Aug 2021
If I recall correctly, the tests I did happened to be against d and e being in the range [0, 1], and I did observe the division by 0.

Sign in to comment.

### Categories

Find more on Common Operations in Help Center and File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!