Solving symbolically a system of 8 non-linear equations
4 views (last 30 days)
Show older comments
Hi,
I have got a system of 8 equations that are non-linear as below (unknowns are x, y and z).
I have tried to solve with the Matlab function solve, but this results in an empty sym 0 by 1. When, I only solve the first 6, I have got a parameterised solution, I would have thought that having 8 equations with only 3 unknowns would be easy to solve. Could you help?
Best,
FD
clear all; close all;
%knowns and their interval
syms A B
assume([A, B], 'real') % A and B are real
assume([A, B], 'positive') % A and B are >0
assume(0.2 <= A <= 0.4) % A takes values between 0.2 and 0.4
syms ang D
assume([ang, D], 'real') % angle and D are real
assume([ang, D] > 0) % angle and D are >0
assume(0.2 <= D <= 1) % D takes values between 0.2 and 1
assume(40 <= ang <= 90) % angle takes values between 40deg and 90deg
%unknowns to determine
syms x y z; assume([x, y, z], 'real'); assume([x, y, z] > 0) % unknowns are real and >0
%LHS terms of equality
p2_z11 = B/A;
p2_z12 = -(B*exp(sym('1i')*deg2rad(ang)))/D;
p2_z22 = (B*A*(D+exp(2*sym('1i')*deg2rad(ang))))/(D*D*(1-A));
p2_det = p2_z11 * p2_z22 - p2_z12 * p2_z12;
p2z2p = [p2_z11, p2_z12; p2_z12, p2_z22]
p2abcd_A = p2_z11 / p2_z12;
p2abcd_B = p2_det / p2_z12;
p2abcd_C = 1 / p2_z12;
p2abcd_D = p2_z22 / p2_z12;
p2abcd = [p2abcd_A, p2abcd_B; p2abcd_C, p2abcd_D]
%RHS terms of equality
x_A = cosd(ang);
x_B = sym('1i')*x*sind(ang);
x_C = sym('1i')*(1/x)*sind(ang);
x_D = cosd(ang);
x_ABCD = [x_A, x_B ; x_C, x_D]
z_A = 1;
z_B = 0;
z_C = 1/z;
z_D = 1;
z_ABCD = [z_A, z_B ; z_C, z_D]
y_A = cosd(2*ang);
y_B = sym('1i')*y*sind(2*ang);
y_C = sym('1i')*(1/y)*sind(2*ang);
y_D = cosd(2*ang);
y_ABCD = [y_A, y_B ; y_C, y_D]
p3abcd = x_ABCD * z_ABCD * y_ABCD
p3abcd_A = p3abcd(1,1);
p3abcd_B = p3abcd(1,2);
p3abcd_C = p3abcd(2,1);
p3abcd_D = p3abcd(2,2);
%Solving equations: equating real and imag term to term LHS to RHS
equations = [real(p2abcd_A) == real(p3abcd_A),...
imag(p2abcd_A) == imag(p3abcd_A),...
real(p2abcd_B) == real(p3abcd_B),...
imag(p2abcd_B) == imag(p3abcd_B),...
real(p2abcd_C) == real(p3abcd_C),...
imag(p2abcd_C) == imag(p3abcd_C),...
real(p2abcd_D) == real(p3abcd_D),...
imag(p2abcd_D) == imag(p3abcd_D),...
];
equations'
sol_1shot = solve(equations, [x, z, y ], 'ReturnConditions',true)
sol_6first = solve(equations(1:6), [x, z, y ], 'ReturnConditions',true)
8 Comments
Torsten
on 15 Sep 2023
Edited: Torsten
on 15 Sep 2023
Could you explain why "t, y1 and y2 arbitrarily chosen, x1 an odd multiple of pi/2 and x2 a multiple of pi give an infinite number of solutions." ?
Choose arbitrary values for t, y1 and y2, choose x1 an odd multiple of pi/2 and x2 a multiple of pi, insert these values into your equations and you will see that all 8 are satisfied.
What if I would like to impose not having x1 and x2 taking those values, do the code lines below impose the condition to "solve"?
The condition on x1 is x1 ~= (2*n+1)*pi/2, not x1*(2*n+1) ~= pi/2. But "solve" will most probably only repeat your equations together with your assumptions. If "solve" without the option "'ReturnConditions',true returns an empty solution (I think this is the case here, isn't it ?), you cannot expect an even more complicated solution with this option.
Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





