Skip to main content
14-Alexandrite
January 4, 2026
Solved

non linear solver update to guess values

  • January 4, 2026
  • 2 replies
  • 330 views

Hi,

I have a problem that is sensitive to guess values. I am attempting to copy a method that was posted some time ago 

https://community.ptc.com/t5/Mathcad/Solve-block-problem-3-1/td-p/43434

but I get an error as follows:

remslie_0-1767532076731.png

I am sure the fix is trival but I have a had no luck fixing it. Any help would be appreciated.

Thanks

Ross

 

Best answer by Werner_E

Using the values given (1000 frequency values from 0.1 to 100 with a constant step width of 0.1) I experienced no problems when using the very same guess values (all 0.05) for all of them. Even though these guesses are way off from the actual results. usually its better to use guesses nearer to the actual expected values.

Here I create a table with values using 0.05 as guess throughout.

Werner_E_0-1767554636419.png

The table created that way is identical to the table ANS6 created by Terry. There are just tiny differences in the range of 10-20 which sure can be ignored.

See details in the attached sheet where I used Terry's sheet as a start. 

This means to me that you could omit the guess values in your function f and use the same guesses (or better ones) throughout.

I did it in hat sheet and called the function f2(w).

I show how to create individual functions alpha(w), etc. and use a range for plotting.

When I was about to suggest using "logspace" instead of "vec" to create a vector of values which are equally spaced in a log-lin plot, I experienced the solve block failing.

I created a function which would trap this error

Werner_E_1-1767556468642.png

so we can see which frequencies out of the 1000 used made the solve block fail and it was found that just two frequency were problematic.

Werner_E_2-1767556504272.png

I investigated further (details see in attached sheet) and it looks that at these frequencies we have some kind of spikes (don't look like asymptotes any more but I am not sure) the solve block has troubles with.

I used the suggested mean values as guesses and not omega1  worked but omega2 still failed.

Not sure if these frequencies have a special meaning to you.

I am also not sure if the approach you found in that thread would be of help in this case. As I showed the solve block had no problems with the frequencies linear spaced from 0.1 to 100 with step width 0.1. So there was no need to awkwardly use the results of the 'previous' calculation as guesses.

I looked to the left and right of the problematic frequencies until the solve block would work and used these values as guesses in your function f.

Now both frequencies worked:

Werner_E_4-1767557664652.png

I also tried the results from frequency w1 instead of the all 0.05 and now no frequency from the vector failed, but some frequency near both(!) problematic ones did.

I am not sure which troubles you encountered and if going through all these hassles is it worth to achieve results (of doubtful accuracy) at these positions.

Maybe the error trapping function f3 already suffices for your needs?

 

Prime 11 sheet attached

 

BTW, if you set the system variable CTOL to a large value like 0.1 all frequencies in the last vector omega work Ok, but it looks like the values returned are awfully inaccurate. Setting CTOL to a smaller value than the default 0.001 may make more frequencies fail

2 replies

21-Topaz II
January 4, 2026

Hi,

omega in your sheet is a range.  Mathcad Prime 11 can now create a vector.

Program uses columns 6 and 7 that do not exist so cause errors.  Changed them to 3 and 4.

Put the creation of omega and small program below not in the solve block above.

 

Cheers

Terry

Werner_E25-Diamond IAnswer
25-Diamond I
January 4, 2026

Using the values given (1000 frequency values from 0.1 to 100 with a constant step width of 0.1) I experienced no problems when using the very same guess values (all 0.05) for all of them. Even though these guesses are way off from the actual results. usually its better to use guesses nearer to the actual expected values.

Here I create a table with values using 0.05 as guess throughout.

Werner_E_0-1767554636419.png

The table created that way is identical to the table ANS6 created by Terry. There are just tiny differences in the range of 10-20 which sure can be ignored.

See details in the attached sheet where I used Terry's sheet as a start. 

This means to me that you could omit the guess values in your function f and use the same guesses (or better ones) throughout.

I did it in hat sheet and called the function f2(w).

I show how to create individual functions alpha(w), etc. and use a range for plotting.

When I was about to suggest using "logspace" instead of "vec" to create a vector of values which are equally spaced in a log-lin plot, I experienced the solve block failing.

I created a function which would trap this error

Werner_E_1-1767556468642.png

so we can see which frequencies out of the 1000 used made the solve block fail and it was found that just two frequency were problematic.

Werner_E_2-1767556504272.png

I investigated further (details see in attached sheet) and it looks that at these frequencies we have some kind of spikes (don't look like asymptotes any more but I am not sure) the solve block has troubles with.

I used the suggested mean values as guesses and not omega1  worked but omega2 still failed.

Not sure if these frequencies have a special meaning to you.

I am also not sure if the approach you found in that thread would be of help in this case. As I showed the solve block had no problems with the frequencies linear spaced from 0.1 to 100 with step width 0.1. So there was no need to awkwardly use the results of the 'previous' calculation as guesses.

I looked to the left and right of the problematic frequencies until the solve block would work and used these values as guesses in your function f.

Now both frequencies worked:

Werner_E_4-1767557664652.png

I also tried the results from frequency w1 instead of the all 0.05 and now no frequency from the vector failed, but some frequency near both(!) problematic ones did.

I am not sure which troubles you encountered and if going through all these hassles is it worth to achieve results (of doubtful accuracy) at these positions.

Maybe the error trapping function f3 already suffices for your needs?

 

Prime 11 sheet attached

 

BTW, if you set the system variable CTOL to a large value like 0.1 all frequencies in the last vector omega work Ok, but it looks like the values returned are awfully inaccurate. Setting CTOL to a smaller value than the default 0.001 may make more frequencies fail

remslie14-AlexandriteAuthor
14-Alexandrite
January 6, 2026

Werner, Terry,

Many thanks for the corrections Terry and in depth look into my problem Werner. The problem is  non-linear involving a ball tuned mass damper rolling in a semi-circular track mounted to a structure that is vibrating. In Terry's sheet I have included equations for rotation of the ball (P) and translation of the base structure (D). 

The response is sensitive to the amplitude of force (Fo) and becomes more non-linear as Fo increases with jumps in response- see plots below of what occurs. 

remslie_0-1767677239596.png

remslie_1-1767677265685.png

Werner, the values you are trapping with NaN would appear to be the values of omega that fall within this non-linear jump zone. I note that Terry's program fails to give a solution when Fo is > 3.5 N. It would be nice to be able to plot the P and D curves for higher values of Fo up to the points where the jump occurs. This would require smaller increments in omega as the solution approaches the jump.

Any assistance would be greatly appreciated.

Regards,

Ross

 

remslie14-AlexandriteAuthor
14-Alexandrite
January 6, 2026

Werner, Terry,

I don't believe the mathcad sheet attached correctly. I have zipped it and try again.

Ross