# (f(g(x)) in Sage? How?

Hi everybody ! I am a total beginner and want to learn to use Sagemath. How do I write a script that calculates the following (f(g(x)). I thank you in advance for helping me. Ulf

(f(g(x)) in Sage? How?

1

You may use `compose`

as in the following sample:

```
sage: h = compose(sin, cos)
sage: h(1.23456)
0.323982971162499
sage: sin(cos(1.23456))
0.323982971162499
sage: plot( compose(sin, cos), (0, pi) )
Launched png viewer for Graphics object consisting of 1 graphics primitive
```

(The explicit composition works, of course, but sometimes one needs the composition without passing through the explicit evaluation, as in the above plot example.)

See also: http://doc.sagemath.org/html/en/reference/misc/sage/misc/misc.html

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2019-07-13 09:55:35 +0200 **

Seen: **106 times**

Last updated: **Jul 15 '19**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

You can write

`f(g(x))`

in Sage. In your situation: what is f? what is g?Thanks! How do I define f(x) and g(x). I guess you have to tell SAGE what these functions are first?