Solving system of equations?

Solving system of equations? - Сообщения

#1 Опубликовано: 15.06.2012 14:09:09
jthorn

jthorn

0 сообщений из 1 понравились пользователям.

Группа: User

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:

https://smath.com/wiki/Solving%20Non-Linear%20Systems%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.
#2 Опубликовано: 15.06.2012 14:47:07
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello,
Wrote

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!"
#3 Опубликовано: 01.09.2012 11:01:06
Gilberto E. Urroz

Gilberto E. Urroz

21 сообщений из 36 понравились пользователям.

Группа: User

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/cee/faculty/gurro/Classes/ClassNotesAllClasses/CEE3510/Lectures/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
#4 Опубликовано: 01.09.2012 11:05:43
Gilberto E. Urroz

Gilberto E. Urroz

21 сообщений из 36 понравились пользователям.

Группа: User

Here's another reference:

http://www.neng.usu.edu/cee/faculty/gurro/Classes/ClassNotesAllClasses/CEE3510/LectureNotes/AdditionalPipelineProblems/SimultaneousEQuationsInSMathStudio.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)
#5 Опубликовано: 01.09.2012 12:46:06
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

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,

[MATH=eng]xs:mat(el(x,1),el(x,2),2,1)[/MATH]

because of this line in the function

[MATH=eng]fJ(x):Jacob(f(x),xs)[/MATH]

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 .

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#6 Опубликовано: 04.09.2012 17:37:38
Gilberto E. Urroz

Gilberto E. Urroz

21 сообщений из 36 понравились пользователям.

Группа: User

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
#7 Опубликовано: 05.09.2012 03:31:07
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

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().
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#8 Опубликовано: 09.09.2012 10:25:53
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello Gilberto,
Wrote

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

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).

[MATH=eng]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):diff(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)[/MATH]

[MATH=eng]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)[/MATH]

[MATH=eng]fNewtonm(F(x#),x0,ε,Nmax)=mat(mat(2,1,3,3,1),5,2,1)[/MATH]

Regards,
Radovan
fWNewton-1.sm (11 КиБ) скачан 70 раз(а).
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#9 Опубликовано: 19.09.2012 19:13:19
Gilberto E. Urroz

Gilberto E. Urroz

21 сообщений из 36 понравились пользователям.

Группа: User

Radovan:

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

Gilberto Urroz
#10 Опубликовано: 19.09.2012 19:58:49
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

You are welcome ,

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений