Re: [GiNaC-list] How to differentiate from a Tensor?
On Fri, 14 Jul 2017 13:29:37 +0430, esarcush esarcush <esarcush@gmail.com> said:
EE> E needs to depend on x. So, symbol A("A"), x("x"); symbol EE> i_sym("i"), j_sym("j"); idx i(i_sym, 3), j(j_sym, 3); ex e = EE> indexed(A, i, j); ex de_dx = e.diff(x); cout << de_dx << "\n"; EE> returns 0. Thus, what is the way to depend "e" on "x" like EE> undefined functions? If a dependence of A on x is not defined, try to use the step function (as one without defined derivative): ex e = indexed(step(x), i, j); This keeps track on derivatives. To maintainer: I have run into similar situation working with differential operators. Shall we add "generic" functions to GiNaC with 1, 2, 3, 4 variables? -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/ EE> All the bests, EE> On 7/14/17, Vladimir V. Kisil <kisilv@maths.leeds.ac.uk> wrote: >>>>>>> On Fri, 14 Jul 2017 12:15:49 +0430, esarcush esarcush >>>>>>> <esarcush@gmail.com> said: >> EE> Dear all, What is right way to have something like \( EE> \frac{\partial A^{i}_{jk}}{\partial x} \)? Indeed, I defined a EE> tensor "A~i.j.k" and want to differentiate from it with respect EE> to "x" e.g. >> >> For a GiNaC object E its derivative with respect to x is obtained >> by E.diff(x) >> -- >> Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: >> Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: >> Geometry of cycles http://moebinv.sourceforge.net/ >>
I think it is not a suitable way. Happening other situations, this method will lack. For example, consider a case that \( A_{ij} \) is a two variable function. Moreover, please try your answer (if I understand it well): { symbol x("x"); symbol i_sym("i"), j_sym("j"); idx i(i_sym, 3), j(j_sym, 3); ex e = indexed(step(x), i, j); ex de_dx = e.diff(x); cout << de_dx << "\n"; } returning 0. All the best, On 7/14/17, Vladimir V. Kisil <kisilv@maths.leeds.ac.uk> wrote:
On Fri, 14 Jul 2017 13:29:37 +0430, esarcush esarcush <esarcush@gmail.com> said:
EE> E needs to depend on x. So, symbol A("A"), x("x"); symbol EE> i_sym("i"), j_sym("j"); idx i(i_sym, 3), j(j_sym, 3); ex e = EE> indexed(A, i, j); ex de_dx = e.diff(x); cout << de_dx << "\n";
EE> returns 0. Thus, what is the way to depend "e" on "x" like EE> undefined functions?
If a dependence of A on x is not defined, try to use the step function (as one without defined derivative):
ex e = indexed(step(x), i, j);
This keeps track on derivatives.
To maintainer: I have run into similar situation working with differential operators. Shall we add "generic" functions to GiNaC with 1, 2, 3, 4 variables? -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
EE> All the bests,
EE> On 7/14/17, Vladimir V. Kisil <kisilv@maths.leeds.ac.uk> wrote: >>>>>>> On Fri, 14 Jul 2017 12:15:49 +0430, esarcush esarcush >>>>>>> <esarcush@gmail.com> said: >> EE> Dear all, What is right way to have something like \( EE> \frac{\partial A^{i}_{jk}}{\partial x} \)? Indeed, I defined a EE> tensor "A~i.j.k" and want to differentiate from it with respect EE> to "x" e.g. >> >> For a GiNaC object E its derivative with respect to x is obtained >> by E.diff(x) >> -- >> Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: >> Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: >> Geometry of cycles http://moebinv.sourceforge.net/ >>
On Fri, 14 Jul 2017 14:04:56 +0430, esarcush esarcush <esarcush@gmail.com> said:
EE> returning 0. You are right: Implementation of ex::diff() for an indexed object always returns 0. If you have a reason for a different behaviour you need to derive your own class for it. -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
Thanks. I have an idea to this target. My algorithm is based on Regular Expressions. I tested my algorithm in python for simple cases (disclaimer: "My algorithm" is not a good expression; but I mean that as my plan to implementing symbolic tensor computations). I am ready to contribute on this plan with my friend here and thus implementing it in GiNaC. Codes in Python are only for testing the plan. The main language will be C++. It will be my honour to see it in this link: https://github.com/esasharahi/Symbolic_Tensor_Computer/blob/master/ECE.py All the bests, Esa On 7/14/17, Vladimir V. Kisil <kisilv@maths.leeds.ac.uk> wrote:
On Fri, 14 Jul 2017 14:04:56 +0430, esarcush esarcush <esarcush@gmail.com> said:
EE> returning 0.
You are right: Implementation of ex::diff() for an indexed object always returns 0.
If you have a reason for a different behaviour you need to derive your own class for it. -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
On Fri, 14 Jul 2017 14:44:25 +0430, esarcush esarcush <esarcush@gmail.com> said:
EE> Thanks. I have an idea to this target. My algorithm is based on EE> Regular Expressions. I tested my algorithm in python for simple EE> cases (disclaimer: "My algorithm" is not a good expression; but EE> I mean that as my plan to implementing symbolic tensor EE> computations). EE> I am ready to contribute on this plan with my friend here and EE> thus implementing it in GiNaC. Codes in Python are only for EE> testing the plan. The main language will be C++. EE> It will be my honour to see it in this link: EE> https://github.com/esasharahi/Symbolic_Tensor_Computer/blob/master/ECE.py And what is the mathematical object, which you are implementing? -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
On 07/14/2017 11:18 AM, Vladimir V. Kisil wrote:
To maintainer: I have run into similar situation working with differential operators. Shall we add "generic" functions to GiNaC with 1, 2, 3, 4 variables?
Isn't that there already? <https://www.ginac.de/ginac.git/?p=ginac.git;a=blob;f=ginac/function.cppy;h=a7e3649c7c195e93ae5886c66202ad9fdc1bbd6c;hb=HEAD#l744> Cheers -richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>
On Mon, 17 Jul 2017 19:56:44 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said:
RK> On 07/14/2017 11:18 AM, Vladimir V. Kisil wrote: >> To maintainer: I have run into similar situation working with >> differential operators. Shall we add "generic" functions to GiNaC >> with 1, 2, 3, 4 variables? RK> Isn't that there already? RK> <https://www.ginac.de/ginac.git/?p=ginac.git;a=blob;f=ginac/function.cppy;h=a7e3649c7c195e93ae5886c66202ad9fdc1bbd6c;hb=HEAD#l744> It seems, not. Assume, I want to calculate the Laplacian in polar coordinates. Then the expression f(sqrt(x*x+y*y),atan2(y,x)).diff(x,2)+f(sqrt(x*x+y*y),atan2(y,x)).diff(y,2) does it, provided that f is a function of two variables without defined derivatives. For one variable the step function is (the only?) example of such function. So my proposition is to add to GiNaC a family of "generic functions" of 1-4 variables without any specific properties. Advises "derive your own class" or "define your own function" is a certain barrier for a set of GiNaC users, I think (from my own experience). Best wishes, Vladimir -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
participants (3)
-
esarcush esarcush
-
Richard B. Kreckel
-
Vladimir V. Kisil