Howto implement the inverse Laplace transform in javascript?

1.5k views Asked by At

I'm writing an javascript applet make it easy for others to see how a system with and without proportional controller works and what the outputs are.

First a little explanation on the applet (You can skip this if you want, the real question is in the last paragraph.):

I managed to implement a way of input for the system (in the frequency domain), so the applet can do the math and show the users their provided system. At the moment the applet computes the poles and zeros of the system, plots them together with the root-Loci, plot the Nyquist curve of the system and plot the Bode plots of the system.

The next thing I want the applet to do is calculating and plotting the impulse response. To do so I need to perform an inverse Laplace transformation on the transferfunction of the system.

Now the real question: I have a function (the transferfunction) in the frequency domain. The function is a rational function, stored in the program as two polynomes (numerator and denominator stored by their coefficients). What would be the best way of transforming this function to the time domain? (inverse Laplace). Or is there an open-source library which implements this already. I've searched for it already but only found some math libraries for with more simple mathematics.

Thanks in advance

2

There are 2 answers

1
Robert Dodier On BEST ANSWER

This is a fairly complex and interesting problem. A couple of ideas.

(1) If the solution must be strictly JS: the inverse LT of some rational functions can be found via partial fraction decomposition. You have numerical coefficients for the polynomials, right? You can try implementing a partial fraction decomposition in JS or maybe find one. The difficulty here is that it is not guaranteed that you can find the inverse LT via partial fractions.

(2) Use JS as glue code and send the rational function to another process (running e.g. Sympy or Maxima) to compute the inverse LT. That way you can take advantage of all the functions available, but it will take some work to connect to the other process and parse the result. For Maxima at least, there have been many projects which use Maxima as the computational back-end; see: http://maxima.sourceforge.net/relatedprojects.html

1
mathijs On

Problem is solved now. After checking out some numerical methods I went for the partial fraction decomposition by using the poles of the system and the least square method to calculate the coeficients. After this the inverse LT wasn't that hard to find.

Thx for your suggestions ;)

Ask me if you want to look at the code.