Question

I have six parametric equations using 18 (not actually 26) different variables, 6 of which are unknown.

I could sit down with a couple of pads of paper and work out what the equations for each of the unknowns are, but is there a simple programatic solution (I'm thinking in Matlab) that will spit out the six equations I'm looking for?

EDIT: Shame this has been closed, but I guess I can see why. In case anyone is still interested, the equations are (I believe) non-linear:

r11^2 = (l_x1*s_x + m_x)^2 + (l_y1*s_y + m_y)^2
r12^2 = (l_x2*s_x + m_x)^2 + (l_y2*s_y + m_y)^2
r13^2 = (l_x3*s_x + m_x)^2 + (l_y3*s_y + m_y)^2
r21^2 = (l_x1*s_x + m_x - t_x)^2 + (l_y1*s_y + m_y - t_y)^2
r22^2 = (l_x2*s_x + m_x - t_x)^2 + (l_y2*s_y + m_y - t_y)^2
r23^2 = (l_x3*s_x + m_x - t_x)^2 + (l_y3*s_y + m_y - t_y)^2

(Squared the rs, good spot @gnovice!)

Where I need to find t_x t_y m_x m_y s_x and s_y

Why am I calculating these? There are two points p1 (at 0,0) and p2 at(t_x,t_y), for each of three coordinates (l_x,l_y{1,2,3}) I know the distances (r1 & r2) to that point from p1 and p2, but in a different coordinate system. The variables s_x and s_y define how much I'd need to scale the one set of coordinates to get to the other, and m_x, m_y how much I'd need to translate (with t_x and t_y being a way to account for rotation differences in the two systems)

Oh! And I forgot to mention, I also know that the point (l_x,l_y) is below the highest of p1 and p2, ie l_y < max(0,t_y) as well as l_y > 0 and l_y < t_y.

It does seem specific enough that I might have to just get my pad out and work it through mathematically!

Was it helpful?

Solution

If you have the Symbolic Toolbox, you can use the SOLVE function. For example:

>> solve('x^2 + y^2 = z^2','z')    %# Solve for the symbolic variable z

ans =

  (x^2 + y^2)^(1/2)
 -(x^2 + y^2)^(1/2)

You can also solve a system of N equations for N variables. Here's an example with 2 equations, 2 unknowns to solve for (x and y), and 6 parameters (a through f):

>> S = solve('a*x + b*y = c','d*x - e*y = f','x','y')
>> S.x

ans =

(b*f + c*e)/(a*e + b*d)

>> S.y

ans =

-(a*f - c*d)/(a*e + b*d)

OTHER TIPS

Are they linear? If so, then you can use principles of linear algebra to set up a 6x6 matrix that represents the system of equations, and solve for it using any standard matrix inversion routine...

if they are not linear, they you need to use numerical analysis methods.

As I recall from many years ago, I believe you then create a system of linear approximations to the non-linear equations, and solve that linear system, over and over again iteratively, feeding the answers back into the inputs each time, until some error metric gets sufficiently small to indicate you have reached the solution. It's obviously done with a computer, and I'm sure there are numerical analysis software packages that will do this for you, although I imagine that as any arbitrary system of non-linear equations can include almost infinite degree of different types and levels of complexity, that these software packages can't create the linear approximations for you, (except maybe in the most straightforward standard cases) and you will have ot do that part of the thing manually.

Yes there is (assuming these are linear equations) - you do this by creating a matrix equiation which is equivalent to your 6 linear equations, for example if you had the two equatrions:

6x + 12y = 9
7x - 8y = 14

This could be equivalently represented as:

|6  12| |a|   |9 |
|7  -8| |b| = |14|

(Where the 2 matrices are multipled together). Matlab can then solve this for the solution matrix (a, b).

I don't have matlab installed, so I'm afraid I'm going to have to leave the details up to you :-)

As mentioned above, the answer will depend on whether your equations are linear or nonlinear. For linear systems, you can set up a simple matrix system (but don't use matrix inversion, use LU decomposition (if your system is well-conditioned) ).

For non-linear systems, you'll need to use a more advanced solver, most likely some variation on Newton's method. Essentially you'll give Matlab your six equations, and ask it to simultaneously solve for the root (zero) of all of the equations. There are several caveats and complications that come into play when dealing with non-linear systems, one of which is the need for an initial guess that assigns each of your six unknown variables a value close to the true solution. Without a good initial guess, the solver may take a long time finding a solution, or may not converge to a solution at all, even if one exists.

Decades ago, MIT developed MACSYMA, a symbolic algebra system for just this kind of thing. MIT sold MACSYMA to Symbolics, which has pretty well folded, dried up, and blown away. However, because of the miracle of military funding, an early version of MACSYMA was required to be released to the government. THAT version was subsequently released under the GPL, and is continuing to be maintained, under the name MAXIMA.

See http://maxima.sourceforge.net/ for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top