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
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

R: Quadratic curve is printing as dozens of lines

Instead of printing a nice curve, R is printing a dense mess of line segments. The edge of that dense mess looks exactly like the curve I'm trying to print, though. I have datasets X2 and Y2 plotted and am trying to print a quadratic curve on the…
Mason
  • 23
  • 4
2
votes
0 answers

Solving non concave quadratic function in matlab with constraints

How can I solve non concave quadratic function in matlab with constraints. I tried using quadprog but it doesn't work I have to optimize a function f=x'Ax with constraints that sum of xs is equal to 1 and 0<=x<=1. My function is not concave. So I…
user34790
  • 1,900
  • 5
  • 26
  • 34
2
votes
1 answer

Quadratic sieve and nth powers

I implemented the quadratic sieve in Haskell according to the basic algorithm specified on the Wikipedia page. It works great on most integers, however it fails to find a factorization on numbers N that are nth powers. For even powers (squares), the…
Nick
  • 2,571
  • 5
  • 24
  • 34
2
votes
2 answers

Issues with quadratic programming

I am trying to do a quadratic programming. I have an affinity matrix A, and I have to maximize certain function x'*A*x. This is basically related to feature matching i.e., matching points to labels This is basically related to establish a connection…
user34790
  • 1,900
  • 5
  • 26
  • 34
2
votes
2 answers

CGAL Quadratic Programming Solver, how to enter "x^4" in objective function? and in the constraints?

I am trying to minimize a function like the following: a*x^4+b*y and constraints like: x^2 <= a in CGAL::Quadratic_program. To input "x^2" in the objective function I can do the following: qp.set_d(X, X, 2); but what about "x^4" ? To add a…
fusio
  • 3,799
  • 5
  • 28
  • 44
2
votes
2 answers

Why do I get quadratic time sorting using STL sort()?

I was trying to sort a vector of objects by values stored in a map, using the STL sort() function. To my great surprise, my algorithm was running in quadratic time. I simplified it as much as I could, trying to pinpoint an apparent bug, but to no…
1
vote
2 answers

How Can I Use ojAlgo To Solve Quadratic Programming (QP) in Java?

I have a quadratic programming problem (quadratic objective function with linear constraints, integer variables) that I want to solve in Java. ojAlgo seems capable of this. Unfortunately, I can't find documentation or examples for how to use it. Can…
Tom D
  • 175
  • 1
  • 4
  • 12
1
vote
5 answers

Simplify the radical in the quadratic formula?

I am fairly new to java and need help writing the code that will simplify the quadratic formula. Right now my program truncates the two solutions to two decimal places. But I do not know how to simplify the square of the discriminant. For example,…
1
vote
3 answers

Submit form to calculate quadratic equation

Am just learning html. I need to write code that solves the quadratic equation formula. I tried php code embeding in html but am getting blank output. How do I get user values a, b, c and display conditional answers?
Lu Moo
  • 11
  • 1
  • 2
1
vote
2 answers

Examples of apache math optimization

I have a simple optimization problem and am looking for java software for that. The Apache math optimization software looks just like what I want but I cant find documentation to suit my needs (where those needs are to useful to a beginner / non…
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
  • 4,631
  • 7
  • 30
  • 44
1
vote
1 answer

Imaginary numbers

I have a method that takes 3 doubles and calculates the roots via the Quadratic Formula: public static double[] quadraticFormula(double a, double b, double c) throws ArithmeticException { double root1 = 0; double root2 = 0; //sqrt(b^2 -…
Mohit Deshpande
  • 48,747
  • 74
  • 187
  • 247
1
vote
0 answers

Quadratic/parabolic interpolation

I have this curve (COVID-19 cases per 100,000 inhabitants in California between 2020-09-01 and 2021-03-01): It's clear that the dip at the end of December 2020 is an artifact of testing's having gone down during the winter holidays (the nadir…
dbcrow
  • 45
  • 4
1
vote
1 answer

slow quadratic constraint creation in Pyomo

trying to construct a large scale quadratic constraint in Pyomo as follows: import pyomo as pyo from pyomo.environ import * scale = 5000 pyo.n = Set(initialize=range(scale)) pyo.x = Var(pyo.n, bounds=(-1.0,1.0)) # Q is a n-by-n matrix in…
leo
  • 197
  • 8