How to find the solution of a system of equations with two known partial derivatives ?
2 views (last 30 days)
Show older comments
Hello everyone,
I'm trying to find the solution to a system of equations with two known partial derivatives. As I am in a study with very small displacements, I consider the net variations equal to the partial derivatives...
The code I use is not correct. The equations equ_8 and equ_9 are false because when compiled it gives 0==169/10000 and 0==29/10000. Furthermore, I think that forcing the study in alpha_0 by supervising alpha as I do in the "range" is really not the solution!
Can you help me please?
% * equ_1 to equ_7 represent a macanical system
% * I can only measure alpha (absolute) and l1 & L2 (relative) therefore the
% variations of l1 and l2
% * By measurement I know the variation of alpha compared to l1 at alpha_0
% and the variation of alpha compared to l2 at alpha_0
% * ==> I try to know the values of l1 and l2 at alpha_0
a1=150;
a2=150;
d=2910;
P=1;
alpha_0=0.0196;
syms alpha x y l1 l2 X1 X2 Y1 Y2
equ_1=l1^2==(x-a1*cos(alpha)+d)^2+(y-a1*sin(alpha))^2;
equ_2=l2^2==(x+a2*cos(alpha)-d)^2+(y+a2*sin(alpha))^2;
equ_3=X1+X2==0;
equ_4=Y1+Y2-P==0;
equ_5=a1*(X1*sin(alpha)-Y1*cos(alpha)) == a2*(X2*sin(alpha)-Y2*cos(alpha));
equ_6=Y1/X1==(y-a1*sin(alpha))/(x-a1*cos(alpha)+d);
equ_7=Y2/X2==(y+a2*sin(alpha))/(x+a2*cos(alpha)-d);
equ_8=diff(alpha,l1)==0.0169;
equ_9=diff(alpha,l2)==0.0029;
equations = [equ_1 equ_2 equ_3 equ_4 equ_5 equ_6 equ_7 equ_8 equ_9];
vars = [alpha x y l1 l2 X1 X2 Y1 Y2];
range = [alpha_0-0.1 alpha_0+0.1 ; -2900 2900 ; 0 -2400 ; 0 6000 ; 0 6000 ; -10 0 ; 0 10 ; 0 1 ; 0 1];
S=vpasolve(equations,vars,range);
l1_0 = S.l1;
l2_0 = S.l2;
3 Comments
John D'Errico
on 23 Sep 2024
This is making little sense. alpha is apparently a (unknown) number. You define it as that, and use it as such. And you apparently want to solve for alpha as a number, not as a function.
But then you want to define alpha as a function of two other variables, that is, l1 and l2. You cannot differentiate it unless alpha is a function of those variables.
And you are clearly not trying to solve a differential equation, so this all makes little sense. You probably need to explain what you want to do better, more clearly.
Answers (1)
Arnav
on 25 Nov 2024
Since alpha is not a function of l1 and l2, it cannot be differentiated with respect to them. Equations 1 and 2 relate alpha, l1 and l2 in an implicit manner. From this, we can derive an implicit form of the partial derivatives using the chain rule as shown:

F1 = (x-a1*cos(alpha)+d)^2+(y-a1*sin(alpha))^2 - l1^2;
F2 = (x+a2*cos(alpha)-d)^2+(y+a2*sin(alpha))^2 - l2^2;
equ_8 = -diff(F1, l1) / diff(F1, alpha) == 0.0169;
equ_9 = -diff(F2, l2) / diff(F2, alpha) == 0.0029;
You may refer to the follow link for more information about symbolic differentiation: https://www.mathworks.com/help/symbolic/sym.diff.html
See if it helps you.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!