Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Solve Variables

Subject: Solve Variables

From: Armen

Date: 6 Jul, 2011 21:10:24

Message: 1 of 3

Hey everybody:

I'm relatively new to matlab, so I'm sure my question has a straightforward solution. I have a very complex quartic equation whose coefficients are defined by other functions and set equal to defined variables. I'm trying to use the solve function, but (understandably) when I cast this expression it does not reference the previously-defined variables. I was wondering how I would get solve to recognize them - perhaps cast them using syms?

Here's the code:

S = solve('x^4*(u^2 - d*n^2) + x^3*(2*u*v - e*n^2 - 2*d*m*n) + x^2*(v^2 + 2*u*w - f*n^2 - d*m^2 - 2*e*m*n) + x*(2*v*w - 2*f*m*n - e*m^2) + (w^2 - f*m^2)');

where:

g = (Rac * (b/Rab) - cx)/cy;
h = (c^2 - Rac^2 + Rac * Rab * (1-(b/Rab)^2))/(2*cy);
d = -(1 - (b/Rab)^2 + g^2);
e = b*(1 - (b/Rab)^2) - 2*g*h;
f = (Rab^2/4) * (1 - (b/Rab)^2)^2 - h^2;
u = (beta^2 + d*sz^2)/(4*a^2) - (1 + g^2 + d);
v = (alpha*beta + e*sz^2)/(4*a^2) - (2*qx + 2*qy +e +2*g*h);
w = (alpha^2 + 4*f*sz^2)/(16*a^2) - (Qm^2 + 2*h*qy + h^2 + f);
m = -sz*alpha/(4*a^2) + 2*qz;
n = -sz*beta/(2*a^2);

and all other variables defined in the above expressions are user defined.

Thanks for your help.

am

Subject: Solve Variables

From: Roger Stafford

Date: 6 Jul, 2011 22:56:07

Message: 2 of 3

"Armen" wrote in message <iv2j00$oks$1@newscl01ah.mathworks.com>...
> Hey everybody:
>
> I'm relatively new to matlab, so I'm sure my question has a straightforward solution. I have a very complex quartic equation whose coefficients are defined by other functions and set equal to defined variables. I'm trying to use the solve function, but (understandably) when I cast this expression it does not reference the previously-defined variables. I was wondering how I would get solve to recognize them - perhaps cast them using syms?
>
> Here's the code:
>
> S = solve('x^4*(u^2 - d*n^2) + x^3*(2*u*v - e*n^2 - 2*d*m*n) + x^2*(v^2 + 2*u*w - f*n^2 - d*m^2 - 2*e*m*n) + x*(2*v*w - 2*f*m*n - e*m^2) + (w^2 - f*m^2)');
>
> where:
>
> g = (Rac * (b/Rab) - cx)/cy;
> h = (c^2 - Rac^2 + Rac * Rab * (1-(b/Rab)^2))/(2*cy);
> d = -(1 - (b/Rab)^2 + g^2);
> e = b*(1 - (b/Rab)^2) - 2*g*h;
> f = (Rab^2/4) * (1 - (b/Rab)^2)^2 - h^2;
> u = (beta^2 + d*sz^2)/(4*a^2) - (1 + g^2 + d);
> v = (alpha*beta + e*sz^2)/(4*a^2) - (2*qx + 2*qy +e +2*g*h);
> w = (alpha^2 + 4*f*sz^2)/(16*a^2) - (Qm^2 + 2*h*qy + h^2 + f);
> m = -sz*alpha/(4*a^2) + 2*qz;
> n = -sz*beta/(2*a^2);
>
> and all other variables defined in the above expressions are user defined.
>
> Thanks for your help.
>
> am
- - - - - - - - - - - -
  You are apparently trying to obtain a solution as a single expression (or rather four expressions) in terms of your original variables, Ras, b, cx, cy, etc. I would strongly advise against that. It would be such a bewildering maze of complexity as to be totally useless in my opinion. Why not be content with just the code you have with g, h, d, e, etc., combined with the expressions for the five coefficients of the quartic and then simply use matlab's 'roots' function to get the quartic's four roots? You can consider that as an efficient recipe for finding these roots.

  If your polynomial had one additional degree making it a quintic, such an undertaking would be impossible in terms of elementary algebraic functions, as has been proven. The quartic does have a known general solution but it is messy.

  In any case I don't think you will be able to persuade the 'solve' function to provide the specific roots to your quartic even directly in terms of its five coefficients. If you can, it would outdo my own 'solve', which stubbornly refuses to divulge even the roots of a quadratic equation.

Roger Stafford

Subject: Solve Variables

From: Steven_Lord

Date: 7 Jul, 2011 04:06:09

Message: 3 of 3



"Armen " <armen.melikian@gmail.com> wrote in message
news:iv2j00$oks$1@newscl01ah.mathworks.com...
> Hey everybody:
>
> I'm relatively new to matlab, so I'm sure my question has a
> straightforward solution. I have a very complex quartic equation whose
> coefficients are defined by other functions and set equal to defined
> variables. I'm trying to use the solve function, but (understandably)
> when I cast this expression it does not reference the previously-defined
> variables. I was wondering how I would get solve to recognize them -
> perhaps cast them using syms?
>
> Here's the code:
>
> S = solve('x^4*(u^2 - d*n^2) + x^3*(2*u*v - e*n^2 - 2*d*m*n) + x^2*(v^2 +
> 2*u*w - f*n^2 - d*m^2 - 2*e*m*n) + x*(2*v*w - 2*f*m*n - e*m^2) + (w^2 -
> f*m^2)');

Do NOT specify the input to the SOLVE function as a string.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us