Newbie question on solving simple equations

4 messages
Open this post in threaded view
|
Report Content as Inappropriate

Newbie question on solving simple equations

 Hi,I just installed Octave and thought I would give it a try.I tried to solve a trivial equation:8 = 2 * x + 4what is x?When I type the equation, Octave complains that x is undefined.  The only way I can get Octave to solve for x is to do half the work myself by transforming the equation, such that x is alone on the left side of the equation:x = (8 - 4) / 2Only then does Octave reply that:x = 2How do I give Octave an equation or a set of equations and then ask it to solve them?  A slightly less trivial example is:10 = x * y + 28 = 2 * y + xwhat are x and y?In this case, I could not transform the equations as above because the transformation of the first equation to x = ... is not resolvable without the second equation, so it would complain that y is undefined. And if I transformed it to y =  ..., it would complain that x is undefined.  In this case, (before the second equation is defined) x and y are unknowable.  So what syntax do I use to submit both equations simultaneously to Octave, so that it can solve these simultaneously?Of course, I could transform the equations and use substitution, but again I would be doing half the work by hand.I have scanned through the help documentation, but such simple issues are not addressed.Can anyone give me a few examples of syntax I would submit to address these trivial equations?Thanks,Joe_______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Open this post in threaded view
|
Report Content as Inappropriate

Re: Newbie question on solving simple equations

 On Tue, May 19, 2009 at 4:45 PM, Joe Kirchner <[hidden email]> wrote: > Hi, > > I just installed Octave and thought I would give it a try. > > I tried to solve a trivial equation: > > 8 = 2 * x + 4 > > what is x? > > When I type the equation, Octave complains that x is undefined.  The only > way I can get Octave to solve for x is to do half the work myself by > transforming the equation, such that x is alone on the left side of the > equation: > > x = (8 - 4) / 2 > > Only then does Octave reply that: > > x = 2 > > How do I give Octave an equation or a set of equations and then ask it to > solve them? > > A slightly less trivial example is: > > 10 = x * y + 2 > 8 = 2 * y + x > > what are x and y? > > In this case, I could not transform the equations as above because the > transformation of the first equation to x = ... is not resolvable without > the second equation, so it would complain that y is undefined. And if I > transformed it to y =  ..., it would complain that x is undefined.  In this > case, (before the second equation is defined) x and y are unknowable.  So > what syntax do I use to submit both equations simultaneously to Octave, so > that it can solve these simultaneously? > > Of course, I could transform the equations and use substitution, but again I > would be doing half the work by hand. > > I have scanned through the help documentation, but such simple issues are > not addressed. > > Can anyone give me a few examples of syntax I would submit to address these > trivial equations? > > Thanks, > > Joe > Octave is not a CAS, which is what you apparently want, but rather a numerical tool. It can solve equations (linear, nonlinear) only approximately, and needs them specified in some canonical form. For more info, see: http://en.wikipedia.org/wiki/Computer_algebra_systemregards -- RNDr. Jaroslav Hajek computing expert & GNU Octave developer Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Open this post in threaded view
|
Report Content as Inappropriate

Re: Newbie question on solving simple equations

 In reply to this post by Joe_K On Tue, May 19, 2009 at 4:45 PM, Joe Kirchner <[hidden email]> wrote: > Hi, > > I just installed Octave and thought I would give it a try. > > I tried to solve a trivial equation: > > 8 = 2 * x + 4 > > what is x? > > When I type the equation, Octave complains that x is undefined.  The only > way I can get Octave to solve for x is to do half the work myself by > transforming the equation, such that x is alone on the left side of the > equation: > > x = (8 - 4) / 2 > > Only then does Octave reply that: > > x = 2 > > How do I give Octave an equation or a set of equations and then ask it to > solve them? > > A slightly less trivial example is: > > 10 = x * y + 2 > 8 = 2 * y + x > > what are x and y? > > In this case, I could not transform the equations as above because the > transformation of the first equation to x = ... is not resolvable without > the second equation, so it would complain that y is undefined. And if I > transformed it to y =  ..., it would complain that x is undefined.  In this > case, (before the second equation is defined) x and y are unknowable.  So > what syntax do I use to submit both equations simultaneously to Octave, so > that it can solve these simultaneously? > > Of course, I could transform the equations and use substitution, but again I > would be doing half the work by hand. > > I have scanned through the help documentation, but such simple issues are > not addressed. > > Can anyone give me a few examples of syntax I would submit to address these > trivial equations? > > Thanks, > > Joe Hi Octave is a programming language, so it can't "magically" solve any equation you enter. In fact, "=" is used for assignment, not equality, so your example "8 = 2 * x + 4" is interpreted as "compute 2*x+4 and assign it to 8", which does not make sense (since x is undefined and 8 is a constant). On the other hand, "x = (8 - 4) / 2" is valid since right side is a mathematical expression that is evaluated to a number, which is then assigned to variable x. I hope this made some sense, I suggest you take look at chapter 1 of Octave manual ("A Brief Introduction to Octave") which gives some simple examples. To solve set of linear equations Ax = b (written in matrix form), you must specify matrix A, vector b and then solve by "x = A\b". For nonlinear equations, you must use "fsolve" function. Regards Ivan Sutoris _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave