solve three non linear power equations
4 次查看(过去 30 天)
显示 更早的评论
I have three equations. I want to solve kindly help me.
x*10^y+z=5
x*25^y+z=4.95
x*30^y+z=4.89
0 个评论
回答(3 个)
Star Strider
2017-7-27
Try this (requires the Symbolic Math Toolbox):
syms x y z
assume(x > 0)
M = [x*10^y+z==5; x*25^y+z==4.95; x*30^y+z==4.89];
[xsol,ysol zsol] = vpasolve(M, [x,y,z], 'random',true)
There are several solutions. Experiment with starting values and different states for 'random'.
0 个评论
Sarah Gilmore
2017-7-27
To solve your system of three non-linear equations, you can use the fsolve function. In one matlab function, define the following:
function F = root3d(x)
F(1) = x(1)*10^x(2) + x(3) - 5;
F(2) = x(1)*25^x(2) + x(3) - 4.95;
F(3) = x(1)*30^x(2) + x(3) - 4.89;
end
Note that the three equations are written in F(x) = 0 form and the three variables, x, y and z are replaced by x(1), x(2), x(3). x is a 1x3 vector in this case. Now, in a separate matlab script file write the following code:
x0 = [5 4.95 4.89];
x = fsolve(@root3d, x0)
x0 is your initial guess for the values of x, y and z fsolve uses to the solve the system. The first argument in fsolve, @root3d, is an anonymous function. The second argument, x0, is the input passed to root3d.
To learn more about anonymous functions, check out the following link to matlab's documentation:
To learn more about fsolve and look at more examples, check out this link:
0 个评论
John D'Errico
2017-7-27
编辑:John D'Errico
2017-7-27
Do it mainly with pencil and paper?
x*(10^y - 25^y) = 5 - 4.95
x*(10^y - 30^y) = 5 - 4.89
Now take the ratio.
(10^y - 25^y)/(10^y - 30^y) = 0.05/0.11
Some simple algebra.
(.06/0.11)*10^y - 25^y + (0.05/0.11)*30^y == 0
You could use fzero to solve this, or use the symbolic toolbox. Plot shows two solutions.
vpasolve((.06/0.11)*10^y - 25^y + (0.05/0.11)*30^y == 0,4)
ans =
4.264083495647992647900412924213
vpasolve((.06/0.11)*10^y - 25^y + (0.05/0.11)*30^y == 0)
ans =
0
Is the solution at zero a valid solution? Perhaps not, since that would result in a divide by zero. In fact, the original equations make y==0 obviously not a solution. You can go back and recover x and z now.
Or, better yet, divide by 10^y, which is fine, since 10^y will never be zero.
(.06/0.11) - 2.5^y + (0.05/0.11)*3^y == 0
Again, we can see that y==0 is a trivial solution, but not admissible, since that solution was generated by algebraic operations we did before.
It is homework though, so your problem to solve.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!