Some mathematical analysis

Sep 25, 2016 36 Replies

The two I'd reach for are Press, Flannery, Teukolsky, & Vetterling, "Numerical Recipes in C, 2nd Ed.", and Acton's "Numerical Methods That Work".

NR is a pretty good book. The code isn't of the same quality, but it's fine for light-duty use if you can stomach the way they use globals.

Long ago I built some shared libraries of the NR routines, and have been using them off and on ever since. My code is mostly prototype stuff--I really wouldn't use NR code in a product, even if it weren't for the licensing issues.

Acton is a super good read about numerical methods generally. It's more of a lore book than a textbook, and I love lore books, as you know. He has zero patience for mathematically neat methods that are useless in practice, e.g. root-squaring methods for solving equations. There are also a bunch of fun war stories.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

Thanks Phil, Acton sounds like what I want... hey look who's reviewed it. :^)

formatting link

The price is right too!

George H.

The Chebysev expansion is just a method of getting the coefficients to the polynomials. The lazy way is to get enough points to the range to fit and make a least-squares fit to x, x**2, x**3 ...

If the result is monotonic and not very crooked, the high-order terms will be small compared to the lower ones, and the accuracy is preserved when calculating the Horner expansion.

-TV

Polynomials can go crazy if you don't use enough input data points. Lots of points are good to tame the fit and to reduce noise.

It can require double precision math to get 12 bit results,

12th is extreme... we genearlly use 2nd or 3rd order to smooth out not-too-radical functions. Too often an acquisition channel has unexplained nonlinearities, so we use a polynomial in the cal table to pound it flat.

Some of the NBS thermocouple fits get up to 15th order.

John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

Ah, Grasshopper, you lack Buddha-nature (or something.)

A high-order polynomial expressed as sums of powers is _dramatically_ more ill-conditioned than the very same polynomial expressed as a Chebyshev sum. The reason is that x**20, say, looks almost exactly like x**18. In fact, i t's easy to show (from Chebyshev approximation theory) that on any finite i nterval, you can replace X**N by a lower order polynomial with a relative e rror of less than 2**-N. This is the basis for the classical "economization of series" method (YCLIU).

Going from one representation is also ill-conditioned, for the same reason.

Cheers

Phil Hobbs

Which is even more weird, because as you can see, plain as day -- the first-order result is almost as bad as a linear function! Meanwhile, the

2nd order error is pretty tolerable (largely within 1 degree).

I did the cubic as well, for better accuracy. Even the residual from that has a 4th order shape, so it's not converging very quickly.

It's not nearly as good as, say, the rational approximation, which has a 6th order residual from a 1st+2nd order equation, which is, rather astonishing, really! And sure as hell beats a logarithm.

I don't know if it's because this particular thermistor sucks, or I didn't use the formula I said I used -- but if it's right, then it's not "physics based" to any meaningfully useful degree -- that, or I'll eat my physics degree!

Yeah. You can set the type of derivative method from the dialog, as well as error bounds and limits. There's a sensitivity report option, among other things.

Tim

Seven Transistor Labs, LLC Electrical Engineering Consultation and Contract Design Website: http://seventransistorlabs.com

Legendre polynomials are the orthonormals I generally use, though...

For infinite and semiinfinite ranges, there's tricks...but no joy in straight polynomials, you gotta find alternatives.

as

t.

The Steinhart-Hart relationship asserts that the reciprocal of the temperat ure being measured is almost a linear function of the logarithm of the resi stance of the thermistor measuring it, and that you can get a better fit by adding a term proportional to the cube of the logarithm of the resistance.

There was a paper in Review of Scientific Instruments that advocated droppi ng the cubic term if you could live with hundredth degree errors, so I don' t think we are talking about the same function.

formatting link

Bill Sloman, Sydney

Right. The end result is a polynomial anyway, which is reasonable to calculate with the Horner expansion.

-TV

Horner is just a scheme to save cycles when evaluating a polynomial expressed as a sum of coefficients times powers of X. That works for low-order polynomials, but fails horribly for higher order ones, because the size of the coefficients explodes due to the ill-conditioning of the basis set. Have a look at Acton if you don't believe me.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

Legendre polynomials are a lot better than powers of X, but not as good as Chebyshev ones. Either one lets you use a Clenshaw formula to avoid computing the coefficients of x**N, which is the main point.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

That's right. You are already in the swamp with the alligators if the order of the polynomial gets large. It means that the function is pretty crooked.

In practice, I have very seldom needed to go past 3rd degree. It is good for e.g. Pt-1000 for -70C to +250C with error well below the best class sensing element's tolerances.

-TV

Exactly. So Horner is not a good idea then.

Instead of decomposing the function into sums of powers you can decompose it as a sum of chebychev functions. My memory is a bit dim around this, but it ended up not consuming much more computer resources, while the terms became smaller with each order.

Straightforwardly using a polynomial of a degree greater than about 5 is a bad idea.

Groetjes Albert

Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

The fun way of doing the decomposition is to take advantage of the fact that Chebyshev polynomials are cosines with a dorked X axis.

So you sample your function at the Chebyshev abscissae for order 1024 or something, extend it to make it an even function, and then take the FFT, which yields the Chebyshev coefficients.

I sometimes make rational function approximations that way, by building this big long Chebyshev series, formally equating it to a rational Chebyshev function with undetermined coefficients, cross-multiplying, and using the Chebyshev recurrence relationship to compute the numerator and denominator coefficients.

It's easy to automate, and generally gets very very close to the true equiripple approximation of that order.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required