I am trying to solve the set of linear equations:
min || Ax - B ||^2
for t in [0,1]
such that the coefficients x in this equation satisfy the linear equation:
C x = D
This system attempts to fit a set of Polynomials to approximate a function F(t) over the range of t.
- A is a matrix, representing the map of the set of polynomials over the range of t values
- x is a vector of coefficients (what I want) corresponding to a weight applied to each polynomial in A
- B is a vector representing the F(t) values,
- C is a matrix and D a vector, which together represent the boundary conditions on the coefficients of this system
This is a case of solving linear equations using the constraint of ordinary least squares.
While there are known closed form solutions e.g. Karush-Kuhn-Tucker I'm looking for a routing in scipy
/ numpy
that can be used to solve this.
Research has shown the scipy.optimize
module, which includes functions such as:
scipy.optimize.least_squares .
The above is suggested both from this question and this question.
But these do not have conditions that work for a constraint of some other linear equation. What can I use in scipy
and numpy
to do this?