Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
6733 Discussions

## how to make a linear polynomial approximation by the least squares method New Contributor I
535 Views

Hello.

I have a function f = y (x). On the interval [a, b] I need to do a linear polynomial approximation of the data.

Linear means that the polynomial is of the first degree.

This means that it is described by two coefficients.

Those. I need to find two coefficients by which I can draw a red line like in the picture.
What MKL library functions can I do this?

1 Solution Black Belt
497 Views

See page 221 of this. Change the names of the variables from t to x and b to y.

4 Replies Black Belt
521 Views

You asked more or less the same question a month ago:

https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-make-an-analogue-of-the-polyfit-function-from-Matlab/m-p/1286941

and the question was answered in that thread. In short, use the Lapack routine ?GELS. New Contributor I
508 Views

Yes you are right. The problem is I can't figure out how to use the Lapack routine ?GELS.

I have my x and y data.

How do I use my data in `LAPACKE_dgels()`?

``info = LAPACKE_dgels(APACK_ROW_MAJOR,'N',m,n,nrhs,*a,lda,*b,ldb);``

And where will the result be? Where will the two coefficients be? Black Belt
498 Views

See page 221 of this. Change the names of the variables from t to x and b to y. Moderator
465 Views

Hi, 