Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"04-28-09 - Quadratic"

11 Comments -

1 – 11 of 11
Blogger Brian said...

You have the case where b^2>>4ac where you have huge error bounds for the root near zero unless you rewrite the quadratic equation.

April 28, 2009 at 6:02 PM

Blogger cbloom said...

Hmm.. doesn't the Q formulation do that for you? The root near zero will be the C/Q root.

It does seem like the errors can still get really huge any time one of the coefficients dwarfs others.

April 28, 2009 at 6:14 PM

Blogger Brian said...

Yeah, you are right. I just took a quick look and noticed there wasn't a special case for that.

April 28, 2009 at 6:31 PM

Anonymous Anonymous said...

It's possible NR has converged over time to something better, but it's long been complained that NR is not a trustworth source for numerical algorithms.

http://math.stanford.edu/~lekheng/courses/302/wnnr/nr.html

April 29, 2009 at 2:41 AM

Anonymous Anonymous said...

link

April 29, 2009 at 2:42 AM

Blogger jld said...

Have you read Jim Blinn's articles on the topic?

http://portal.acm.org/citation.cfm?id=1100878

http://portal.acm.org/citation.cfm?id=1158859

They make for a good read...

JL

April 29, 2009 at 8:10 AM

Blogger cbloom said...

I like the Blinn articles, but they don't really add anything, he winds up saying that just using the Q formulation is best. I do like the intuition that he creates though.

Sean, that NR bashing site just annoys me. Yeah, that's all well and good, so maybe it is horrible, so give me something better. Write a better book, make me a better library.

April 29, 2009 at 12:19 PM

Blogger ryg said...

Well, the article does have a link to more "trusted" numeric libraries right at the bottom. However, a lot of them are 404s by now.

Their main reference is Netlib, which is a pretty mixed bag itself. Yeah, a lot of it (especially LAPACK and the TOMS collection) is peer reviewed and has been in use for a long time; but precisely because it's been around that long (some of the code dates from the mid-60s), it's missing some significant algorithmic improvements and is usually tweaked for pre-IEEE floating point implementations. Plus most of it is either sparsely commented FORTRAN 66 or 77 code, or FORTRAN->C conversions with the same 6-char identifiers and the same lack of comments.

April 30, 2009 at 2:14 AM

Blogger cbloom said...

Yeah, I went to this link :

http://math.stanford.edu/~lekheng/courses/302/wnnr/other-sw.html

and couldn't find a single useful thing there.

I'm currently using some code I found for least squares and svd and some other things like that, and it's all that ancient horrible fortran stuff. It seems like nobody has written mathematical code since 1980 !?

April 30, 2009 at 8:57 AM

Blogger ryg said...

A pretty nice lib for your basic linear algebra needs is Newmat (downloads here, that page has a strange organization).

The code is (readable!) C++ with useful comments, it does some lazy evaluation to make sure temporaries don't kill performance, it avoids metaprogramming orgies that result in impossible to read error messages, it has optimized routines for most important special cases (upper/lower triangular, symmetric, diagonal and banded matrices) so there's no needless arithmetic on zeros, and performance is okay. Not something I'd use for HPC, but definitely handy to have around.

April 30, 2009 at 12:03 PM

Blogger cbloom said...

ADDENDUM : of course the other thing that's missing is the checks for zero should really be checks against epsilon, and in the epsilon region you should use series expansion.

Of course then saying it has 1 or 2 roots in that region is sort of lame, so just always say it has 2 and they might be very close or equal.

September 9, 2010 at 12:23 AM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.