This will be a huuuh? moment.
Here's some results for the two algorithms (DB3=Peter's
Algorithm). I used unity as the initial guess.
You can see that L D[AR2,p#0.0]'s method converges with fewer iterations but this doesn't tell us which one is faster. How long does a divide take relative to a multiply? I count clock cycles.
Also, the trick is getting the initial guess right, then my method takes 5 iterations. This is the key.
L D[AR2,P#0.0], you appear to be taking the cube root of 15625 to get 25. First load 15625 into ACC1 and convert to a float if it isn't already.
Next multiply 0.333333333333333
Then +D 709921077 but treat the result a REAL.
This is your first guess.
Yes, you are adding adding a DINT to a REAL and the result is still a REAL but don't let that bother you.
Now execute the rest of the code and post it as you did before. You will see that both methods will take fewer iterations.
So why does the *0.333333333+L#16#709921077 work?
The S7 should allow you do this trick because STL is close to machine code whereas other PLCs will not let one add a DINT to a REAL.
Manglemender, the code you posted is how XPY is computed.
I have spent a lot of time looking at the source code to C libraries, modifying them and then recompiling to make the routines faster.