Post Reply 
composition of functions
07-22-2014, 01:23 AM
Post: #1
composition of functions
Is there a command for the composition of two functions, f and g, in CAS? There is f@@g in xcas, but I do not seem to get it to work in the Prime.
Find all posts by this user
Quote this message in a reply
07-22-2014, 02:17 AM (This post was last modified: 07-22-2014 02:19 AM by Mark Hardman.)
Post: #2
RE: composition of functions
(07-22-2014 01:23 AM)Alberto Candel Wrote:  Is there a command for the composition of two functions, f and g, in CAS? There is f@@g in xcas, but I do not seem to get it to work in the Prime.

Try something along the lines of:

f(x):=√(x²-1)
g(x):=4*x

The composition of the two functions is simply:

f(g(x))

HTH

Ceci n'est pas une signature.
Find all posts by this user
Quote this message in a reply
07-22-2014, 03:54 AM
Post: #3
RE: composition of functions
Thank you Mark. But I was looking for something like that on page 12 of this Xcas/giac tutorial
Find all posts by this user
Quote this message in a reply
07-22-2014, 09:51 AM
Post: #4
RE: composition of functions
In Xcas, @ does function composition, not @@, @@ is for composition power.
Find all posts by this user
Quote this message in a reply
07-22-2014, 03:44 PM
Post: #5
RE: composition of functions
(07-22-2014 09:51 AM)parisse Wrote:  In Xcas, @ does function composition, not @@, @@ is for composition power.

Yes, thanks, I should have written f@g for the composition and f@@n for the composite of f with itself n times. The prime accepts f@g, but it seems to return a function like (x,y)->(f(x),g(y)) (if f and g are 1 variable functions).
Find all posts by this user
Quote this message in a reply
07-22-2014, 04:07 PM
Post: #6
RE: composition of functions
Please give an example.
Find all posts by this user
Quote this message in a reply
07-22-2014, 09:14 PM
Post: #7
RE: composition of functions
(07-22-2014 04:07 PM)parisse Wrote:  Please give an example.

For instance

f(x):=x^2
g(x):=x+1
f@g returns ((x)->x^2)@((x)->x+1)

I do not know the meaning of @
Find all posts by this user
Quote this message in a reply
07-22-2014, 11:11 PM
Post: #8
RE: composition of functions
(07-22-2014 09:14 PM)Alberto Candel Wrote:  
(07-22-2014 04:07 PM)parisse Wrote:  Please give an example.

For instance

f(x):=x^2
g(x):=x+1
f@g returns ((x)->x^2)@((x)->x+1)

I do not know the meaning of @

The CAS is providing an intermediate solution to the composition.

If you execute:

simplify(f@g)

You get the expected result:

(_(x))->_(x)²+2*_(x)+1

Ceci n'est pas une signature.
Find all posts by this user
Quote this message in a reply
07-23-2014, 02:41 PM (This post was last modified: 07-23-2014 03:32 PM by Alberto Candel.)
Post: #9
RE: composition of functions
That works, thanks.
But it would be better without the simplify part.

[edit] Actually, if you define k:=f@g, then k(x)=x^2+2*x+1, without the simplify.[/edit]
Find all posts by this user
Quote this message in a reply
07-23-2014, 06:23 PM
Post: #10
RE: composition of functions
You can also type (f@g)(x). Note that f@g is a function, not an expression.
Find all posts by this user
Quote this message in a reply
07-23-2014, 09:21 PM
Post: #11
RE: composition of functions
(07-23-2014 06:23 PM)parisse Wrote:  You can also type (f@g)(x). Note that f@g is a function, not an expression.

Yes, thanks. I think my original mistake was to write f@g(x) instead of (f@g)(x).
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)