composition of functions
07-22-2014, 01:23 AM
Post: #1
 Alberto Candel Member Posts: 169 Joined: Dec 2013
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.
07-22-2014, 02:17 AM (This post was last modified: 07-22-2014 02:19 AM by Mark Hardman.)
Post: #2
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
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.
07-22-2014, 03:54 AM
Post: #3
 Alberto Candel Member Posts: 169 Joined: Dec 2013
RE: composition of functions
Thank you Mark. But I was looking for something like that on page 12 of this Xcas/giac tutorial
07-22-2014, 09:51 AM
Post: #4
 parisse Senior Member Posts: 1,327 Joined: Dec 2013
RE: composition of functions
In Xcas, @ does function composition, not @@, @@ is for composition power.
07-22-2014, 03:44 PM
Post: #5
 Alberto Candel Member Posts: 169 Joined: Dec 2013
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).
07-22-2014, 04:07 PM
Post: #6
 parisse Senior Member Posts: 1,327 Joined: Dec 2013
RE: composition of functions
Please give an example.
07-22-2014, 09:14 PM
Post: #7
 Alberto Candel Member Posts: 169 Joined: Dec 2013
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 @
07-22-2014, 11:11 PM
Post: #8
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
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.
07-23-2014, 02:41 PM (This post was last modified: 07-23-2014 03:32 PM by Alberto Candel.)
Post: #9
 Alberto Candel Member Posts: 169 Joined: Dec 2013
RE: composition of functions
That works, thanks.
But it would be better without the simplify part.

 Actually, if you define k:=f@g, then k(x)=x^2+2*x+1, without the simplify.[/edit]
07-23-2014, 06:23 PM
Post: #10
 parisse Senior Member Posts: 1,327 Joined: Dec 2013
RE: composition of functions
You can also type (f@g)(x). Note that f@g is a function, not an expression.
07-23-2014, 09:21 PM
Post: #11
 Alberto Candel Member Posts: 169 Joined: Dec 2013
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).
 « Next Oldest | Next Newest »

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