C++ performance: Linear regression in other way Here is the code that can be used for calculation of mathematical function, like ax^2 + bx + c.
It is fast enough if you choose small length, otherwise if programmer don't know the small range, that code can be really slow. I've made it specially on C++ to be more fast.
#include &lt;iostream&gt;
#include &lt;vector&gt;

using namespace std;

template&lt;class var&gt;
var Module(var x){
    if (x &gt;= 0)
        return x;
    else
        return x*-1;
}

class Linear {
public:
    float resA, resB, resC;
    float err;

    float Predict(float a, float b, float c, float x) {
        return ((a * (x*x)) + (b*x) + c);
    }

    float Predict(float x) {
        return ((resA * (x * x)) + (resB * x) + resC);
    }

    float ErrorAv(float a, float b, float c, vector&lt;float&gt; input, vector&lt;float&gt; output) {
        float error = Module(Predict(a, b, c, input[0]) - output[0]);
        for (int i = 1; i &lt; input.size(); i++)
            error = (Module(Predict(a, b, c, input[i]) - output[i]) + error)/2;
        return error;
    }

    void LinearRegr(vector&lt;float&gt; input, vector&lt;float&gt; output, float maximum, float minimum = 0, float step = 1) {
        if (step == 0)
            step++;
        float a, b, c;

        float lastError = INFINITY;
        for (a = minimum; a &lt;= maximum; a += step)
            for (b = minimum; b &lt;= maximum; b += step)
                for (c = minimum; c &lt;= maximum; c += step) {
                    float error = ErrorAv(a, b, c, input, output);
                    if (error &lt; lastError) {
                        lastError = error;
                        resA = a;
                        resB = b;
                        resC = c;
                        err = lastError;

                        if (!lastError)
                            return;
                    }
                }
            
        
    }
};

#include &lt;ctime&gt;
int main(){
    vector&lt;float&gt; input; //Input example.
    vector&lt;float&gt; output; //Output example.

    float a = 10.5, b = -7, c = 5.5; //Variables as search values.

    //Fill dataset:
    for (int i = 0; i &lt; 100; i++) {
        input.push_back(i);
        output.push_back((a * (i * i)) + (b * i) + c);
    }

    clock_t begin = clock(); //Start clock while searching a, b, c values
    Linear linear; 
    linear.LinearRegr(input, output, 15, -10, 0.5); //Start searching.
    cout &lt;&lt; &quot;Time: ~&quot; &lt;&lt; double(clock() - begin) / CLOCKS_PER_SEC &lt;&lt; &quot; seconds.&quot; &lt;&lt; endl;

    cout &lt;&lt; linear.resA &lt;&lt; &quot;*x^2 + &quot; &lt;&lt; linear.resB &lt;&lt; &quot;x + &quot; &lt;&lt; linear.resC &lt;&lt; endl; //Enter results.
}

As can see, Linear.LinearRegr function can get from 3 to 5 parameters.
I dont need make the code super prettier(for me its already pretty), just want to work it faster.
How to optimize and make it faster?
Optimizing the algorithm
If \$M\$ is the number of steps between minimum and maximum, and \$N\$ is the size of the input and output vectors, then your algorithm has complexity \$\mathcal{O}(N \cdot M^3)\$. Also, it likely doesn't find the optimal solution unless you use a very small step size, and you have to choose minimum and maximum correctly. There are other algorithms that will both give you a guaranteed optimal solution without having to specify a range and a step size, and which have complexity \$\mathcal{O}(N)\$. This is possible since the problem of linear least squares can be solved analytically, and can be implemented efficiently on a computer.
If you don't want to go for the exact mathematical approach, and perhaps want to perform regressions of more complex functions that don't have an exact solution, then you might want to look into algorithms that approach the problem in a smarter way than just brute-forcing all possible values of the parameters. A typical solution to this kind of problem is to implement a gradient descent algorithm.
Choosing the right error function
The way you calculate the error (or rather the residual to be more precise) is quite strange. Normally one would try to minimize the sum of the squares of the difference between a data point and the predicted value. However, your error function is using the linear difference, and weighting it such that the first datapoint has the least weight, and the last datapoint weighs as much as all the other datapoints combined:
float error = Module(Predict(a, b, c, input[0]) - output[0]);
for (int i = 1; i &lt; input.size(); i++)
    error = (Module(Predict(a, b, c, input[i]) - output[i]) + error)/2;

Unless this is really the intended function, you should probably replace this with a function that calculates the least squares residual.