Questions tagged [cubic]

Pertaining to cubing, or being of the third power. In mathematics, it is notated as a superscript three (x³). Use this tag for programming-relevant questions that involves cubic equations and similar concepts, which have applications such as computational complexity, and cubic spline interpolation. This tag is not to be confused with the "cube" tag, which refers to the *OLAP cube*.

Cubic means of degree three. Variables raised to the third variable are called cubes in algebra, and a cubic polynomial is a third-degree polynomial.

Cubic polynomials are polynomials whose highest degree is three. All cubic polynomials of one variable are of the form A*x^3 + B*x^2 + C*x + D where leading coefficient A is nonzero. The graph of a cubic function rises for positive A, and falls for negative A, but it is described as "bendy" and that it has an inflection point.

All cubic polynomials have three complex roots, where one to three of the roots are real. Therefore, all cubic polynomials may be factored as (x-p)*(x-q)*(x-r) where p, q, r are complex and potentially real roots. All three complex roots of every cubic polynomial can be solved in terms of radicals, this is known as the Cardano formula.

The first derivative of a cubic polynomial is a quadratic polynomial, which is 3*A*x^2 + 2*B*x + C

Here are the graphs of five cubic polynomials.

enter image description here

Cubic Spline Interpolation is a process where a shape or curve is approximated or interpolated by piecewise cubic functions. This is useful for extrapolating sets of points or data with a smooth curve, as well as approximating shapes and fonts.

Here is an example of a cubic spline interpolating a series of five points.

Source: http://mathworld.wolfram.com/CubicSpline.html

Cubic Complexity means having an asymptotic complexity of O(x^3). That means, it grows similar to a positive cubic function A*x^3 + B*x^2 + C*x + D as x grows, or in calculus terms, f(x) == O(x^3) if the limit as x grows to positive infinity, f(x)/x^3 is a constant.

There are two forms of cubic complexity: cubic space and cubic time, indicating that this program or algorithm asymptotically requires extra memory space or took time equal or less than the cube of the size of the input n respectively. It is worse than quadratic complexity, but it is still considered efficient as it is in polynomial complexity. Matrix multiplication between m×k and k×n matrices is a cubic-time algorithm of time O(m*k*n), whereas the best square matrix multiplication can be done faster than cubic time but still slower than quadratic time; matrix multiplication is therefore a cubic time algorithm.

Related tags

  • : Generalization of 'cubic' and 'quadratic' by having any (constant) degree.

  • , : Tags referring to lower polynomial times

  • , , : Tags relating to complexity, including the famous polynomial time such as linear time, quadratic time, and cubic time.

  • : Applications of cubic polynomials where a curve or point set is approximated by piecewise cubic polynomials.

  • : Do not confuse between "cubic" and "cube" tags. Here, the "cube" tag refers to the OLAP cube datastructure.

Read More:

103 questions
2
votes
1 answer

What is considered a cubic algorithm when considering time complexity?

So I've implemented this algorithm and after analyzing its time complexity I've found that its upper bound is restricted by O(n^2*m) where n is the number of vertices in a graph and m is the number of edges. I'm wondering if this would be considered…
John Smith
  • 181
  • 1
  • 7
2
votes
2 answers

Cubic Regression (best fit line) in JavaScript

I'm having the worst time trying to find a JavaScript code that could allow me to do cubic regressions. Would write it myself, but my understanding of polynomial math is, well, suboptimal. So, here's what I'm looking for. Given an input of an array…
teeZee
  • 977
  • 1
  • 8
  • 8
2
votes
1 answer

cubic and quadratic graphs?

I am trying to make a pygame program that 'sketches' cubic and quadratic graphs. my code is below. but every time i try running the code i get this error. y = 250 - ((A(x)**B)+(C(x)**D)+(E(x))+c) TypeError: 'int' object is not callable I don't…
2
votes
1 answer

How to interpolate a set of points in 3D using Matlab (or Excel)

