I have a python algorithm which solves an ODE. Now I noticed that this code is for several different input parameters extremely slow. Thus I profiled the code, and got as result:

```
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)

        1    0.004    0.004  429.032  429.032 gnlse.py:153(perform_simulation)
        2    0.001    0.000  429.017  214.508 _ode.py:564(integrate)
        2    0.000    0.000  429.016  214.508 _ode.py:381(integrate)
        2   18.985    9.492  429.016  214.508 _ode.py:1013(run)
    52007   22.260    0.000  410.031    0.008 _ode.py:495(_wrap)
    52007  188.766    0.004  387.243    0.007 gnlse.py:234(GNLSE_RHS)
   208033    1.300    0.000  173.272    0.001 fftpack.py:46(_raw_fft)
   104018   18.316    0.000  108.077    0.001 fftpack.py:195(ifft)
   104015    0.857    0.000   90.410    0.001 fftpack.py:100(fft)
   104015   85.626    0.001   85.626    0.001 {numpy.fft.fftpack_lite.cfftf}
   104018   85.607    0.001   85.607    0.001 {numpy.fft.fftpack_lite.cfftb}
    29108   25.776    0.001   25.776    0.001 {min}
   530887    3.275    0.000    3.275    0.000 {numpy.core.multiarray.array}
   104034    2.522    0.000    2.522    0.000 {method 'astype' of 'numpy.ndarray' objects}

```

Which part of the algorithm can be optimized best (can that be answered without the whole code based on the cProfile measurements?)? According to the data I would say the `GNLSE_RHS` function, after the total time spent in this function is most significant.  

In this function the `fft`-functions (four times each call) are called. Would it make more sense to make them faster instead of improving the algorithmus in the `GNLSE_RHS`?
The function in question is

```
AT = np.fft.fft( np.multiply( AW , np.exp( simp['linop'] * z)))
IT = np.abs(AT)**2  
if simp['raman'] == True:
    RS = simp['dt']  *  np.fft.fft( np.multiply( np.fft.ifft(IT), simp['RW'] ))
    M = np.fft.ifft( np.multiply( AT,( (1-simp['fr'])*IT +  simp['fr']*RS ) ) )      
else:
    M = np.fft.ifft( np.multiply( AT, IT))
return  1.0j * simp['gamma'] * np.multiply( simp['W'], np.multiply( M, np.exp( -simp['linop'] * z)) )

```

Edit: I do not need a refined algorithm, I rather want to know which part is mostly contributing to the running time, i.e. increasing the speed of which function would improve the overall speed the most?