3

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

Community
  • 1
  • 1
mathijs
  • 71
  • 7
  • Javascript math functions are pretty much the same as most other languages. What operations are you having trouble doing? – Barmar Aug 19 '14 at 08:40
  • what have you tried ? R-lang might be more accomidating and then feeding a JS request with some response.. but i dont know! – Pogrindis Aug 19 '14 at 08:41
  • For the moment I haven't tried anything yet. I'm searching the web for some clear explanation about a numerical algorithm to do the inverse Laplace. Found already some method's: Weeks method, Talbot's method,... any experience with one of those? – mathijs Aug 19 '14 at 08:48
  • Yes a bit, and Post's Formula but as for JS implementation its really hard to give you an answer.. – Pogrindis Aug 19 '14 at 08:59
  • It doesn't strictly has to be JS, but it has to be implemented with JS. Also note that the server which will host the site is not mine, so I'm not able to install heavy prog languages on it. – mathijs Aug 19 '14 at 09:03
  • The input is a rational function, given in a fairly symbolic format as the ratio of two (complex?) polynomials, P(x)/Q(x). You seem to want to do the inverse Laplace tranform numerically, perhaps using one of the methods found "searching the web". Success with these numerical methods will depend in part on symbolic properties of P(x)/Q(x). Are you satisfied that the input has been validated? – hardmath Aug 19 '14 at 12:47

2 Answers2

2

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

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • Thanks for the ideas! I will take a look at it next week (need to focus on something else next week). – mathijs Aug 19 '14 at 18:10
2

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.

mathijs
  • 71
  • 7
  • Glad to hear you got it working. If possible, perhaps you can post a link to the code repository or other location so that others can see how you solved it. – Robert Dodier Sep 05 '14 at 19:00