Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline jthorn  
#1 Posted : 15 June 2012 21:09:09(UTC)
jthorn

Rank: Newbie

Groups: Registered
Joined: 15/06/2012(UTC)
Posts: 1
United States
Location: Bay Area

Hello,

I'm not figuring out how to symbolically solve a non-linear system of equations. I created a mostly blank Wiki page in the hopes that someone could help to create a solution:

http://smath.info/wiki/S...ms%20of%20Equations.ashx

In MathCad this would be a Given / Solve block kind of thing.


Very pleased with SMath so far; Excellent work! Very much looking forward to further development in creating documents with it.

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline omorr  
#2 Posted : 15 June 2012 21:47:07(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Hello,
Originally Posted by: jthorn Go to Quoted Post
I'm not figuring out how to symbolically solve a non-linear system of equations.

That is not implemented yet.

Regards,
Radovan

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline gurro  
#3 Posted : 01 September 2012 18:01:06(UTC)
gurro


Rank: Advanced Member

Groups: Registered
Joined: 22/09/2009(UTC)
Posts: 34
Man
Location: Utah State University, Logan, UT, USA

Was thanked: 20 time(s) in 7 post(s)
Here's some information on numerically solving a system of non-linear equations:

Check out the last four links in this web site:

http://www.neng.usu.edu/...s/CEE3510_Lecture15a.htm

They are:

Pipes converging at a junction - pdf file: see pages 5-12 in this pdf file
Pipes converging at a junction (SMath Studio files): SMath Studio file with examples
Creating function "fNewtonm.sm" to solve multiple equations OPTIONAL VIDEO - explains how to create the code snippet for the function
Using function "fNewtonm.sm" to solve problems of pipe at a junction VIDEO - shows how to use SMath Studio to solve junction problems


Note: the "norme" function in the most recent version of SMath Studio (July 2012) is not working properly, so you'll have to implement your own "norme" function, e.g.:

NormE(F):line(nn:length(F),sqrt(sum((el(F,k)^2),k,1,nn)),2,1)

NOTE: copy the line above and paste it in your SMath Studio worksheet, but not as text.

The function that solves the system of non-linear equations is:

fNewtonm(f(x),xs,x0,ε,Nmax):line(fJ(x):Jacob(f(x),xs),k:0,xG:x0,while(((k≤Nmax)&(NormE(f(xG))>ε)),line(JJ:eval(fJ(xG)),JJI:eval(invert(JJ)),fxG:eval(f(xG)),DxG:eval(JJI*fxG),xGp1:eval(xG-DxG),k:k+1,xG:xGp1,7,1)),mat(xG,k,2,1),5,1)

Again, copy the line above and paste it in your SMath Studio worksheet, but not as text.

Find the file: JeppsonCh01Prob13MomentumApplication.zip in the File Manager of the SMath Studio wiki for an example
Offline gurro  
#4 Posted : 01 September 2012 18:05:43(UTC)
gurro


Rank: Advanced Member

Groups: Registered
Joined: 22/09/2009(UTC)
Posts: 34
Man
Location: Utah State University, Logan, UT, USA

Was thanked: 20 time(s) in 7 post(s)
Here's another reference:

http://www.neng.usu.edu/...uationsInSMathStudio.pdf

But make sure to use your own "norme" function:

NormE(F):line(nn:length(F),sqrt(sum((el(F,k)^2),k,1,nn)),2,1)
Offline omorr  
#5 Posted : 01 September 2012 19:46:06(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Hello Gilberto,

You are right about norme(). Some strange error - Atempted to read or write protected memory...This must be a bug, I think.

Moreover, your fNewtonm() function is very useful in order to solve the system of nonlinear equations numerically by Newton method although there is roots() function in SMath. Actually, sometimes there is no other way then writing our own functions (often quite uneficient and slow) because of the problems with roots() and solve() functions. There is still a drawback in fNewtonm() because your function argument "xs" must have vector named elements as "x" actually,

xs:mat(el(x,1),el(x,2),2,1)

because of this line in the function

fJ(x):Jacob(f(x),xs)

this is not your fault but the way SMath and Jacob() function are working. To make long story short - If we want to use your function we can not use variables named "x" before its use.

