How to solve an equation with one unknown?

49 views (last 30 days)
Ahmad Ghareeb
Ahmad Ghareeb on 28 Feb 2017
Answered: Walter Roberson on 28 Feb 2017
For example:
ss = (16*T*do)/pi*(do^4-di^4)
all variables are know except for (di). What is the code to solve it? Thanks in advance!
  3 Comments
Roger Stafford
Roger Stafford on 28 Feb 2017
I like your reply, John. Pencil and paper is certainly the right way to do that problem.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 28 Feb 2017
syms di
syms ss T do %or assign numeric values to the variables
Pi = sym('pi');
eqn = ss == (16*T*do)/Pi*(do^4-di^4);
sol = solve(eqn, di)
The result you get back will be a vector of four elements, reflecting the four roots of the quartic. You can use double(sol) to see the decimal versions of the exact solutions.
Depending on what you are solving, you might encounter cases where you see outputs such as
root(16*2^(1/2)*z^5 - 16*2^(1/2)*di^4*z - 17*pi, z, 1)
root(16*2^(1/2)*z^5 - 16*2^(1/2)*di^4*z - 17*pi, z, 2)
The form root(f(z), z, N) selects from the set of values, z, such that f(z) = 0 -- that is, the roots of the equation. You will sometimes even see this for cubic equations and it is not uncommon for quartic equations; most quintics and above will generate root() forms.

Community Treasure Hunt

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

Start Hunting!