Skip to main content
14-Alexandrite
August 26, 2021
Solved

Nonlinear Incremental/ Iterative solution Newton-Raphson

  • August 26, 2021
  • 4 replies
  • 6361 views

Hello,

 

Attached is a Mathcad 15 file. It is for incremental/ iterative solution using Newton-Raphson method to trace a nonlinear curve.  I am using another example that has a solution. It is enclosed in the sheet.

1. I am unable to plot the curve resulting from Newton-Raphson.

2. i don't know how to plot the graph "number of Iterations" vs. "Increment" 

3. I don't know what " While 1" in the attached file mean.

Both solutions are included in the attached file but i am not able to generate them.

 

Thanks,

Sam

Best answer by LucMeekes

спасибо Vladimir,

 

@SFares , please see attached.

LucMeekes_2-1630052244463.png

Now with that correction, and an additional:

LucMeekes_3-1630052283915.png

You can have your plots:

 

LucMeekes_0-1630052184621.png

LucMeekes_1-1630052197228.png

 

 

Success!
Luc

4 replies

23-Emerald IV
August 26, 2021

1.2.:Please save your sheet as a Mathcad 11 (.mcd) file and attach, that'll save me a lot of retyping.

3: while 1 means forever. Then there must be another provision to exit that loop: break if .... does that.

 

Success!
Luc

24-Ruby III
August 27, 2021
LucMeekes23-Emerald IVAnswer
23-Emerald IV
August 27, 2021

спасибо Vladimir,

 

@SFares , please see attached.

LucMeekes_2-1630052244463.png

Now with that correction, and an additional:

LucMeekes_3-1630052283915.png

You can have your plots:

 

LucMeekes_0-1630052184621.png

LucMeekes_1-1630052197228.png

 

 

Success!
Luc

23-Emerald V
August 26, 2021

Unfortunately, I don't have Mathcad 15, only Prime 7, but as far as I can tell ...

 

1. I am unable to plot the curve resulting from Newton-Raphson.

You need to plot it as a second trace within the plot (also change w's upper limit from -100 to 60).   I think in M15, you just need to type a comma after your current arguments and type the second ones.  You need -Pp(K2,wNPr) on the y-axis and -wNRr on the x-axis.   Change the line type of the first item to a thinner line, and add symbols to the second trace.

 

2. i don't know how to plot the graph "number of Iterations" vs. "Increment" 

First fix the error in your return value.  It should read ( clt[i ) <- nlt, not clt[( i<-nlt ).

Then plot cItNR[i (y-axis) against i (x-axis). 

 

3. I don't know what " While 1" in the attached file mean.

As Luc's explained it just means "loop forever".  The escape clause is, as Luc guessed, the "break if |f| ..." line.

 

Cheers,

 

Stuart

24-Ruby III
August 27, 2021
23-Emerald V
August 27, 2021

Thanks, Vladimir.

 

However, I translated the worksheet to Prime 7 and then suggested M11..15 solutions (the same as Luc's, except that I revised the upper limit of w to 60). 

 

Cheers,

 

Stuart

ttokoro
21-Topaz I
21-Topaz I
August 26, 2021

image.png

 

t.t.
SFares14-AlexandriteAuthor
14-Alexandrite
August 27, 2021

Thanks a lot ttokoro!

ttokoro
21-Topaz I
21-Topaz I
August 29, 2021

image.pngimage.pngimage.pngimage.png

t.t.
7-Bedrock
August 29, 2021

There were a couple of mistakes you made right off the bat:
1. You made the nIt assignment in your program to the index instead of the cIt holder.
2. The w and cIt holders were of different vector sizes.

You can plot all three sets of information on the same plot like I did, or make a separate plot for the Iterations.

As for the while 1, I don't know why it's even there since it will always evaluate to true since 1 is greater that 0 any day of the week. I would have keyed on the iteration parmeter so the program would not have chance keep on iterating beyond some reasonable value, like maybe 10 or 20. I didn't mess with it.

The physical model you are working with is highly non-linear. It almost looks like a break-away control switch. Being a structural engineer myself, I have always worked with real world (linear) stuff. I have always tried to avoid non-linear things unless I have to for stuff like plasticity or high temperature design.

Also, why did you not use unit assignments right away instead of all the cumbersome text units. I telling you from experience, this leads to a lot of avoidable mistakes and misinterpretations. Mathcad does a good job keeping track of units.