I have 19 points (x, y, z values) which can be joined up to produce a curve (very angular). Is there a way to output 100 points (x, y, z values) which include the original 17 points after smoothing the data? My aim is to simply make the line…
dnk8n
  • 675
  • 8
  • 21
2
votes
1 answer

C++: Solving Cubic Equations

This site solves cubic equations, and has the equations it uses I wrote this function to get the same results but it's not working void cubicFormula(float a, float b, float c, float d, float *results) { float a2 = a*a; float b2 = b*b; …
rraallvv
  • 2,875
  • 6
  • 30
  • 67
1
vote
1 answer

Approximate n grade Bezier through cubic and/or quadratic Bezier curves

I'm trying to draw a 6 grade (start point, 4 control points, end point) Bezier curve but the API offers me only cubic and quadratic curves methods. Is there a way to split or approximate the 6 (or n) grade curve ONLY through cubic or quadratic…
Alex
  • 5,510
  • 8
  • 35
  • 54
1
vote
1 answer

How to stop the roots of a cubic from becoming mixed up when plotting the 3 roots as contour plots?

I have a function which determines the roots of a complex cubic. I am solving the cubic for a variety of k0 and k1 values and showing the solutions as contour plots. Since the cubic has three roots, I produce 3 contour plots for the real parts and 3…
George M
  • 11
  • 1
1
vote
1 answer

Interpolate CubicSpline with Pandas

I have a dataframe with ResidMat and Price, I use scipy to find the interpolate CubicSpline. I used CubicSpline and apply to find all data on my dataset. But it's not very fast, because in this case have no more data. I will have more than a hundred…
Flo Cp
  • 281
  • 2
  • 13
1
vote
1 answer

Making a cubic ease-in-out curve dynamically switch its goal position

Using, Lua, I've made a function to cubically (easing in/"accelerating", then easing out/"decelerating" afterwards) interpolate from one number to another; SimpleSpline takes a number between 0-1 (the time the animation's been going, easiest put),…
mrjackman
  • 21
  • 2
1
vote
0 answers

Newton's root finding method in MATLAB: quadratic vs cubic convergence

So I have this example Newton's method for root finding with quadratic convergence below. It takes a function f, the derivative of f df, initial guess g, and tolerance tol. It outputs the # iterations it to reach nth root, the root estimate r, and…
dgdgdg
  • 11
  • 1
1
vote
0 answers

3D Hermite cubic spline interpolation in R

I have a dataframe composed of three numeric variables (x,y,z) which are the coordinates of a 3D surface obtained from interp2xyz from the akima package. x y z 0.600 0.02 42.801 0.604 0.02 42.527 0.609 0.02 42.253 0.614 0.02 41.979 0.618 0.02…
1
vote
2 answers

PHP multiplication string

I have just begun learning PHP, and I have been working on a practice page for finding the cubic volume of a cube. The information is taken from submissions on an html form and I have written the code for taken the submitted information as the…
Zephyranthes
  • 55
  • 1
  • 7
1
vote
1 answer

find roots of cubic polynomial

I'm trying to find the roots of a cubic polynomial ax^3+bx^2+cx+d=0 using math.numerics. The package is great, but I'm struggling to get started with it. Please can someone explain how to find the roots, and a simple explanation on how to run the…
Zeus
  • 1,496
  • 2
  • 24
  • 53
1
vote
2 answers

Matlab - Poorly conditioned polynomial

I have a question asking me to do linear, quadratic and cubic fit for population data, then estimate the population at the year 1915. The linear and quadratic fits work, however the cubic seems to raise an error telling me the polynomial is badly…
Vladamir
  • 247
  • 1
  • 3
  • 11
1
vote
2 answers

Subdivide multi segmented Cubic Bezier spline

First of let me apologies for a bad English and probably not very straight forward question, as I am not really sure how to call it. I have a multi segmented Cubic Bezier curve In After Effects, it is is defined by 5 vertices with IN & OUT tangents.…