help with symbolic int result

I ran into a problem, symbolic int results include int, adding a second variable, theta + psi, when using symbolic int.
Attached the "Code" and "Result" below.
Rather than randomly implementing all permutations of "assume()" and "simplify()" would someone please guide me to generating a result with the symsbolic "int" term?
Thank you
Code:
syms theta psi No Lo
N1 = (sym(1)/sym(2))*(No/sym(1))*sign(sin(sym(1)*theta + psi));
assume(theta>0 & theta<2*pi)
assume(theta, "real")
L11 = Lo*int((subs(N1,theta, theta + psi))^2, theta, 0, 2*pi)
simplify(L11, Steps=10)
Result:
(Lo*No^2*int(sign(sin(theta + 2*psi))^2, theta, 0, 2*pi))/4

4 Comments

The result should be No^2*pi/2.
But although I tried to restrict psi and theta to real values, MATLAB was not able to integrate
(subs(N1,theta, theta + psi))^2
Difficult to explain.
If you look at the attached code, L11 is derived from N1, integrated over theta, and L22 is derived from N2, integrated over theta.
L12 is a derived from L11 and L22, intergrated over theta.
At the end, Matlab returns a single value (L12 = 68).
I would like to add a phase offset, psi, which exists in the final equation of L12.
This way I can find L12 (single value) given say L11 (or L22) is offset from L22 by a desired offset, psi.
No idea what to call this.
Hope this helps.
Thank you,
Example that returns a single value (after a bunch of steps):
syms theta No Lo
N1 = (sym(1)/sym(2))*(No/sym(1))*sign(sin(sym(1)*theta));
L11 = Lo*int(N1^2, theta, 0, 2*pi)
N2 = piecewise((0 < theta) & (theta < pi), -(1/pi)*theta+0.5, ...
(pi < theta) & (theta < 2*pi), (1/pi)*theta-1.5);
L22 = Lo*int(N2^2,theta,0,2*pi)
L12 = Lo*int(L11*L22,0, 2*pi)
Lo = 1;
L12 = vpa(subs(L12), 4)
% L12 = 68.0 [units]
And what is your question ?
Torsten,
Walter Roberson is working this in a direction that I like.

Sign in to comment.

 Accepted Answer

syms theta psi No Lo real
assumeAlso(theta>0 & theta<2*pi)
N1 = (sym(1)/sym(2))*(No/sym(1))*sign(sin(sym(1)*theta + psi));
L11 = Lo*int((subs(N1,theta, theta + psi))^2, theta, 0, 2*pi)
L11 = 
simplify(L11, Steps=10)
ans = 
The sign of psi is not defined, so this is the best you can do.

5 Comments

Whereas if you constrain psi instead of theta
syms theta psi No Lo real
assumeAlso(psi>0 & psi<2*pi)
N1 = (sym(1)/sym(2))*(No/sym(1))*sign(sin(sym(1)*theta + psi));
L11 = Lo*int((subs(N1,theta, theta + psi))^2, theta, 0, 2*pi)
L11 = 
simplify(L11, Steps=10)
ans = 
Ok, the output appears to be piecewise (view of live editor, not as obvious with script).
So I have seen this via script so at the time I did not know what to make of it.
I understand that this results essentually defines L11 for what may be all values of psi (assuming with 0 to 2pi).
How would I continue on with this L11 result?
How may I set or fix psi with in L11 then continue???
For example (there is a question in the middle of the example):
clc
clear all
syms theta psi No Lo real
assumeAlso(psi>0 & psi<2*pi)
N1 = (sym(1)/sym(2))*(No/sym(1))*sign(sin(sym(1)*theta + psi));
L11 = Lo*int((subs(N1,theta, theta + psi))^2, theta, 0, 2*pi)
L11 = 
At this point L11 could be / is a function (piecewise) of psi.
How might I set psi (within L11) to some value/offset here then continue on with the following code???
%simplify(L11, Steps=10)
N2 = piecewise((0 < theta) & (theta < pi), -(1/pi)*theta+0.5, ...
(pi < theta) & (theta < 2*pi), (1/pi)*theta-1.5);
L22 = Lo*int(N2^2,theta,0,2*pi)
L22 = 
L12 = Lo*int(L11*L22,0, 2*pi)
L12 = 
Lo = 1, No = 1;
Lo = 1
L12 = vpa(subs(L12), 4) % L2 = xx [units]
L12 = 
5.168
I don't understand the piecewise result for L11. sign(...)^2 is always 1 (except maybe for one or two values in the interval 0<theta<2*pi depending on psi), thus the integral over sign(...)^2 will always be 2*pi.
Perhaps better question:
Given my latest code list ...
Should I stop at the ouput of L11 then rebuild the derivation of L11 with psi removed given the piecewise results with psi then continue to derive L12?
Or is there a smarter way of getting to L12 with psi part of L11?
How might I set psi (within L11) to some value/offset here then continue on with the following code???
newL11 = subs(L11, psi, DesiredValue)

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Release

R2023b

Community Treasure Hunt

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

Start Hunting!