|
From: | Fotios Kasolis |
Subject: | Function suggestion: Function composition |
Date: | Sun, 31 Oct 2010 17:13:48 +0100 |
Since I use to be a Mathematica user I inform you that it offers several
functions of interest. Two if them are nest and nestlist and they have the
following syntax
nestlist (fun, x0, iter)
This function returns a vector (or matrix or list) with the following
elements
[ x0, f(x0), f(f(x0)),..., f^iter(x0) ]
(nest does the same but gives only the last element if I recall
correctly)This is useful for dynamical systems and I have implemented that
myself in an .m file as part of a “package” I made for the study of chaotic maps
(mental jump-> the package contains Lyapunov exponent calculation,
bifurcation diagrams, Kaplan – Yorke dimension for multidimensional discrete
time systems and if anybody interested could help me make it a proper package).
# - - - -
function [ orb ] = nestfun (fun, x0, n)
orb = [ x0(:), zeros(numel (x0), n) ];
for count = 1:n
orb(:, count + 1) = fun (orb(:, count));
end
endfunction
# - - - -
Unfortunately I am not able to write that in an .oct file (and I m not sure
it ll be of any value since there is a call to an .m function continuously in a
loop(opinions?)) and I am happy with the one I wrote since it is fast
enough.
This is an example of a function I really believe should be included in
Octave (even if simple for everybody to write); my point here is that Octave
should be enriched with functions not only inspired by ML but any piece of
mathematical software. Ok! syntax compatibility with ML is there, but lets see
now what could take Octave one step further. I really appreciate Mathematica
(which by the way is not only symbolics, but an extreme superset of ML even for
numerics when it comes to core functions) and since I own home edition I could
make a list of functions (and share it with you) that I find important (and if
it is an acceptable solution I could implement in .m functions myself)
Regards
/Fotis
|
[Prev in Thread] | Current Thread | [Next in Thread] |