Cubic "bezier" curve of grade n This is code I wrote for calculating bezier curves as quickly and RAM efficiently as possible.

I would like to know if there are faster ways to optimize anything, because I am very new to C++ and efficiency methods.

Lastly, if there is a variable that could be more explicitly named, also let me know.

#include &lt;vector&gt;

double* bezier_interp (double* points, double* temp_space, int temp_space_size, int points_total, double t_step_t) {
    memcpy(temp_space, points, temp_space_size);
    for (int pointsi = points_total; pointsi &gt; 1; --pointsi){
        for (int pointsj = 1; pointsj &lt; pointsi; pointsj++) {
            points[pointsj-1] -= (points[pointsj-1] - points[pointsj]) * t_step_t;
        }
    }
    return points;
}

double* bezier_t (double* numbers, int points_total, int definition) {
    double *result = new double[definition];

    double t_step = 1 / ((double) definition - 1);
    double t_step_t;
    double* temp_space = new double[points_total];
    int temp_space_size = sizeof(*temp_space) * points_total;
    for (int t = 0; t &lt; definition; t++) {
        t_step_t = t * t_step;
        result[t] = *bezier_interp(numbers, temp_space, temp_space_size, points_total, t_step_t);
    }
    delete[] temp_space;
    return result;
}

#include&lt;iostream&gt;

int main() {
    double numbers_x[] = {
        0, 0, 4, 4
    };
    double numbers_y[] = {
        0, 4, 4, 0
    };
    int definition = 8;
    double* xs = bezier_t(numbers_x, 4, definition);
    double* ys = bezier_t(numbers_y, 4, definition);
    for (int dix = 0; dix &lt; definition; dix++){ std::cout &lt;&lt; xs[dix] &lt;&lt; "\t"; }
    std::cout &lt;&lt; "\n";
    for (int diy = 0; diy &lt; definition; diy++){ std::cout &lt;&lt; ys[diy] &lt;&lt; "\t"; }
    std::cin.get();
    return 0;
}
#include &lt;vector&gt; is pointless. There is no vectors in the code.
Unless I am missing something obvious, temp_space plays no role in the calculations.
pointsi and pointsj do not sound right (too much of visual noise makes it hard to tell them apart). It is one of the rear cases where I'd go for plain i and j.
t_step_t is confusing, and strictly speaking unnecessary. You may calculate it at the point of invocation as

result[t] = *besier_interp(..., t * t_step);