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
16
votes
4 answers

Find new control point when endpoint change in cubic bezier curve

I'm implementing cubic bezier curve logic in my one of Android Application. I've implemented cubic bezier curve code on canvas in onDraw of custom view. // Path to draw cubic bezier curve Path cubePath = new Path(); // Move to startPoint(200,200)…
Hitesh Patel
  • 2,868
  • 2
  • 33
  • 62
14
votes
3 answers

Spline Interpolation with Python

I wrote the following code to perform a spline interpolation: import numpy as np import scipy as sp x1 = [1., 0.88, 0.67, 0.50, 0.35, 0.27, 0.18, 0.11, 0.08, 0.04, 0.04, 0.02] y1 = [0., 13.99, 27.99, 41.98, 55.98, 69.97, 83.97, 97.97,…
Hellfish
  • 1,685
  • 3
  • 12
  • 10
13
votes
5 answers

Finding Y given X on a Cubic Bezier Curve?

I need a method that allows me to find the Y-coordinate on a Cubic Bezier Curve, given an x-coordinate. I've come across lots of places telling me to treat it as a cubic function then attempt to find the roots, which I understand. HOWEVER the…
Captain Awesome
  • 141
  • 1
  • 4
11
votes
6 answers

Solving a cubic equation

As part of a program I'm writing, I need to solve a cubic equation exactly (rather than using a numerical root finder): a*x**3 + b*x**2 + c*x + d = 0. I'm trying to use the equations from here. However, consider the following code (this is Python…
astrofrog
  • 32,883
  • 32
  • 90
  • 131
10
votes
2 answers

Extract TCP round trip time (RTT) estimations on linux

I have apache server running on Ubuntu. Client connects and downloads an image. I need to extract RTT estimations for the underlying TCP connection. Is there a way to do this? Maybe something like running my tcp stack in debug mode to have it log…
kakhkAtion
  • 2,264
  • 22
  • 23
6
votes
2 answers

Resolution independent cubic bezier drawing on GPU (Blinn/Loop)

Based on the following resources, I have been trying to get resolution independent cubic bezier rendering on the GPU to work: GPU Gems 3 Chapter 25 Curvy Blues Resolution Independent Curve Rendering using Programmable Graphics Hardware But as stated…
scippie
  • 2,011
  • 1
  • 26
  • 42
5
votes
3 answers

Interpolation advice (linear, cubic?)

I need to find good approximations of the points where an undefined function intersect a threshold value. I'm stepping through my space and whenever I find that two subsequent steps are on different sides of the threshold, I add a point somewhere in…
David Rutten
  • 4,716
  • 6
  • 43
  • 72
4
votes
2 answers

Quadratic Time for 4-sum Implementation

Given an array with x elements, I must find four numbers that, when summed, equal zero. I also need to determine how many such sums exist. So the cubic time involves three nested iterators, so we just have to look up the last number (with binary…
Filuren
  • 661
  • 2
  • 7
  • 19
4
votes
2 answers

Cubic root function cbrt() in Visual Studio 2012

I am writing a program in Visual Studio 2012 Professional (Windows) in C/C++ which consists of calculating many powers using pow(). I ran the profiler to find out why it takes such a long time to run and I found that pow() is the bottleneck. I have…
EJG89
  • 1,189
  • 7
  • 17
4
votes
4 answers

Proper implementation of cubic spline interpolation

I was using one of the proposed algorithms out there but the results are very bad. I implemented the wiki algorithm in Java (code below). x(0) is points.get(0), y(0) is values[points.get(0)], α is alfa and μ is mi. The rest is the same as in the…
Mr Jedi
  • 33,658
  • 8
  • 30
  • 40
4
votes
2 answers

Why am I receiving a "no ordering relation defined for complex numbers" error?

See this question for some background. My main problem on that question was solved, and it was suggested that I ask another one for a second problem I'm having: print cubic(1, 2, 3, 4) # Correct solution: about -1.65 ... if x > 0: TypeError: no…
user2330618
3
votes
1 answer

find cubic root of a number from 0 to 125

I am trying to write a C code of a function that takes an integer from 0 to 125 and return the cubic root of that integer only if it's a whole number ( 1,2,3,4,5 ) and if it's not, return 0 instead. So I wrote this code: unsigned int cubic(unsigned…
3
votes
1 answer

Cubic spline in matlab

i have trouble getting a matlab code to work properly! i found a cubic spline code in matlab to give me the interpolated polynomial. and i simply give it an example to work: Xi = [0 0.05 0.1] Fi = [1 1.105171 1.221403] Fi' = [2 _ 2.442806] but it…
Yasin
  • 609
  • 1
  • 10
  • 22
3
votes
2 answers

Constant Speed Over Cubic Bezier Curve

The problem that I'm trying to solve is that I can't seem to move a 2D point along a cubic bezier curve at a constant speed. I followed this tutorial: http://catlikecoding.com/unity/tutorials/curves-and-splines/ to implement the curve initially and…
doomcake
  • 25
  • 1
  • 3
3
votes
1 answer

Solving a cubic to find nearest point on a curve to a point

Ok, I have a projectile that has its position defined such that: a.x = initialX + initialDX * time; a.y = initialY + initialDY * time + 0.5 * gravtiy * time^2; I want to be able to predict which obstacles in my environment this projectile will…
Tech-no
  • 31
  • 3
1
2 3 4 5 6 7