Questions tagged [quadratic]

Pertains to squares or squaring. Use this tag for questions relating to quadratic equations, quadratic regression, and similar concepts in the context of programming as defined in the Help Center. It may also be used for questions regarding quadratic probing and quadratic time complexity.

Quadratic means to the second (2nd) power, that means, squares (in algebra), or squaring. This tag is used for questions relating to quadratic equations, regression, and similar programming contexts involving quadratic polynomials or terms.

A quadratic polynomial is a polynomial of degree 2. All quadratic polynomials of a single variable x is of the form ax^2 + bx + c where the quadratic coefficient a != 0. The graph of a quadratic function is a parabola, with open end up if a > 0, and down if a < 0. All quadratic polynomials have exactly two complex roots, and can have either two, one, or zero real roots. The famous quadratic formula, applicable for all quadratic polynomials ax^2 + bx + c with real or complex coefficients a,b,c , is given by x = (-b ± sqrt(b^2 - 4*a*c)) / (2*a).

Here are the graphs of three quadratic functions with color coding

three quadratics

A quadratic regression is a method of finding a parabola, represented as a quadratic polynomial of best fit in a set of data. The chart below shows an example of finding a parabola extrapolating the known data points.

Source: https://www.varsitytutors.com/hotmath/hotmath_help/topics/quadratic-regression

Quadratic Complexity means complexity of O(n^2). That means, it grows similar to a positive quadratic function ax^2 + bx + c, a > 0 as x grows, precisely, f(x) == O(x^2) if f(x)/x^2 is constant. There are two forms of quadratic complexity: quadratic space and quadratic time, indicating that this program or algorithm asymptotically requires extra memory space or took time equal to the square of the size of the input n respectively. Selection sort is an example of a quadratic time algorithm. Linear or better complexity is also within quadratic complexity.

420 questions
3
votes
4 answers

Smoothing Small Data Set With Second Order Quadratic Curve

I'm doing some specific signal analysis, and I am in need of a method that would smooth out a given bell-shaped distribution curve. A running average approach isn't producing the results I desire. I want to keep the min/max, and general shape of my…
Rev316
  • 1,920
  • 2
  • 19
  • 24
3
votes
1 answer

Minimize quadratic form energy using matlab. Which function should I use?

I'm new to matlab and try to do some energy minimization work with it. The energy function takes a 3-channel image as input. For every channel, there's a energy term looks like this: E = x'Ax + ||Bx||^2 + w*||x-c||^2, where x,c are vectors of length…
Bei
  • 71
  • 6
3
votes
1 answer

Finding Minimum Effect with Quadratic terms in regression models

Quadratic terms are quite common in regression. Here is an example from John Fox (http://www.jstatsoft.org/v08/i15/paper) library(car) # For data library(splines) # For bs() library(effects) # For plotting data(Prestige) prestige.mod <-…
majom
  • 7,863
  • 7
  • 55
  • 88
3
votes
1 answer

Maximization in quadratic programming using CGAL

I am using CGAL to solve some quadratic programming problems. Assume I want to minimize x^2 for x taking values from -oo(-infinity) to +oo. This could be easily solved by doing: Program qp (CGAL::SMALLER, false, 0, false, 0); qp.set_d(0,…
insumity
  • 5,311
  • 8
  • 36
  • 64
3
votes
1 answer

C++ Eigen Library - Quadratic Programming, Fixed vs Dynamic, Performance

I am looking into doing some quadratic programming, and have seen different libraries. I have seen various Eigen variants of QuadProg++ (KDE Forums, Benjamin Stephens, StackOverflow posts). Just as a test, I forked wingsit's Eigen variant, available…
eacousineau
  • 3,457
  • 3
  • 34
  • 37
3
votes
2 answers

Haskell and Quadratics

I have to write a program to solve quadratics, returning a complex number result. I've gotten so far, with defining a complex number, declaring it to be part of num, so +,- and * - ing can take place. I've also defined a data type for a quadratic…
3
votes
2 answers

How to calculate non-zero dx/dt and dy/dt at t = 0 when P0 == P1 on a cubic Bezier curve?

Before I begin the problem, I use P0, P1, P2, and P3 for the four cubic Bezier points, and 't' since it's parametric. Also, I have searched for a similar problem in this site, as well as Google, and couldn't find one. I apologize if this is a…
Ootawata
  • 63
  • 1
  • 7
2
votes
3 answers

C++ + glut + OpenGL + gluSphere doesn't draw anything

I'm using GLUT to work with OpenGL (would work with SDL if I could). And I need to draw sphere. I'm using gluSphere but it simply doesn't draw anything. Here's my GLUT initialization: // Initializes display glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB…
Vyktor
  • 20,559
  • 6
  • 64
  • 96
2
votes
1 answer

Spliting a quadratic slice into 3 smaller slices HTML5 CANVAS JS

I have a quadratic curve that I use to create a slice of a piechart. The slice is situated in an axis of x and y, with the center point at (0,0). The radius is variable at radiusX and radiusY. This slice travels 90 degrees. I need to split this…
Feeney
  • 357
  • 2
  • 4
  • 12
2
votes
1 answer

Draw separate linear and quadratic regression graphs for each group in the same panel

I'd like to draw linear and quadratic regression line per group (data is different). For example, I make a graph like…
Jin.w.Kim
  • 599
  • 1
  • 4
  • 15
2
votes
1 answer

Python: Using CVXOPT for quadratic programming

I'm using CVXOPT to do quadratic programming to compute the optimal weights of a potfolio using mean-variance optimization. There is a great example at http://abel.ee.ucla.edu/cvxopt/userguide/coneprog.html#quadratic-programming. However, the…
Jason Strimpel
  • 14,670
  • 21
  • 76
  • 106
2
votes
1 answer

using quadprog for portfolio optimization

I have my input parameters mu (mean vector μ), Q (covariance matrix Q), and tau (risk tolerance τ) and I need to return the vector h (asset weights) that maximizes the following utility function U defined by: U(h)= −1/2h^T*Q*h + τ*h^T*μ subject to…
eruiz
  • 59
  • 9
2
votes
2 answers

How to add quadratic constraints to the model by using DOcplex (python)?

Take this quadratic constraint as example: (-x1^2 + x2^2 + x3^2 <= 0) Note that in the CPLEX Python API, the above constraint is formalated as follows: m.quadratic_constraints.add( quad_expr=[["x1", "x2", "x3"], ["x1", "x2", "x3"], [-1, 1, …
aniuniu
  • 23
  • 3
2
votes
2 answers

How to code quadratic form both naively and efficiently

I'm trying to code a quadratic form Z'(S)^{-1} Z The code is as below z <- matrix(rnorm(200 * 100), 200, 100) S <- cov(z) quad.naive <- function(z, S) { Sinv <- solve(S) rowSums((z %*% Sinv) * z) } However, I'm not sure I…
Alison
  • 35
  • 4
2
votes
0 answers

CVXOPT QP SOLVER : TypeError: 'A' must be a 'd' matrix with 10 columns

I'm having trouble with the CVXOPT QP Solver lately: I keep receiving the TypeError: 'A' must be a 'd' matrix with 10 columns error while I had, indeed, a matrice A of dimension (10,10) and of type d. Here is the code: import numpy as np from cvxopt…
Kermit
  • 3,112
  • 2
  • 10
  • 34