# Function

## Define function $$f(x) = x^2$$


```python
# Define function f(x) = x^2
def f(x):
    return x**2
```


```python
print(f(2))
```

    4


## Define function $$g(x) = x^3$$


```python
# Define function g(x) = x^3
def g(x, y):
    return 2*x + y
```


```python
print(g(1, 2))
```

    4



```python
# Load sympy module
from sympy import *
```


```python
# Define variables
x, y, z = symbols('x y z')
```


```python
# Substitute x = y and y = x
substitution = x**2 + 2*y + z
replacement = [(x**2, y**2), (2*y, 2*x)]
print(substitution.subs(replacement))
```

    2*x + y**2 + z



```python
# Subtitute x, y, and z with their values
number_subs = [(x**2, 2), (2*y, 2), (z, 2)]
print(substitution.subs(number_subs))
```

    6


0a074076985ee06719beef571e230806cf099169
ipynb
Jupyter Notebook
function.ipynb
ricoen/learn-math
fc84bc4d0dc353f8ccb3c52e36155069e9ca5af4
MIT
2021-11-30T10:05:29.000Z
2021-12-30T13:39:08.000Z
function.ipynb
ricoen/learn-math
fc84bc4d0dc353f8ccb3c52e36155069e9ca5af4
MIT
function.ipynb
ricoen/learn-math
fc84bc4d0dc353f8ccb3c52e36155069e9ca5af4
MIT
Qwen/Qwen-72B
1. YES
2. YES