How to perform definite integration with non-commutable symbolic coefficients?

9 views (last 30 days)
Hi All,
I am trying to perform a definite integration in X (length axis) to calculate some beam modeshapes, following this the variables will be passed into a time integration using ode45. In the integration there are beam modeshape terms (W) which are a function of x and there are time dependent terms (qw) which are not. Crucially the qw terms are not commutable so cannot be factored out of the integrals. I need the answer to W6 to be given in terms W6=Y1*qw1+Y2*qw2... where Y1 and Y2 are numerical coefficients.
Here is my code:
clear all
clc
syms x qw1 qw2
L=0.52;
qw=[qw1; qw2];
%Bending Mode
Landa=[1.875104069 4.694091133];% 7.854757];% 10.99554];
for j=1:length(Landa)
SIGMA(j)=(cos(Landa(j))+cosh(Landa(j)))/(sin(Landa(j))+sinh(Landa(j)));
W(j)=cosh(Landa(j)*x/L)-cos(Landa(j)*x/L)-SIGMA(j)*(sinh(Landa(j)*x/L)-sin(Landa(j)*x/L));
end
% Integration in X over length of beam
W6=(vpaintegral(W*diff(diff(W,x,1)*qw*diff(diff(W,x,1)*qw*diff(W,x,2)*qw,x,1),x,1),0,L));
The value W6 is left as symbolic without the integrals being solved, this means that when I pass the W6 term into the time integration in a separate script and solve for qw terms the time integration is much slower because it is computing the spatial integration in X for each time of the 1000 time-steps.
I have tried using the 'double','simplify' and 'collect' commands but I have not been able to get the result in the form I want it. So what I'm asking is, is there a way to "force" matlab to do the integrations with the symbolic coefficients attahced. Any help would be much appreciated!

Accepted Answer

Walter Roberson
Walter Roberson on 25 Mar 2025
Crucially the qw terms are not commutable so cannot be factored out of the integrals.
The only way to enter non-commutable terms in the Symbolic Toolbox is to use symmatrix, in which case all multiplications and divisions involving the symmatrix objects become non-commutive.
However, expressions involving symmatrix objects are not eligible for int() until the symmatrix are replaced with real matrices, in which case all of the terms involving the symmatrix objects are expanded out into arrays of commutable objects.
Note by the way that the expression() you are attempting to vpaintegral() is an expression involving qw1, qw2, and x, and vpaintegral() can only process expressions in which all of the variables except one are "bound" variables. For example, it is valid to do
syms x y z
vpaintegral( vpaintegral(x * sin(y), y, 0, 1), x, 0, 1)
ans = 
0.229849
The inner vpaintegral() will return unevaluated, but it is recognized that it "binds" the variable y to a fixed range. The outer vpaintegral() can then act on x and the bound y.
But you cannot usefully do
vpaintegral( vpaintegral(x * sin(y) + z, y, 0, 1), x, 0, 1)
ans = 
as that leaves z unbound.
One might hope that it might return
z*(1-0) + 0.22849
ans = 
but vpaintegral() is not able to do that. int() is able to handle that situation though.
int( int(x * sin(y) + z, y, 0, 1), x, 0, 1)
ans = 
  2 Comments
ABCD_DCBA
ABCD_DCBA on 25 Mar 2025
Hi Walter,
Thanks so much for your help! I will try using symmatrix to expand out the expression with the non-commutable terms and see what I am left with. Hopefully I can simplify from there and break the integrals into smaller parts, thanks again!
Walter Roberson
Walter Roberson on 26 Mar 2025
The fact that some symbols are non-commutative makes me wonder whether you are doing tensor work. If so, then there is no direct symbolic support for tensors; you would have to write your own functions to impliment tensors on definite matrices.

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!