Hi everyone, I've been following Julia development for a while, and I'd like to jump in and contribute, especially after seeing:
http://amca01.wordpress.com/2014/01/08/meeting-julia/ As far as I can tell, Julia offers two different ODE packages: https://github.com/JuliaLang/ODE.jl and: https://github.com/JuliaLang/Sundials.jl I was interested in trying to write a small patch for the ODE.jl to analytically calculate the sensitivity equations using Julia's Calculus package. In my experience, I've found that calculating parameter sensitivity analytically is a lot more accurate than using numerical approximations like finite elements, and it happens to be significantly faster. There is a good introduction to the problem here: http://www.cs.toronto.edu/~hzp/index_files/presentations/SONAD08hossein.pdf I've written a script to do this in Python, using SymPy, for the simple case involving smooth functions that can be differentiated at all points. The core of the algorithm is this: [code] sens_eqns = OrderedDict() for var_i, f_i in expanded_eqns.items(): for par_j in parameters.keys(): dsens = diff(f_i, par_j) for var_k in expanded_eqns.keys(): sens_kj = Symbol('sens%s_%s' % (var_k, par_j)) dsens += diff(f_i, var_k)*sens_kj sens_eqns['sens%s_%s' % (var_i, par_j)] = simplify(dsens) [/code] My question is this: If I have a very simple function in Julia, written like this: [code] function ode_test(t, x, p) AB = x[1] At = p[1] Bt = p[2] kon = p[3] koff = p[4] A = At - AB B = Bt - AB dAB = kon*A*B - koff*AB end [/code] Is there a simple way, using introspection, to access the raw strings of the function so that I can use it with Julia's Calculus module? An equivalent of Python inspect.getsourcelines? I can use code_typed to get a heavily annotated version, but that's not what I need, since I want to treat the function as a series of symbolic expressions.
