Skip to main content
14-Alexandrite
April 29, 2016
Question

Can I use Polyroots in a in a loop ?

  • April 29, 2016
  • 31 replies
  • 11638 views

Hi, I am wishing to solve a Hertzian contact problem for sub-surface stresses for multiple points in order to plot contours. The solution routine uses Polyroots to extract the maximum root for use in the calculation and works fine for a single point. Is it possible to automate the process in a loop for variable x, y and z using Polyroots? I tried a couple of attempts but get errors.

Any assistance would be appreciated.

Thanks Ross

31 replies

23-Emerald V
April 29, 2016

Ross Emslie wrote:

Hi, I am wishing to solve a Hertzian contact problem for sub-surface stresses for multiple points in order to plot contours. The solution routine uses Polyroots to extract the maximum root for use in the calculation and works fine for a single point. Is it possible to automate the process in a loop for variable x, y and z using Polyroots? I tried a couple of attempts but get errors.

I'm not sure you need to use the symbolic processor as you already know the form of the polynomial.   You should be able to wrap the S1S equations up into a function like this ...

which you can then call as part of a loop (program or range variable)

.

Stuart

remslie14-AlexandriteAuthor
14-Alexandrite
May 1, 2016

Stuart, Thanks for looking into my problem.

I have tried splicing your routine into the program and assigned a range variable to z (ultimately I would like to vary all x, y and z) but running into difficulty with extracting the maximum root for each iteration z. My function f(x1,y1,z1) now has complex roots and includes all roots. So I need to extract the max root for each iteration and use this as s1s in subsequent equations. The current  max(f(x1,y1,z1)) only gives  a single value and not the multiple values for the range variable z1?

Cheers

Ross

21-Topaz II
April 29, 2016

What do you think about my solution?

ESDU.jpg

remslie14-AlexandriteAuthor
14-Alexandrite
May 1, 2016

FM, I can see where you are going with this enhancement. Your programming skills are a level above mine. I have tried reproducing your routine but something basic is missing.I think there are some errors in the definition of deltax, deltay and deltaz but that does not seem to be the reason for the undefined variable ? Perhaps you could send your version of the mathcad sheet.

Thanks

Ross

21-Topaz II
May 2, 2016

In my file goes all "smoothly". You have incorrectly written the name of the rootsdistr routine.

Bye


rootdistr.jpg