I was convinced many times and reported at this Forum problems with nonlinear equations solvers roots() - system of nonlin. equations/single equations , solve() - single nonlinear equations:
http://en.smath.info/forum/yaf_postst1263_solve---and-roots-----again.aspx
http://en.smath.info/forum/yaf_postst1253_roots---problems.aspx
Andrey did his best to resolve all the problems with those root finding functions but they are still not good enough. Unfortunately, there is still no library with strictly numerical solvers in SMath and, as the time is passing, I do not believe if there would ever be any. On the other hand, making plugins by myself is far beyond my capabilities. To be honest, I got frustrated many times because of that Sad .

Regards,
Radovan

Edited by user 01 September 2012 21:50:52(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline gurro  
#6 Posted : 05 September 2012 00:37:38(UTC)
gurro


Rank: Advanced Member

Groups: Registered
Joined: 22/09/2009(UTC)
Posts: 34
Man
Location: Utah State University, Logan, UT, USA

Was thanked: 20 time(s) in 7 post(s)
Hello, Radovan:

After I posted my earlier message highlighting the use of "fNewtonm", I found your posting about using "roots", and I'm convinced it's a simpler approach. I'm winding down the use of "fNewtonm" in my classes and replacing it with "roots".

Thanks,

Gilberto
Offline omorr  
#7 Posted : 05 September 2012 10:31:07(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
You are welcome Gilberto,

From my experience, I have to point out once more that roots() will fail sometimes and your function using Newtomn-Raphson will sometimes do the job in that case. Unfortunately, I could not solve many of my class problems with roots() when even few simple Newton-Raphson iterations will solve the same system. It might be quite cumbersome and quite frustrating sometimes. Therefore I pointed out (desperately) many times that SMath needs some more powerful and robust nonlinear solvers made from some well known numerical libraries. Unfortunately, it seems that this is not likely to happen due to the SMath internal structure. Therefore, roots() and solve() are the only two functions we can count on at the moment.

Regards,
Radovan

P.S Just few minutes ago I've seen this post Broyden().

Edited by user 05 September 2012 10:47:16(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline omorr  
#8 Posted : 09 September 2012 17:25:53(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Hello Gilberto,
Originally Posted by: gurro Go to Quoted Post
After I posted my earlier message highlighting the use of "fNewtonm", I found your posting about using "roots", and I'm convinced it's a simpler approach. I'm winding down the use of "fNewtonm" in my classes and replacing it with "roots".

At the same time we posted here, there were few additional nonlinear solvers posted here Non-Linear solvers . You might find them useful as I do Good

By the way, If you want to use your fNewtonm() function without the mentioned restriction about the vector of variables names (must be "x" ), here is a bit changed version. There is one parameter excluded (vector of unknows).

fNewtonm(f(x#),x0,ε,Nmax):line(fJ(f(x#),x#):line(n:length(x#),for(i,range(1,n),for(j,range(1,n),el(J,i,j)Biggriniff(el(f(x#),i),el(x#,j)))),J,3,1),k:0,xG:x0,while(((k≤Nmax)&(NormE(f(xG))>ε)),line(JJ:eval(fJ(f(x#),xG)),JJI:eval(invert(JJ)),fxG:eval(f(xG)),DxG:eval(JJI*fxG),xGp1:eval(xG-DxG),k:k+1,xG:xGp1,7,1)),mat(xG,k,2,1),5,1)

F(X):mat(el(X,1)+el(X,2)+el(X,3)-6,el(X,1)*el(X,2)*el(X,3)-6,el(X,1)^2+el(X,2)^2+el(X,3)^2-14,3,1)

fNewtonm(F(x#),x0,ε,Nmax)=mat(mat(2,1,3,3,1),5,2,1)

Regards,
Radovan

Edited by user 09 September 2012 17:29:40(UTC)  | Reason: Not specified

File Attachment(s):
fWNewton-1.sm (12kb) downloaded 50 time(s).
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline gurro  
#9 Posted : 20 September 2012 02:13:19(UTC)
gurro


Rank: Advanced Member

Groups: Registered
Joined: 22/09/2009(UTC)
Posts: 34
Man
Location: Utah State University, Logan, UT, USA

Was thanked: 20 time(s) in 7 post(s)
Radovan:

Thanks for the updated version of "fNewtonm". I'm going to use it in my classes.

Gilberto Urroz
Offline omorr  
#10 Posted : 20 September 2012 02:58:49(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
You are welcome Good ,

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.