Solve Systems of Non-Linear Equations
|
12-16-2023, 08:48 AM
Post: #1
|
|||
|
|||
Solve Systems of Non-Linear Equations
The program solves systems of non-linear equations. Equations are used in a form where the result should be zero. Nelder Mead Optimization is used to find a minimum of the sum of squared results. If the minimum is zero, the solution is found.
Example (taken from a YouTube video): A quadrilateral is given with the following characteristics: A, B, C, and D are located on a circle line. The length of the sides is as follows: AB: 4, BC: 5, CD: 6, DA: 3. What is the radius R of the circle? The center of the circle is set to (0,0); A is set to (-R, 0). Then we get the following system of equations of 7 equations with 7 unknowns ( (X1,Y1) coordinates of A, (X2,Y2) of B etc.): 1) (-R-X2)^2+Y2^2=16 2) (X2-X3)^2+(Y2-Y3)^2=25 3) (X3-X4)^2+(Y3-Y4)^2=36 4) (X4+R)^2+Y4^2=9 5) X2^2+Y2^2=R^2 6) X3^2+Y3^2=R^2 7) X4^2+Y4^2=R^2 Application: Parameters R, X2, X3, X4, Y2, Y3, Y4 are stored in List L1. From a rough drawing, we get the following initial estimates: R=3, X2=1; X3=3; X4=-3; Y2=-1; Y3=4; Y4=3. We set: {3,1,3,-3,-1,4,3) ▶ L1 Further, the function FUNES is needed with the equations. Equations are changed, so that the results are 0. Results are stored in List L0. Code: EXPORT FUNES() Start the program NLES. You are asked for the following parameters: S0: Initial step width of Nelder Mead Optimization. We start with 1. E0: Termination criterion. Optimization ends if the square root of the sum of squared results of the equations is less than E0, the step length of the Nelder Mead Procedure is less than E0/10, or the maximum number of iterations is reached. We put in 0.0001. ITM: Maximum number of iterations. We put in 500. The interim result of the minimum is shown every 25 iterations. After a few seconds, you get the following information on the screen: --- DONE ----------- Iter: 478 Eps: 8,4281055292E-6 Fmin: 1.70417577211E-4 Parameter: L1 Parameter L2 Interpretation: Optimization stopped after 478 iterations because of the limit of step length of the Nelder Mead procedure, not because zero was reached (Fmin>1E-4). So it might make sense to start a new one with a lower step length. We take S0=0.25, E0=0.0001, ITM=400. After 46 iterations we get Fmin=1.385E-4, so our criterion is nearly reached and we stop. Parameters are in list L1. L1(1)=3.2704; this is the estimate for the radius of the circle. Inspection of list L0 shows that the biggest deviation in the equations is 8.4E-5. Code: EXPORT NLES(S0,E0,ITM) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)