HP Forums
composition of functions - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: composition of functions (/thread-1865.html)



composition of functions - Alberto Candel - 07-22-2014 01:23 AM

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.


RE: composition of functions - Mark Hardman - 07-22-2014 02:17 AM

(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


RE: composition of functions - Alberto Candel - 07-22-2014 03:54 AM

Thank you Mark. But I was looking for something like that on page 12 of this Xcas/giac tutorial


RE: composition of functions - parisse - 07-22-2014 09:51 AM

In Xcas, @ does function composition, not @@, @@ is for composition power.


RE: composition of functions - Alberto Candel - 07-22-2014 03:44 PM

(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).


RE: composition of functions - parisse - 07-22-2014 04:07 PM

Please give an example.


RE: composition of functions - Alberto Candel - 07-22-2014 09:14 PM

(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 @


RE: composition of functions - Mark Hardman - 07-22-2014 11:11 PM

(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


RE: composition of functions - Alberto Candel - 07-23-2014 02:41 PM

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]


RE: composition of functions - parisse - 07-23-2014 06:23 PM

You can also type (f@g)(x). Note that f@g is a function, not an expression.


RE: composition of functions - Alberto Candel - 07-23-2014 09:21 PM

(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).