09-14-2022, 12:59 AM
Hey guys,
Just an update...
Thanks for the posts / code. I will be looking though them all later tonight. Last night I put the Newton approximation to work in my string math routine to mixed reviews.
1) It works, but...
2) Square root of 9 comes out to something like 3.000000000000000000000000001
So I tested using Treebeard's routine, and got the same results. I know, a lot of roots are approximation algorithms. Actually, if I added the rounding back into my new string math routines, it would handle this case, but would it handle all possible cases? I can't say.
There is a long division method, but it get crazy when you are doing something the 100th root. I can't quite yet wrap my head around the iteration loops to build out the algorithm correctly.
As Mark stated, I'm avoiding using logs. Why? Because I don't have a way to process logs in string math... yet, maybe never. Logs are very tricky, too, so I'm working with general roots and decimal powers, first.
So Newton is the simplest, but I don't want to be caught with calculator results that cannot be reversed as 3.0000000000000000001 squared certainly doesn't get us back to 9.
I'll post the string math version for general roots later tonight. Right now, I'm cooking up some signature spaghetti sauce. Hey, better than writing my signature spaghetti code!
Thanks,
Pete
Just an update...
Thanks for the posts / code. I will be looking though them all later tonight. Last night I put the Newton approximation to work in my string math routine to mixed reviews.
1) It works, but...
2) Square root of 9 comes out to something like 3.000000000000000000000000001
So I tested using Treebeard's routine, and got the same results. I know, a lot of roots are approximation algorithms. Actually, if I added the rounding back into my new string math routines, it would handle this case, but would it handle all possible cases? I can't say.
There is a long division method, but it get crazy when you are doing something the 100th root. I can't quite yet wrap my head around the iteration loops to build out the algorithm correctly.
As Mark stated, I'm avoiding using logs. Why? Because I don't have a way to process logs in string math... yet, maybe never. Logs are very tricky, too, so I'm working with general roots and decimal powers, first.
So Newton is the simplest, but I don't want to be caught with calculator results that cannot be reversed as 3.0000000000000000001 squared certainly doesn't get us back to 9.
I'll post the string math version for general roots later tonight. Right now, I'm cooking up some signature spaghetti sauce. Hey, better than writing my signature spaghetti code!
Thanks,
Pete
Shoot first and shoot people who ask questions, later.