automatic differentiation and change expression ordering
Hello, I have two questions: 1. is it possible to prevent automatic differentiation of some expression? For example, when I do (with ginac 1.1.4): DECLARE_FUNCTION_1P( intensity ) static ex intensity_eval( const ex & r ) { return intensity(r).hold(); } // here i tried to hold it :-) REGISTER_FUNCTION( intensity, eval_func(intensity_eval) ) int main() { symbol r("r"); ex der1 = mul( diff( intensity(r), r ), r ).hold(); ex deriv = der1.diff(r); cout << deriv << endl; return 0; } I get the following output: D[0,0](intensity)(r)*r+D[0](intensity)(r) But I would like to get something like this: D[0]( D[0](intensity)(r)*r )(r) Is it possible with ginac? 2. What is the simplest way to change the order in multiplication so that the differential operators print after all other terms: r*D[0,0](intensity)(r) instead of D[0,0](intensity)(r)*r And the third one ;-) Is there maybe some work done to output fderivative in latex style? Thanks in advance Andrius
Hi! On Wed, Nov 05, 2003 at 09:47:48PM +0200, Andrius Kurtinaitis wrote:
int main() { symbol r("r"); ex der1 = mul( diff( intensity(r), r ), r ).hold();
Don't use hold() here.
ex deriv = der1.diff(r); cout << deriv << endl; return 0; }
I get the following output: D[0,0](intensity)(r)*r+D[0](intensity)(r)
But I would like to get something like this:
D[0]( D[0](intensity)(r)*r )(r)
Is it possible with ginac?
No. fderivative can only represent derivatives of symbolic functions, not of general expressions.
2. What is the simplest way to change the order in multiplication so that the differential operators print after all other terms: r*D[0,0](intensity)(r) instead of D[0,0](intensity)(r)*r
You'd have to rewrite the output routine of the 'mul' class to rearrange the terms. This is possible in GiNaC 1.2 without modifying GiNaC itself, but it is not a trivial task.
Is there maybe some work done to output fderivative in latex style?
Suggestions are welcome. :) Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/
participants (2)
-
Andrius Kurtinaitis
-
Christian Bauer