How do I solve for a variable?

6 views (last 30 days)
Jason Cardillo
Jason Cardillo on 9 Feb 2016
Commented: Walter Roberson on 10 Feb 2016
I am trying to solve for a variable, and I'm pretty sure I have the code written correctly but for some reason it doesn't like it. I wrote:
syms x
eqn = 2943*log((2943*x-1)/(2943*0.2*x)) + 2305.35*log((2305.35*x-1)/(2305.35*0.3*x)) == 6.2;
solve(eqn,x)
but it gives me this response in the command window:
Warning: Possibly spurious solutions. [solvelib::checkSolutions]
ans =
RootOf(some infinitely long number)
Any ideas?

Answers (1)

Walter Roberson
Walter Roberson on 9 Feb 2016
Does the first 2305.35 mean 230535/100, or does it mean 230535/100 +/- 5/1000 ? Does the second 2305.35 mean the same structure as the first? If so then in the +/- case could the second 2305.35 be towards the top end of the 230535/100 + 5/1000 range but the first one be near the bottom of the 230535/100 - 5/1000 range?
Is the 0.2 the same thing as 1/5 or does it mean 1/5 +/- 5/100 or does it mean 1/5 +- 2^(-55) (the normal MATLAB interpretation) ?
Basically, if you have a floating point number in your equation, you should not be using solve() because solve() is for exact algebraic solutions, and exact algebraic solutions are GIGO (Garbage In, Garbage Out) when the inputs are imprecise. In such cases you should use vpasolve() to look for a [software] numeric solution.
When I convert the numbers as if the decimal places were exact numbers, the symbolic package I am using is taking a fair time to come up with a solution.
  2 Comments
Jason Cardillo
Jason Cardillo on 9 Feb 2016
Yeah those are decimal points, so it should be 1/5 and I'm not sure what the 2305.35 would be as a fraction.
So if that doesn't work I don't quit understand what I need to do in order to make it work. Can you help me with that?
Walter Roberson
Walter Roberson on 10 Feb 2016
Instead of using
solve(eqn,x)
use
vpasolve(eqn,x)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!