Non-linear Equations
#1
Posted 22 May 2006 - 05:29 PM
I khow it is possible for a TI to solve it!
But what about a CP?
I entered equations as below:
solve({x+x*y=5,x^2+y=2},{x,y})
Thanks for your kind attention.
#2
Posted 22 May 2006 - 08:42 PM
#3
Posted 23 May 2006 - 05:27 PM
It's not clear for me!
Do u mean it needs programming?
#4
Posted 23 May 2006 - 06:00 PM
#5
Posted 23 May 2006 - 06:18 PM
(The Broyden Method , I posted a related problem and the solution on the Engineering Applications Topic)
#6
Posted 23 May 2006 - 06:57 PM
How?
It's not clear for me!
Do u mean it needs programming?
No.
You must extract first variable from first equation using solve() then use it in second equation (with | command) and find all results manualy (as you write on paper).
I tried to solve this system but in one part CP didn't return exact expression but approximation only. So I don't if this is usable for you.
solve(x^2+y=2,y) {y=-x^2+2} solve(x+x*y=5,x)|ans[1] {x=-5/(x^2-3)} solve(x=-5/(x^2-3),x) // CP can't solve this. We must edit the expression. solve(x(x^2-3)=-5,x) {x=-2.279018786}I'll find same problem even if I start with second equation.
And sorry for my english. I'm not from English-speaking country
#7
Posted 23 May 2006 - 10:28 PM
#8
Posted 25 May 2006 - 08:05 AM
A quick solution:How can I solve a non-linear Equation system?
I khow it is possible for a TI to solve it!
But what about a CP?
I entered equations as below:
solve({x+x*y=5,x^2+y=2},{x,y})
Thanks for your kind attention.
require("table","LuaNumAn/Broyden") local function F(x) return {x[1]+x[1]*x[2]-5,x[1]^2+x[2]-2} end local function J(x) return{{1+x[2],x[1]},{2*x[1],1}} end root=Broyden({-1,0},F,J,5E-16) table.foreach(root,print)You get {-2.27901878616659,-3.19392662770025}, accurate to at least 15 decimal digits. See LuaNumAn's documentation for details .
#9
Posted 25 May 2006 - 01:03 PM
My HP49 couldn't solve it and mathematica gave a really long solution,are you sure the TIs can solve this particular one?
My TI-92 Plus gives x = -2.27901878617, y = -3.1939266277. So yes, the TI calculators can solve it.
#10
Posted 25 May 2006 - 03:33 PM
I don't remember having said that require() now accepts several arguments. But since you use it, that means you know it. Glad to see it's useful.A quick solution:
require("table","LuaNumAn/Broyden") local function F(x) return {x[1]+x[1]*x[2]-5,x[1]^2+x[2]-2} end local function J(x) return{{1+x[2],x[1]},{2*x[1],1}} end root=Broyden({-1,0},F,J,5E-16) table.foreach(root,print)You get {-2.27901878616659,-3.19392662770025}, accurate to at least 15 decimal digits. See LuaNumAn's documentation for details .
Btw, I noticed that you often use the "table" package only for the foreach() function. You could have the same result with
for key,value in pairs(root) do print(key,value) endThe pairs() function does not require any extra package
And again, this is another proof of the utility of CPLua and LuaNumAn
#11
Posted 25 May 2006 - 05:35 PM
{x=1.14+.946i , x=1.14-.946i , x=-2.279} and {y=1.597-2.157i , y=1.597+2.157i , y=-3.194}, these are the rounded results (obviously).
we must use the calc together with our heads not appart. anyway, this system gives a third order system, that can still be solved exactly but calcs don't have it implemented.
#12
Posted 25 May 2006 - 07:26 PM
#13 Guest_Anonimo_*
Posted 25 May 2006 - 10:12 PM
My HP49 couldn't solve it and mathematica gave a really long solution,are you sure the TIs can solve this particular one?
MMmmmm....the program name is Solvesys. For the hp 49g. Find hpcalc.org
#14
Posted 26 May 2006 - 08:25 AM
It solved the equations system which I post.
#15
Posted 26 May 2006 - 11:41 PM
Oh, yes, you did .I don't remember having said that require() now accepts several arguments. But since you use it, that means you know it. Glad to see it's useful.
I know this solution, but it doesn't make the program shorter, and I usually want to print a table more than once in a program. But if the "table" package uses a lot of memory, your solution is definitely better.Btw, I noticed that you often use the "table" package only for the foreach() function. You could have the same result with
for key,value in pairs(root) do print(key,value) endThe pairs() function does not require any extra package
#16
Posted 26 May 2006 - 11:59 PM
First, I want to ask something: What do you mean by "i use the same method used to solve it on the classpad"? As far as I know the only way to solve nonlinear systems in ClassPad is to use the "Broyden" function, included in my LuaNumAn package. Don't tell me that you have translated it for the HP ? You probably mean something else...i was looking for an EXACT solution not an aproximation, the HP can't solve it as a system directly because it can't factor the expression, but if i use the same method used to solve it on the classpad i get not one but three solutions
{x=1.14+.946i , x=1.14-.946i , x=-2.279} and {y=1.597-2.157i , y=1.597+2.157i , y=-3.194}, these are the rounded results (obviously).
About the solutions you have find: Indeed, there are also complex conjugate solutions, but LuaNumAn can't handle complex numbers... yet. The main problem with complex arithmetics is that Lua doesn't support complex numbers directly. I could probably use the "cas" package to overpass this problem, but I'm afraid that it will be slow, since I will need to use plenty of CAS commands within a Lua program (even a simple addition will need the CAS, or a Lua script for adding complex numbers ). Implementing a complicated numerical method this way will be a real nightmare. For the moment, LuaNumAn contains numerical methods for real -not complex- numbers.
Incorrect. In most cases, nonlinear systems cannot be solved "exactly" by any CAS system, simply because there is no exact solution, or because there is an exact solution, but it is very complicated and useless. This is when Numerical Analysis is involved. Nonlinear systems can be solved "exactly" only in very special (simple) cases. Their numerical solution is not an easy task as well: numerical methods for nonlinear systems are not easy.anyway, this system gives a third order system, that can still be solved exactly but calcs don't have it implemented.
In general, if you seek for "exact" solutions in real problems, you will dissapointed. But I understand, most programmers, novice to Numerical Analysis, always seek for "exact" solutions, even if there is no such a thing.
Btw, the TI probably solves this system numerically, using a numerical method which is, quite probably, a version of Broyden's method, similar to the corresponding implementation I have included in LuaNumAn.
#17
Posted 29 May 2006 - 05:11 PM
"Incorrect. In most cases, nonlinear systems cannot be solved "exactly" by any CAS system", i guess you should take a look at the cardano method to solve third order systems at http://mathworld.wol...bicFormula.html
also i wasn't trying in any way to say anything bad about LuaNumAn.
you are right to say that in the real world exact solutions are worthless, but it's still a good exercise to know if it is possible or not to find them and why.
my point is, you should have a math background even when solving linear or nonlinear problems with a calculator or pc, so you can at least see if the result is coherent.
#18
Posted 30 May 2006 - 01:13 PM
Ok. I guessed that you used some method, but you didn't specified which one.When i said "i use the same method used to solve it on the classpad" i meant i used the same method "Daniel (CZE)" used.
No offence, but this is not correct. The web page you mentioned does not describe a way to solve third order nonlinear systems. It describes a way to solve general cubic equations, which is a completely different thing. Cardano's method involves some nonlinear systems, but they are only special cases, not an arbitrarily complex nonlinear system. I insist: there is no general method to solve nonlinear systems analytically, including third order systems; only special nonlinear systems can be solved exactly, and this is the exception, not the rule.i guess you should take a look at the cardano method to solve third order systems at http://mathworld.wol...bicFormula.html
I know that, it was obvious that you didn't wanted to be offensive.also i wasn't trying in any way to say anything bad about LuaNumAn.
I absolutely agree. We use calculators to perform addition, but we should know how to add numbers anyway. We use numerical methods to solve a complicated problem, but we should at least know what exactly we solve, and how. I never said that one must use numerical methods blindly.my point is, you should have a math background even when solving linear or nonlinear problems with a calculator or pc, so you can at least see if the result is coherent.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users