In [1]:
```get_ipython().ast_node_interactivity = 'all'
import matplotlib.pyplot as plt
import os
import math
import numpy as np```
In [2]:
```def plot_fn(fn, start, end, step):
l = [fn(x) for x in np.arange(start, end, step)]
plt.plot(l)```
In [3]:
```def real_f(x):
PI = 3.14159265
return (1 / math.sqrt(2 * PI)) * math.exp(-0.5 * math.pow(x, 2.0))

plot_fn(real_f, -3, 3, 0.0001)```
Out:
In [1]:
```def make_poly_f(params):
def f(x):
res = 0
l = len(params)
for i, param in enumerate(params):
res += param * math.pow(x, l - i - 1)
return res
return f

params = [-0.001351881896958825, -1.3472626944500271e-06, 0.0258183586346407, 1.1661833394212631e-05, -0.16774103108355934, -1.8935633914021407e-05, 0.39197121674427576]
pf = make_poly_f(params)

plot_fn(real_f, -3, 3, 0.0001)
plot_fn(pf, -3, 3, 0.0001)```
Out:
`[ERROR] NameError: name 'plot_fn' is not defined`
In [21]:
```inp = [3, 1, 4, 4, 3, 1, 1]
out = [2, 6, 1, 7, 5, 3, 4]

x = [i for i in range(len(inp))]
y = [0 for _ in inp]

for i, v in enumerate(inp):
val = x.pop(v - 1)
y[val] = i + 1

y```
Out [21]:
`[2, 6, 1, 7, 5, 3, 4]`