question for lyuka and the Ostrowski method - Printable Version +- HP Forums ( https://archived.hpcalc.org/museumforum)+-- Forum: HP Museum Forums ( https://archived.hpcalc.org/museumforum/forum-1.html)+--- Forum: Old HP Forum Archives ( https://archived.hpcalc.org/museumforum/forum-2.html)+--- Thread: question for lyuka and the Ostrowski method ( /thread-190798.html) |

question for lyuka and the Ostrowski method - hugh steers - 08-16-2011
hi, wanted to try out this method. took the code here, http://www.finetune.jp/~lyuka/technote/fract/ost.html and tried one of my tests. this is smooth test from the temperature industry.
double f(double t) not very pretty i know, but it should have a real world solution to a value of 1e-5 (hardcoded) between -275.15 and 100, say.
i do this: int main() and it gives me -256. here's the results from my other methods,
37 iterations secant blows, but brent and ridder are fine. ost is the -256 as mentioned. is there a way to fix for this, otherwise the method has failed.
thanks for any info,
Re: question for lyuka and the Ostrowski method - Namir - 08-16-2011
Hugh, Thanks for the nice link. Interestingly the author uses my favorite test function f(x) = e^x - 3*x^2. Small world! :-) I am going to look into the code and write a version for Excel VBA.
Namir
Re: question for lyuka and the Ostrowski method - Lyuka - 08-16-2011
Hi hugh,
Thank you for your interest on the page "
Take a look at the return code, Quote:
It would occur mainly because of too wide set of initial guesses.
Quote:main: -271.15, 100, f(-256.651643757074339) = -1e-05, 3
Best regards,
Re: question for lyuka and the Ostrowski method - Namir - 08-16-2011
Hugh, I got to play with Ostrowski's method using f(x)=e^x-3*x^2 and comparing it with Newton's method and the faster Halley's method. Since Ostrowski's method uses two initial guesses (and calculates a third guess as the average of the first two), I used the average of these guesses for the Newton and Halley methods, to even up the score a bit. In this case, Ostrowski's method did better than Newton but not better than Halley. If I use the first guess for Newton and Halley methods, then depending on that guess and the second guess (used only by Ostrowski's method) I get a few cases where Ostrowski's method outperforms the other two! Thanks for the fantastic article (and thanks for Luyka for writing that web page). It is a true gem in numerical analysis and for a root-seeking junkie like me!! Namir
Re: question for lyuka and the Ostrowski method - Lyuka - 08-16-2011
Hi, Namir It's not a small world, I've chosen the function because you often use the function as an example :-)
Best regards, Re: question for lyuka and the Ostrowski method - Namir - 08-17-2011
Hi Lyuka, Thank you for a wonderful web page and links. The C and 42S source codes (plus the .raw file for the 42s) are very very nice.
Namir
Re: question for lyuka and the Ostrowski method - Namir - 08-17-2011
I like your C code because it examines the function values for the initial guesses and is able to exit if any of these guesses are at or close to the root. This is what I call the "deluxe version" of an implementation where all scenarios are handled.
Namir
Re: question for lyuka and the Ostrowski method - Lyuka - 08-17-2011
It's my pleasure, thank you for saying that :-) Re: question for lyuka and the Ostrowski method - hugh steers - 08-17-2011
all credit goes to lyuka for the article. i followed his post earlier (seems to have disappeared) to investigate this method. yes, i am interested in root methods too. mostly i use ridders method and find it very stable. the code is also small. i wanted to try this method out and compare it. to lyuka, thanks. it looks like the method finds my function flat. it is true that the curve has a flattened end. this has fooled other methods too. the annoying thing is that this particular example comes from a real world case. now im thinking if there's a hybrid method involving ostrowski and other ideas. -- hugh.
Re: question for lyuka and the Ostrowski method - Namir - 08-17-2011
Lyuka's article about the Ostrowski algorithm comes in an interesting time. For the last week, I have been playing with basic root-seeking algorithms trying to use random numbers as a tool to tweak and improve these algorithms. Here is the pseudo-code for a method that is interesting. It is based on Bisection and uses random numbers:
Given: I have been running solutions in batches of 10000 iterations. The above algorithm does better than the Bisection method between 20% to 50% of the time and saving between 1 to 8 iterations (in significant frequencies). The results depend on the interval [A,B] and where the root is located within the interval. If the root is near the initial boundaries of interval [A,B] then the above algorithm shows more success. Using the "Factor" is the latest aspect of tweaking the algorithm. I am still studying the effect of using Factor and its optimum values. The above algorithm is not the greatest improvement on Bisection. Like I said before I am looking at using random numbers in tweaking basic algorithms I have used the approach with Newton and Halley's method. So far no success. Namir
Re: question for lyuka and the Ostrowski method - Namir - 08-17-2011
Hi, I was looking at the following part of your C code:
if (0.0 == (f - e) * (f - d)) { How about something like:
while (0.0 == (f - e) * (f - d)) { The suggested code calculates c as a random value in the interval [a,b].
Namir
Re: question for lyuka and the Ostrowski method - Lyuka - 08-17-2011
Hi,
Best regards, Re: question for lyuka and the Ostrowski method - Namir - 08-17-2011
You are right. After I posted the message I thought teh while loop perhaps needed a counter? Also the range for calculating c may need to be wider. You are not obligated to have a < c < b.
Re: question for lyuka and the Ostrowski method - Lyuka - 08-18-2011
Hi Namir,
Quote:if (0 == (f - e)) {
It seems to work well, also for the case of hugh steer's temperature related function.
Best regards,
Re: question for lyuka and the Ostrowski method - Lyuka - 08-22-2011
Hi hugh steers, I've been tried to make my implementation of Ostrowski's method to be able to solve the water saturation pressure related equations, as you shown above, for various initial guesses. Now, the latest version of the program (Rev.2.8) seems to work well for such kind of equations with almost any initial guesses within the range of [-273.15 : 100], except when the two guesses are at flat region near -273.15. I've tested the program using the water saturation pressures equations by Sonntag and Wexler as well, to solve it for the pressure to be 1e-5.
Quote: Here is the results of test run of the program.
Quote:
Best regards, |