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

Is there a matlab built-in that calculates the quadratic form (x'*A*x)?

Pretty straightforward question: Given an N x N symmetric matrix A and an N-vector x, is there a built-in Matlab function to calculate x'*A*x? i.e., instead of y = x'*A*x, is there a function quadraticform s.t. y = quadraticform(A, x)? Obviously I…
dantswain
  • 5,427
  • 1
  • 29
  • 37
3
votes
1 answer

Simple Multiplication and Arithmetic in C

I have an assignment to compute the roots of quadratic equations in C, should be pretty simple and I know what I need to do with the program but I am having a problem nonetheless. It works fine when the roots are imaginary and when the term inside…
none
  • 263
  • 6
  • 13
3
votes
1 answer

Big O Understand Quadratic n(n+1)/2 diagram

Reading DS & Algorithms on Quadratic n(n+1)/2. There are 2 diagrams here Figure 4.1a & 4.1b. I understand 4.1a diagram but not diagram 4.1b. I know Figure 4.1b is n/2 (x-axis) multiple (n+1) (y-axis). I don't understand the jaggeet line shown in…
yapkm01
  • 3,590
  • 7
  • 37
  • 62
3
votes
0 answers

Is it possible to get decision boundary equation for Quadratic Discriminant Analysis?

I use Python and sklearn packages. I used LDA for predictions and I can get the coefficients of the decision boundary. clf = LinearDiscriminantAnalysis(priors=[prob_norm, prob_anem]) clf.fit(X_train, y_train) y_predict =…
Arzental
  • 103
  • 6
3
votes
3 answers

Nearest point on a quadratic bezier curve

I am having some issues calculating the nearest point on a quadratic curve to the mouse position. I have tried a handful of APIs, but have not had any luck finding a function for this that works. I have found an implementation that works for 5th…
matt
  • 33
  • 1
  • 3
3
votes
3 answers

Convert a quadratic curve points to polynomial representation?

I have the X,Y of 2 end points and 1 bezier point, of a Quadratic Bezier curve. Using this data, how can I derive the polynomial representation of the curve? (source: euclidraw.com)
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
3
votes
2 answers

Operator Overloading with Tuples in Swift

Operator Overloading Swift 4.1, Xcode 9.3 I am trying to make a quadratic equation function in Swift. While working on this, I found that I needed to overload some operators so that I could work with tuples alongside other numbers (Double in this…
Noah Wilder
  • 1,656
  • 20
  • 38
3
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…
3
votes
2 answers

Fast Method to Intersect two Integer Quadratic Beziers?

Given two Quadratic Beziers in 2D with integer coordinates, what is the best way to find their intersection point(s)? Also interesting is an early rejection if they do not intersect. If it makes it easier, they can both be assumed to be monotone in…
starmole
  • 984
  • 7
  • 6
3
votes
1 answer

What is the best time complexity possible to find a solution to x^2 + y^2 = m where m can be any natural number?

I have to find a solution to the equation x2 + y2 = m where m can be any natural number and x,y are integers. This can be done in O(m1/2) by using brute force easily. Is there a way I can do this in constant time?
Sujay_K
  • 155
  • 1
  • 2
  • 10
3
votes
1 answer

Quadractic Formula mix up

So I made a python code that solves for x using the quadratic formula. Everything works out in the end except for the signs. For instance, if you want to factor x^2 + 10x + 25, my code outputs -5, -5 when the answer should be 5, 5. def…
Gabbi
  • 33
  • 2
3
votes
1 answer

How to compute the intersection between a quadratic bezier curve and a horizontal line?

What I am trying to do get the X coordinates at which a certain bezier curve crosses a horizontal line (a y coordinate). For the moment, I have this code: function self.getX(y) if y > maxY or y < minY then return end local a = y1…
Creator
  • 151
  • 1
  • 9
3
votes
1 answer

NaN error in quadratic formula calculator java

I am working on a function for the quadratic formula in java eclipse mars, and when I compile the code it outputs NaN when mathematically this answer is possible and i should get 2.0 please help import java.util.Scanner; public class Quadradic1 { …
3
votes
1 answer

Quadratic equation solver in php

I tried to make a quadratic equation solver in php: index.html:
Find solution for ax^2 + bx + c
a:
b:
Kys Plox
  • 774
  • 2
  • 10
  • 23
3
votes
1 answer

Constraining norms with inequalities

I have time-series data for N stocks. sample.data<-replicate(10,rnorm(1000)), where each column shows the returns of different stocks over time. I am trying to construct a portfolio weight vector to minimize the variance of the returns. the…
upabove
  • 1,057
  • 3
  • 18
  • 29
1 2
3
27 28