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.

380 questions
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
  • 4,590
  • 6
  • 33
  • 59
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,147
  • 2
  • 30
  • 36
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
  • 53
  • 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
  • 19,006
  • 5
  • 53
  • 93
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

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
  • 11,832
  • 19
  • 65
  • 95
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
1 answer

Can't get the algebra (quadratic formula) to work

I have been working on very simple calculator with a few functions for a computer science course, and of the calculators functions is solving quadratic equations. I have tried to make it work but I get this error:screenshot of error. I don't…
Lucas Grau
  • 35
  • 3
2
votes
3 answers

Factor a quadratic polynomial in Python

Since factoring a quadratic equation in my head just happens, and has done that since I learned it - how would I go about starting to write a quadratic factorer in Python?
tekknolagi
  • 9,371
  • 20
  • 66
  • 112
2
votes
1 answer

Smooth transition between values (ease in/out)

I'll probably get negative reputation for asking this question but I'm stuck and need help. I need to do a nice and smooth easing between two values, the result being displayed in a textbox. For example, my textbox is showing "125" and have to grow…
2
votes
1 answer

Polynomial regression: Why do you need to define polynomial terms outside of lm() to avoid singularities?

If you try to run a polynomial regression where x^2 is defined in the lm() function, the polynomial term is dropped due to singularities. However, if we define the polynomial term outside the lm(), the model is fit correctly. It seems like it…
Dr. Beeblebrox
  • 746
  • 2
  • 11
  • 28
2
votes
0 answers

Gradient of Semi Log Curve in Excel

I need help in automating to get the gradient slope on the graph with the input for the x-value for the graph. The graph is void ratio against Pressure. Values are as follows for the top curved region of the graph. kPa 13 25 50 100…
2
votes
1 answer

Java only returns 0 when equation is unfactorable

import java.util.Scanner; public class QuadraticEquation { private int a, b, c, d, s1, s2; public QuadraticEquation() { a = 1; b = 2; c = 1; d = 0; s1 = -1; s1 = -1; } public…
Hmm
  • 79
  • 6
2
votes
1 answer

Simple C++ quadratic Equation solver returning incorrect answers

I'm working on a school assignment that requires using the quadratic equation to find the roots of ax^2+bx+c=0, with a b & c as inputs. #include #include using namespace std; int main() { int a, b, c; cout << "Enter…
bob
  • 85
  • 1
  • 6