Métodos dos minimos quadrados

$ f(x) = c_0 * f_0(x) + c_1 * f_1(x) + ... + c_n * f_n(x) $

A = | $f_0(x_0)$ $f_1(x_0)$ ... $f_n(x_0)$ |
| $f_0(x_1)$ $f_1(x_1)$ ... $f_n(x_1)$ |
| ... ... ... ... |
| $f_0(x_n)$ $f_1(x_n)$ ... $f_n(x_n)$ |

C = |C0|
|C1|
|...|
|Cn|

Y = |Y0|
|Y1|
|...|
|Yn|


In [2]:
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline

In [4]:
def f0(x):
    return x

def f1(x):
    return 1

f = np.array([[f0], [f1]])
def F(C, x):
    ans = 0
    for i in range(C.shape[0]):
        ans += C[i] * f[i](x)
    return ans

In [5]:
C = np.array([1, 0])
x = np.linspace(0, 10, 100)
y = F(C, x)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-ba517c79ee83> in <module>()
      1 C = np.array([1, 0])
      2 x = np.linspace(0, 10, 100)
----> 3 y = F(C, x)

<ipython-input-4-76e2eb9cb889> in F(C, x)
      9     ans = 0
     10     for i in range(C.shape[0]):
---> 11         ans += C[i] * f[i]
     12     return ans

TypeError: unsupported operand type(s) for *: 'int' and 'function'

In [ ]: