Finding analytical solutions for given equations

500 Views Asked by At

I have a system of 6 equations with 6 variables. The 6 variables are $t11, t12, t13, t21, t22, t23$ and the rest of the symbols in the equations are known symbols. I want to find all the possible analytical solutions of the 6 variables $t11, t12, t13, t21, t22, t23$ as expressions of the known symbols. Here are the 6 equations (I wrote them in Matlab):

eq1 = pz1^2 + 2*pz1*t11*vz1 + t11^2*vx1^2 + t11^2*vy1^2 + t11^2*vz1^2 == qz1^2 + 2*qz1*t21*uz1 + t21^2*ux1^2 + t21^2*uy1^2 + t21^2*uz1^2
eq2 = pz2^2 + 2*pz2*t12*vz2 + t12^2*vx2^2 + t12^2*vy2^2 + t12^2*vz2^2 == qz2^2 + 2*qz2*t22*uz2 + t22^2*ux2^2 + t22^2*uy2^2 + t22^2*uz2^2
eq3 = pz3^2 + 2*pz3*t13*vz3 + t13^2*vx3^2 + t13^2*vy3^2 + t13^2*vz3^2 == qz3^2 + 2*qz3*t23*uz3 + t23^2*ux3^2 + t23^2*uy3^2 + t23^2*uz3^2
eq4 = pz1*pz2 + pz2*t11*vz1 + pz1*t12*vz2 + t11*t12*vx1*vx2 + t11*t12*vy1*vy2 + t11*t12*vz1*vz2 == qz1*qz2 + qz2*t21*uz1 + qz1*t22*uz2 + t21*t22*ux1*ux2 + t21*t22*uy1*uy2 + t21*t22*uz1*uz2
eq5 = pz2*pz3 + pz3*t12*vz2 + pz2*t13*vz3 + t12*t13*vx2*vx3 + t12*t13*vy2*vy3 + t12*t13*vz2*vz3 == qz2*qz3 + qz3*t22*uz2 + qz2*t23*uz3 + t22*t23*ux2*ux3 + t22*t23*uy2*uy3 + t22*t23*uz2*uz3
eq6 = pz1*pz3 + pz3*t11*vz1 + pz1*t13*vz3 + t11*t13*vx1*vx3 + t11*t13*vy1*vy3 + t11*t13*vz1*vz3 == qz1*qz3 + qz3*t21*uz1 + qz1*t23*uz3 + t21*t23*ux1*ux3 + t21*t23*uy1*uy3 + t21*t23*uz1*uz3

Notice that each equation is of the form: $eq_i=left\_expression==right\_expression$

The equations are for sure correct (I checked them with known values and known solutions for $t11, t12, t13, t21, t22, t23$ and I indeed got equality of the left and right expressions in each equation).

But I need to get all the possible solutions for the general case.

When I tried to solve the equations using Matlab 'solve' command, it didn't finish the run (I waited for more than an hour).

Can anyone suggest other ways of solving the equations?

The equations look solvable since they are all second degree polynomial equations (of 6 variables).

