Problem with solving a quadratic equation

Hello everybody!:)
I would need some help in solving a quadratic equation, where I have to find the two solutions for the variable "z" in function of many parameters
the equation is pretty long and I did the following steps:
syms d N m h b c A U R P k y z
I = ((d+1)/d)*z^(1/d)*N^(1/d)*b-3*c*z^2-U*A*h^k+P*h+R*A-m-h*P^(1+y); (I is the long euqation)
solve(I)
; the answer I got was:
ans =
log(-(m - P*h + 3*c*z^2 - A*R + A*U*h^k - (N^(1/d)*b*z^(1/d)*(d + 1))/d)/h)/log(P) - 1
Now, are the two solutions coincident? (I do not understand why I only got one of them)
But, main issue, how come I have the variable (z) in the root???? It should not be there!
Maybe I did some mistake..I don't know:/ Any help would be really appreciated!
I apologize if maybe this looks stupid but I am a beginner with matlab
Thank you!
Kodi

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 15 Dez. 2013
Bearbeitet: Walter Roberson am 15 Dez. 2013

0 Stimmen

You did not specify which variable to solve for, so it picked "y".
Note: because of the z^(1/d) term, the expression is not quadratic in z.

Weitere Antworten (2)

Kodi
Kodi am 15 Dez. 2013

0 Stimmen

Hi Walter, thank you for your kind answer!
Yes, it is not properly quadratic (it's of second degree).
Could you please tell me how can I specify to solve it for z?
Thank you very much!

4 Kommentare

solve(I,z)
There is no closed form solution in general, but there might be closed form solutions for particular values of "d"
Kodi
Kodi am 15 Dez. 2013
True. But..how can I set the equation in matlab, then?
That's what I can't understand:(
Kodi
Kodi am 15 Dez. 2013
because when I type "Solve(I,z)" it gives me as answer [empty sym] :/
Walter Roberson
Walter Roberson am 15 Dez. 2013
You can do the solve(). It will return a form involving RootOf(), which the symbolic toolbox knows how to reason about. RootOf(f(x),x) means "the set of values, x, such that f(x) is 0".
When you eventually substitute in enough actual values for your parameters, the Symbolic Toolbox is sometimes able to break down the expression into closed form solutions. When all parameters have been given values, the Symbolic Toolbox is able to find numeric solutions, if you use vpa() or double(). However, the Symbolic Toolbox is often unable to find all solutions in such situations; in some cases it is not able to find any numeric solutions at all even though real-valued solutions exist.

Melden Sie sich an, um zu kommentieren.

Kodi
Kodi am 15 Dez. 2013

0 Stimmen

Thank you very much!
Only, I think I'm doing some typing mistakes as I can't obtain the roots..
If I do not bother you, could you please write me all the passages? (I think it's very quick)
Thank you so much!

4 Kommentare

Walter Roberson
Walter Roberson am 15 Dez. 2013
Bearbeitet: Walter Roberson am 15 Dez. 2013
therootssym = solve(((d+1)/d)*z^(1/d)*N^(1/d)*b-3*c*z^2-U*A*h^k+P*h+R*A-m-h*P^(1+y), z);
As noted above, you will likely get a RootOf() answer. After that, if you have values for the variables,
some_values_for_vars = num2cell(rand(1,12)); %whatever values are suitable
theroots_numeric = double( subs(theroomssym, {d, N, m, h, b, c, A, U, R, P, k, y}, some_values_for_vars) )
Kodi
Kodi am 15 Dez. 2013
Dear Dr. Roberson,
thank you very much for your kind help.
I tried to do this, but when I type
therootssym = solve(((d+1)/d)*z^(1/d)*N^(1/d)*b-3*c*z^2-U*A*h^k+P*h+R*A-m-h*P^(1+y), z);
I subsequently get:
Warning: Explicit solution could not be found. > In solve at 83
and then I'm blocked
:/
Then you will need to work numerically, which is not unexpected. Use fsolve or something like that.
Define values for all of your variables except z. Then
initial_guess = 1; %why not
fun = @(z) ((d+1)/d)*z^(1/d)*N^(1/d)*b-3*c*z^2-U*A*h^k+P*h+R*A-m-h*P^(1+y);
approximate_z = fsolve(fun, initial_guess);
Kodi
Kodi am 16 Dez. 2013
Thank you very much!!

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

am 15 Dez. 2013

Kommentiert:

am 16 Dez. 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by