# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import numpy as np
import matplotlib.pyplot as plt

def polyx(a,x):
    # evaluates a polynomial f(x) of x,
    # given a nump array of coefficients a,
    # such that 
    # 
    # f(x) = a[0] + a[1]x + a[2]x**2 + ... + a[n-1]x**(n-1)
    
    f = 0
    for i in range(len(a)):
        f = f + a[i]*x**i
        
    return f


a = np.array([1,-2,1])
x = np.linspace(-3,3,100)

plt.plot(x,polyx(a,x))