Any chance that anyone here can try to solve the equations using 'Mathematica' or 'Maple' programs (since I don't have them). Or at least tell me if they are solvable in these programs and if so, I will buy the programs (the university will..).

Here is the full code in matlab so you can see how I built the equations (if anyone here is able to translate the code to Mathematica/Maple and check if the the equations are solvable there)

clear;
close all;
clc;

%The folowing 6 symbols are the UNKNOWN variables
syms t11 t12 t13 %parameters of the 3 lines of the first set
syms t21 t22 t23 %parameters of the 3 lines of the second set   

%The folowing symbols are the KNOWN variables
syms px1 py1 pz1
syms px2 py2 pz2
syms px3 py3 pz3

syms vx1 vy1 vz1
syms vx2 vy2 vz2
syms vx3 vy3 vz3    

syms qx1 qy1 qz1
syms qx2 qy2 qz2
syms qx3 qy3 qz3

syms ux1 uy1 uz1
syms ux2 uy2 uz2
syms ux3 uy3 uz3

%Trying to make the equations simpler, I assume all 6 lines pass through
%a point on the Z axis (but I prefer the general case)
lines1_points = [0 0 0 ; 0 0 0 ; pz1 pz2 pz3]; 
%lines1_points = [px1 px2 px3 ; py1 py2 py3 ; pz1 pz2 pz3];
lines1_vecs = [vx1 vx2 vx3 ; vy1 vy2 vy3 ; vz1 vz2 vz3];
lines2_points = [0 0 0 ; 0 0 0 ; qz1 qz2 qz3];
%lines2_points = [qx1 qx2 qx3 ; qy1 qy2 qy3 ; qz1 qz2 qz3];
lines2_vecs = [ux1 ux2 ux3 ; uy1 uy2 uy3 ; uz1 uz2 uz3];

vars1 = diag([t11 t12 t13]);
vars2 = diag([t21 t22 t23]);

T1 = lines1_points+lines1_vecs*vars1;
T2 = lines2_points+lines2_vecs*vars2;

T1_transpose = T1.';
T2_transpose = T2.';

part1 = T1_transpose*T1;
part2 = T2_transpose*T2;

eqs_symmetric_matrix = part1==part2;
expanded_eqs_symmetric_matrix = expand(eqs_symmetric_matrix);
%6 equations of the top upper matrix (first 3 equations are the diagonal)
eq1 = expanded_eqs_symmetric_matrix(1,1)
eq2 = expanded_eqs_symmetric_matrix(2,2)
eq3 = expanded_eqs_symmetric_matrix(3,3)
eq4 = expanded_eqs_symmetric_matrix(1,2)
eq5 = expanded_eqs_symmetric_matrix(2,3)
eq6 = expanded_eqs_symmetric_matrix(1,3)

eqs = [eq1; eq2; eq3; eq4; eq5; eq6];
fprintf('Trying to solve the equations (matlab does not succeed to solve the equations)\n');
[t11_sol,t12_sol,t13_sol,t21_sol,t22_sol,t23_sol] = solve(eqs,[t11,t12,t13,t21,t22,t23]);
fprintf('Finished solving the equations\n');

I will appreciate any help!

Thanks

Update: Using the assumption that all the lines pass through the same point [0 0 z] and using the fact that all the directional vectors of the lines are unit. The new 6 equations are now:

eq1 = t11^2 + z^2 + 2*t11*z*(- vx1^2 - vy1^2 + 1)^(1/2) == t21^2 + z^2 + 2*t21*z*(- ux1^2 - uy1^2 + 1)^(1/2)
eq2 = t12^2 + z^2 + 2*t12*z*(- vx2^2 - vy2^2 + 1)^(1/2) == t22^2 + z^2 + 2*t22*z*(- ux2^2 - uy2^2 + 1)^(1/2)
eq3 = t13^2 + z^2 + 2*t13*z*(- vx3^2 - vy3^2 + 1)^(1/2) == t23^2 + z^2 + 2*t23*z*(- ux3^2 - uy3^2 + 1)^(1/2)
eq4 = z^2 + t11*z*(- vx1^2 - vy1^2 + 1)^(1/2) + t12*z*(- vx2^2 - vy2^2 + 1)^(1/2) + t11*t12*vx1*vx2 + t11*t12*vy1*vy2 + t11*t12*(- vx1^2 - vy1^2 + 1)^(1/2)*(- vx2^2 - vy2^2 + 1)^(1/2) == z^2 + t21*z*(- ux1^2 - uy1^2 + 1)^(1/2) + t22*z*(- ux2^2 - uy2^2 + 1)^(1/2) + t21*t22*ux1*ux2 + t21*t22*uy1*uy2 + t21*t22*(- ux1^2 - uy1^2 + 1)^(1/2)*(- ux2^2 - uy2^2 + 1)^(1/2)
eq5 = z^2 + t12*z*(- vx2^2 - vy2^2 + 1)^(1/2) + t13*z*(- vx3^2 - vy3^2 + 1)^(1/2) + t12*t13*vx2*vx3 + t12*t13*vy2*vy3 + t12*t13*(- vx2^2 - vy2^2 + 1)^(1/2)*(- vx3^2 - vy3^2 + 1)^(1/2) == z^2 + t22*z*(- ux2^2 - uy2^2 + 1)^(1/2) + t23*z*(- ux3^2 - uy3^2 + 1)^(1/2) + t22*t23*ux2*ux3 + t22*t23*uy2*uy3 + t22*t23*(- ux2^2 - uy2^2 + 1)^(1/2)*(- ux3^2 - uy3^2 + 1)^(1/2)
eq6 = z^2 + t11*z*(- vx1^2 - vy1^2 + 1)^(1/2) + t13*z*(- vx3^2 - vy3^2 + 1)^(1/2) + t11*t13*vx1*vx3 + t11*t13*vy1*vy3 + t11*t13*(- vx1^2 - vy1^2 + 1)^(1/2)*(- vx3^2 - vy3^2 + 1)^(1/2) == z^2 + t21*z*(- ux1^2 - uy1^2 + 1)^(1/2) + t23*z*(- ux3^2 - uy3^2 + 1)^(1/2) + t21*t23*ux1*ux3 + t21*t23*uy1*uy3 + t21*t23*(- ux1^2 - uy1^2 + 1)^(1/2)*(- ux3^2 - uy3^2 + 1)^(1/2)
2

There are 2 best solutions below

6
On

In Maple syntax these equations would be:

eq1 := t11^2*vx1^2+t11^2*vy1^2+t11^2*vz1^2+2*pz1*t11*vz1+pz1^2
  = t21^2*ux1^2+t21^2*uy1^2+t21^2*uz1^2+2*qz1*t21*uz1+qz1^2;
eq2 := t12^2*vx2^2+t12^2*vy2^2+t12^2*vz2^2+2*pz2*t12*vz2+pz2^2
  = t22^2*ux2^2+t22^2*uy2^2+t22^2*uz2^2+2*qz2*t22*uz2+qz2^2;
eq3 := t13^2*vx3^2+t13^2*vy3^2+t13^2*vz3^2+2*pz3*t13*vz3+pz3^2
  = t23^2*ux3^2+t23^2*uy3^2+t23^2*uz3^2+2*qz3*t23*uz3+qz3^2;
eq4 := t11*t12*vx1*vx2+t11*t12*vy1*vy2+t11*t12*vz1*vz2+pz1*t12*vz2+pz2*t11*vz1+pz1*pz2
  = t21*t22*ux1*ux2+t21*t22*uy1*uy2+t21*t22*uz1*uz2+qz1*t22*uz2+qz2*t21*uz1+qz1*qz2; 
eq5 := t12*t13*vx2*vx3+t12*t13*vy2*vy3+t12*t13*vz2*vz3+pz2*t13*vz3+pz3*t12*vz2+pz2*pz3
  = t22*t23*ux2*ux3+t22*t23*uy2*uy3+t22*t23*uz2*uz3+qz2*t23*uz3+qz3*t22*uz2+qz2*qz3; 
eq6 := t11*t13*vx1*vx3+t11*t13*vy1*vy3+t11*t13*vz1*vz3+pz1*t13*vz3+pz3*t11*vz1+pz1*pz3
  = t21*t23*ux1*ux3+t21*t23*uy1*uy3+t21*t23*uz1*uz3+qz1*t23*uz3+qz3*t21*uz1+qz1*qz3;

However, given that this system solves a very general geometric problem, I would not expect it to have a compact solution. Indeed, my attempts at getting a Groebner basis in the most efficient way possible in Maple 2017 consumes all of my available system memory almost instantly, and then fails.

Groebner:-Basis((lhs-rhs)~({eq1, eq2, eq3, eq4, eq5, eq6}),
 tdeg(t23, t22, t21, t13, t12, t11, vy3, vy2, vy1, vx3, vx2, vx1, qz3,
 qz2, qz1, pz3, pz2, pz1, uy3, uy2, uy1, ux3, ux2, ux1, vz3, vz2, vz1,
 uz3, uz2, uz1));

This is pretty good evidence that the closed form solution to this system is probably too large to be useful.

You'll probably need to consider a different approach to this problem.

9
On

Referring back to the original problem we are to solve the matrix equation $$ \bbox[lightyellow] { \overline {{\bf T}_{\,{\bf 1}} } \;{\bf T}_{\,{\bf 1}} = \overline {{\bf T}_{\,{\bf 2}} } \;{\bf T}_{\,{\bf 2}} } \tag{1.a}$$ where the overline denotes the transposed, and where $$ \bbox[lightyellow] { {\bf T}_{\,{\bf 1}} = {\bf P}_{\,{\bf 1}} + {\bf V}_{\,{\bf 1}} \,{\bf \Lambda }_{\,{\bf 1}} \quad {\bf T}_{\,{\bf 2}} = {\bf P}_{\,{\bf 2}} + {\bf V}_{\,{\bf 2}} \,{\bf \Lambda }_{\,\,{\bf 2}} } \tag{1.b}$$ with
$ {\bf V}_{\,{\bf 1}}$ ,$ {\bf V}_{\,{\bf 2}}$ , $ {\bf P}_{\,{\bf 1}}$ ,$ {\bf P}_{\,{\bf 2}} $ given matrices
$ {\bf \Lambda }_{\,{\bf 1}}$, ${\bf \Lambda }_{\,{\bf 2}}$ diagonal matrices whose elements are the unknowns.

So the LHS of the equation can be written as $$ \bbox[lightyellow] { \eqalign{ & \overline {{\bf T}_{\,{\bf 1}} } \;{\bf T}_{\,{\bf 1}} = \left( {\overline {{\bf P}_{\,{\bf 1}} } + {\bf \Lambda }_{\,{\bf 1}} \overline {{\bf V}_{\,{\bf 1}} } \,} \right)\left( {{\bf P}_{\,{\bf 1}} + {\bf V}_{\,{\bf 1}} \,{\bf \Lambda }_{\,{\bf 1}} } \right) = \cr & = \left( {\overline {{\bf P}_{\,{\bf 1}} } {\bf P}_{\,{\bf 1}} + \overline {{\bf P}_{\,{\bf 1}} } {\bf V}_{\,{\bf 1}} \,{\bf \Lambda }_{\,{\bf 1}} + {\bf \Lambda }_{\,{\bf 1}} \overline {{\bf V}_{\,{\bf 1}} } {\bf P}_{\,{\bf 1}} + {\bf \Lambda }_{\,{\bf 1}} \overline {{\bf V}_{\,{\bf 1}} } {\bf V}_{\,{\bf 1}} \,{\bf \Lambda }_{\,{\bf 1}} } \right) = \cr & = \overline {\left( {{\bf \Lambda }_{\,{\bf 1}} + {\bf V}_{\,{\bf 1}} ^{ - 1} {\bf P}_{\,{\bf 1}} } \right)} \;\overline {{\bf V}_{\,{\bf 1}} } \,{\bf V}_{\,{\bf 1}} \;\left( {{\bf \Lambda }_{\,{\bf 1}} + {\bf V}_{\,{\bf 1}} ^{ - 1} {\bf P}_{\,{\bf 1}} } \right) \cr} } \tag{2}$$ The matrix equation, being symmetric, translates into a system of $6$ quadratic equations into the $6$ unknowns, $\lambda _{\,1,\,\,k}$,$\lambda _{\,2,\,\,k}$, with $k=1,2,3$.

Equating the diagonal elements, we get $3$ equations of the type $$ \bbox[lightyellow] { b_{\,1,\,\,k} \,\lambda _{\,1,\,\,k} ^{\,2} + c_{\,1,\,\,k} \,\lambda _{\,1,\,\,k} + d_{\,1,\,\,k} = b_{\,2,\,\,k} \,\lambda _{\,2,\,\,k} ^{\,2} + c_{\,2,\,\,k} \,\lambda _{\,2,\,\,k} + d_{\,2,\,\,k} } \tag{3}$$ where
- each (lateral) side is the length of one edge of the pyramid from the origin ($OT$ in the original post) and is therefore non-negative;
- each side is therefore a vertical parabola, convex, standing totally above the $x$ axis;
- the equality means that we are looking for a $y=s_k$ intersecting both parabolas;
- because of the geometrical stem of the problem, we can limit and consider only positive values of the abscissas $\lambda$, since we can in any case shift appropriately the points $P$ and / or change the sign of the vectors $V$.

It remains however the possibility that a parabola might have the vertex at a positive abscissa, which is the case when the normal from the origin to a line, intercepts it on the positive side of the (corresponding) $\lambda$.

By plotting the three couples of parabolas we get a picture of the situation, and can establish a minimum for each $s_k$.

We can now solve the three equations above to obtain $\lambda _{\,1,\,\,k} $ and $\lambda _{\,2,\,\,k} $ as functions of $s_k$. Concerning the sign in front of the $\sqrt{\;}$, we can take only the plus for the parabolas with the vertex in the negative abscissas. For the others we shall appropriately consider also the minus.

Now we can feed the functions found for the $\lambda$s into the three remaining equations given by the off-diagonal elements $$ \bbox[lightyellow] { \left( {\overline {{\bf T}_{\,{\bf 1}} } \;{\bf T}_{\,{\bf 1}} } \right)_{\,1,\,2} - \left( {\overline {{\bf T}_{\,{\bf 2}} } \;{\bf T}_{\,{\bf 2}} } \right)_{\,1,\,2} = 0,\;\; \cdots } \tag{4}$$ to get $3$ equations in the following combination of the three unknowns $(s_{1} ,\, s_{2}),(s_{1} ,\, s_{3}),(s_{2} ,\, s_{3}) $, but they shall be replicated for the allowed combinations of $\pm$ signs in the $\lambda$s expressions, as commented above.

In the geometric perspective, we are at the point where, having fixed the pyramids edges to mutually have equal length $s_k$, we are going to vary these so that the three dot products becomes equal.

Concerning the practical solution of equations (4), their structure (see example below) does not allow to look for a straight method.

We can only think to a successive approximations method.

However we reached a stage that allows us to plot the three surfaces resulting from (4), and visually identify if and where could be a solution.
The picture below an example. By successive "zooming" a solution has been found to exist in the range indicated.
But also, a second solution looks to be present around $s_{1}=2.03, \, s_{2}=2.75, \, s_{3}=5.8$, which complicates the picture.

Rot_3Lines_2

At present, I did not investigate further on these solutions, and did not go back to the triangles they represent to check whether they can be rotated one onto the other.