I have a func
f(x) = sin(x/5.0)*exp(x/10.0) + 5*exp(-x/2.0)
I need to solve system of linear equations
w0 + w1x1 + w2(x1)**2 + ... + wn(x1)**n = f(x1)
I solve that but I have a problem with plot it
from math import sin, exp
from scipy import linalg
import numpy as np
b = []
def f(x):
return sin(x/5.0)*exp(x/10.0) + 5*exp(-x/2.0)
for i in [1, 15]:
b.append(f(i))
A = []
for i in [1, 15]:
ij = []
x0 = i ** 0
x1 = i ** 1
ij.append(x0)
ij.append(x1)
A.append(ij)
matrix = np.array(A)
b = np.array(b).T
x = linalg.solve(matrix, b)
from matplotlib import pyplot as plt
plt.plot(x, f(x))
But it returns
TypeError: only length-1 arrays can be converted to Python scalars
How can I solve this problem?