[Scilab-users] The numderivative function
Samuel Gougeon
sgougeon at free.fr
Sat Nov 18 22:38:02 CET 2017
Le 18/11/2017 à 22:01, Hermes a écrit :
> Hi;
> The numderivative function consumes a lot of time in the calculations.
> In the following script I show two options for my "odes" function
> In one of them I use the numderivative function; and the calculation is
> extended by 9 minutes. And in the other I use the Jacobian determinant of
> the function, for each variable, obtained in wxMaxima. And the calculation
> is a few, few, seconds.
> I am interested in using the function with numderivative, and very similar
> to how I have developed it, since it allows me to use it for systems of more
> equations.
Your script makes Scilab 6.0.0 crashing every time it is run => trials
done only on 5.5.2
* I get *145 s* by default when numderivative() is called as usual
from its library.
Without numderivative(), i get *1.97 s*.
* After exec(SCI+"/modules/optimization/macros/numderivative.sci",-1),
this time decreases down to *45 s *only. This is unlikely proper to
numderivative(). 5.5.2 looks to miss an optimization. For the time
being, no way to test this on 6.0.0.
* Your script calls numderivative() ~57000 times.
* Profiling numderivative() and its dependencies shows that
numderivative_evalf() spends a lot of time.
* Replacing execstr(.., "errcatch") in numderivative_evalf() with
try/catch, we get***38 s*
* Then, mainly, vectorizing the function to derivate in order to
accept x with N columns instead of only 1, and changing
numderivative() in order to be able to work with this new vectorized
profile, we get *29 s*.
Improving numderivative() in order to be fully able to work with
vectorized functions should be possible, but then
* at first sight it will be less easy to keep it able to run with
functions that are NOT vectorized (=> back-compatibility issue)
* The jacobian would become an hypermatrix (OK)
* The hessian would get up to 4 dimensions
You may post a report on bugzilla in order to point numderivative
slowness() (if it is not already reported)(Bugzilla is currently off,
taking its week-end).
Regards
Samuel Gougeon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20171118/ef36d321/attachment.htm>
More information about the users
mailing list