Question

After painful trial and error, I arrived at a grotesque function that behaves the way I want it to:

(exp(- abs(6 * (x - 0.7)) ^ 2.5 ) + exp(- (x-1.7) ^ 8 ) * 1.2)/1.5785

I only care about the values for the range 0 <= x <= 1 and the slope at x = 1. In this interval, 0 <= y <= 1 as well.

Are there any free tools (web-based or MAC OS X) that will generate the Taylor series expansion for this? (I found one, but it choked on such a complex formula and does not support abs.)

My purpose in generating the series expansion is that it may be more efficient to compute. (This function will be called hundreds of thousands of times in Javascript, so performance is an issue.)

Alternately, I could sample the points and do a curve fitting if I had a curve fitting tool. (I do not own MS Excel, alas.) Know of any free non-linear curve-fitting tools (web-based or MAC OS X)?

Was it helpful?

Solution

GNU Octave is a free package that, among other things, has a function polyfit to do least-squares polynomial curve fitting. I think this (or some other package with an equivalent function) is probably a better match for your problem than Taylor series expansion. That absolute value term might make it hard to find a Taylor series that extrapolates well through the point at x=0.7, where the first derivative has a discontinuity.

OTHER TIPS

Maxima does this. See the taylor function.

https://ctaylor.codeplex.com

This is a C++ library which allows you to write expressions and variables and calculate not only the value but also any order derivative. The compiler is the one generating the code for the derivatives.

Wolfram Alpha will do this for you symbolically for free on the web. H/T @ExcessPhase for the idea of using abs(x)=sqrt(x*x).

Wolfram Alpha output

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top