# Matlab / Mupad does not solve definite integral

22 views (last 30 days)
Magnus on 9 Oct 2014
Commented: Magnus on 14 Oct 2014
Dear all,
I'm trying to solve an integral using both matlab and mupad. However it does not solve the integral although it is definite. It basically just simplifies the expression and returns something like
(int((Ub-Ui(i)+cos((pi*x*2.0)/L)*((pi*Xi(i+1.0)*cosh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L+(pi*Yi(i+1.0)*sinh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L)-cos((pi*x*2.0)/L)*((pi*Xi(1.0)*cosh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L+(pi*Yi(1.0)*sinh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L)+((di(i)+H*cos((pi*x*2.0)/L)*(1.0/2.0))*(Ui(i+1.0)-Ui(i)))/(di(i+1.0)-di(i))-((Ub-Ui(1.0))*(d+H*cos((pi*x*2.0)/L)*(1.0/2.0)))/(d-di(1.0)))^2,x,0.0,L*(1.0/2.0))*2.0)/L;
Does anybody know how to 'force' Matlab/Mupad to give a solution?
Kind regards,
##### 2 CommentsShowHide 1 older comment
Magnus on 14 Oct 2014
Dear Bruno, of course. Sorry for that.
g=9.81;
Us=5;
Ui=[0.07*Us 0.1*Us 0.2*Us 0.5*Us Us];
Ub=0.02;
H=7.5;
d=50;
di=[0.8*d 0.6*d 0.4*d 0.2*d 0];
Xi=[X1 X2 X3 X4 X5];
Yi=[Y1 Y2 Y3 Y4 Y5];
syms L x Xi X1 X2 X3 X4 X5 Yi Y1 Y2 Y3 Y4 Y5
i=2; %to cut time, it's actually a for-loop
E2=(int((Ub-Ui(i)+cos((pi*x*2.0)/L)*((pi*Xi(i+1.0)*cosh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L+(pi*Yi(i+1.0)*sinh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L)-cos((pi*x*2.0)/L)*((pi*Xi(1.0)*cosh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L+(pi*Yi(1.0)*sinh((H*pi*cos((pi*x*2.0)/L))/L)*2.0)/L)+((di(i)+H*cos((pi*x*2.0)/L)*(1.0/2.0))*(Ui(i+1.0)-Ui(i)))/(di(i+1.0)-di(i))-((Ub-Ui(1.0))*(d+H*cos((pi*x*2.0)/L)*(1.0/2.0)))/(d-di(1.0)))^2,x,0.0,L*(1.0/2.0))*2.0)/L;

Bruno Pop-Stefanov on 10 Oct 2014
If you want to "force" MATLAB to give a numeric solution to an integral, you can use the integral function, which computes the integral numerically, as opposed to int and MuPAD, which try to solve the integral symbolically.
Here is a page with the list of numerical integration functions and links to examples:
##### 1 CommentShowHide None
Magnus on 14 Oct 2014
Dear Bruno, thanks for your answer! The problem is that for the equation above, I want to solve for L in the next step after the integration from x=0 to x=L/2. I also intend to do so for X1, ...Y5. Numerical integration using integral or quadqk, however, requires only one variable, so I can't keep L, X1,...Y5 as variables but have assign them real values. So I keep x and assign constants to all the other syms values, which works (after transformation to a function handle). I tried to remain L, X1, Y1, etc., as syms but then integral, quadgk etc. wouldn't work.
Cheers