Re: [GiNaC-list] GiNaC-list Digest, Vol 93, Issue 4
Send GiNaC-list mailing list submissions to ginac-list@ginac.de
To subscribe or unsubscribe via the World Wide Web, visit https://www.cebix.net/mailman/listinfo/ginac-list or, via email, send a message with subject or body 'help' to ginac-list-request@ginac.de
You can reach the person managing the list at ginac-list-owner@ginac.de
When replying, please edit your Subject line so it is more specific than "Re: Contents of GiNaC-list digest..."
Today's Topics:
1. Re: user defined functions and constants (Vladimir V. Kisil)
----------------------------------------------------------------------
Message: 1 Date: Thu, 26 Sep 2013 09:34:40 +0100 From: "Vladimir V. Kisil" <kisilv@maths.leeds.ac.uk> To: GiNaC discussion list <ginac-list@ginac.de>, Gunnar Birke <gunnar.birke@online.de> Cc: "Vladimir V. Kisil" <kisilv@maths.leeds.ac.uk> Subject: Re: [GiNaC-list] user defined functions and constants Message-ID: <18176.1380184480@krein.leeds.ac.uk>
Hi,
On Sat, 21 Sep 2013 20:07:12 +0200, Gunnar Birke <gunnar.birke@online.de> said: GB> the map, then call subs() with it. Enable the same support for GB> functions however seems very difficult, as functions can only GB> defined at compile time with a macro. And using subs() seems a GB> bit silly with functions:
Unfortunately, I did not understand the difficulty which you were talking about. May be you was mislead by name of GiNaC::function class? For your example, you do not need o define f(x) and g(x,y) as GiNaC::function. They may be happily defined as an GiNaC::ex containing GiNaC::realsymbol x and y. I think, this will be sufficient for most of your purposes.
Best wishes, Vladimir Well, my problem is that I don't understand how I turn an GiNaC::ex containing f(2) into an GiNaC::ex 2*3+2 in the case that f(x) is some GiNaC::ex 3*x + 2 where x is a symbol object. How do I tell GiNaC, that f(x) means 3*x+2 at runtime from the moment on the user defined f(x) in
On 26.09.2013 12:00, ginac-list-request@ginac.de wrote: this manner. What I (think I) understood is that I can define functions with DECLARE_FUNCTION and REGISTER_FUNCTION at compile time and that I can have an expression GiNaC::ex f, which contains something like 3*x+2 where x is a symbol. So far so good, but how can I handle things like f(2)?
On Mon, 30 Sep 2013 17:19:40 +0200, Gunnar Birke <gunnar.birke@online.de> said:
GB> I can have an expression GiNaC::ex f, which contains something GB> like 3*x+2 where x is a symbol. So far so good, but how can I GB> handle things like f(2)? Let f be declared as GiNaC::ex and x be GiNaC::realsymbol. At some point a user may do an assignment f=3*x+2. If later he need the value which you denote by f(2), you need to return him f.subs(x==2). I cannot see a reason why you need to declare f as GiNaC::function, which shall not be confused with mathematical functions as maps X -> Y. -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk www: http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://www.worldscientific.com/worldscibooks/10.1142/p835
On 30.09.2013 17:32, Vladimir V. Kisil wrote:
Let f be declared as GiNaC::ex and x be GiNaC::realsymbol. At some point a user may do an assignment f=3*x+2. If later he need the value which you denote by f(2), you need to return him f.subs(x==2). I cannot see a reason why you need to declare f as GiNaC::function, which shall not be confused with mathematical functions as maps X -> Y. But what if I have multiple functions, for example f(x) and g(x) and some expression e that looks like f(2) + g(5) ... . Calling e.subs(x==2) would bring great trouble. How can I distinguish between the x in f(x) = 3*x+2 and the x in g(x) = 1/2*x-4, for example. Of course I can imagine ways to make this work, but I don't like to reinvent the wheel to much.
On Mon, 30 Sep 2013 17:50:07 +0200, Gunnar Birke <gunnar.birke@online.de> said:
GB> But what if I have multiple functions, for example f(x) and g(x) GB> and some expression e that looks like f(2) + g(5) ... . Calling GB> e.subs(x==2) would bring great trouble. How can I distinguish GB> between the x in f(x) = 3*x+2 and the x in g(x) = 1/2*x-4, for GB> example. Let us start from the mathematical setup. If you need the function h(x)=f(x)+g(x) then you will not arrive to f(2)+g(5). If you really need the value f(2)+g(5), then it shall come from some natural mathematical setup either as (f(x)+g(y)).subs(lst(x==2,y==5)) or f(x).subs(x==2)+g(x).subs(x==5). Once more: GiNaC::function is designed for some purposes, which are different from value substitutions, GiNaC::ex can handle this simple task. -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk www: http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://www.worldscientific.com/worldscibooks/10.1142/p835
participants (2)
-
Gunnar Birke
-
Vladimir V. Kisil