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
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
  • 99,791
  • 133
  • 372
  • 575
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,369
  • 14
  • 31
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
  • 904
  • 7
  • 6
3
votes
0 answers

How to get quadratic term in simple lm regression formula?

I want to run an OLS regression of this type: lm(S.Educ ~ i.Educ.A + i.Educ.A^2, tsdata) But the coefficient of i.Educ.A^2 does not shows up. How can I run this regression?
Linkman
  • 927
  • 8
  • 14
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
  • 135
  • 2
  • 10
3
votes
2 answers

C# application solving for quadratic imaginary roots

I have constructed an extremely simple, yet fully-functioning and quite helpful, WinForms C# application that solves for the real roots of a quadratic equation. Here is my current programming logic: string noDivideByZero = "Enter an a value that…
Qcom
  • 16,009
  • 27
  • 82
  • 112
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
  • 161
  • 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

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
  • 925
  • 2
  • 14
  • 28
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,890
  • 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
  • 5
3
votes
2 answers

R Error : some group is too small for 'qda'

I used the qda{MASS} to find the classfier for my data and it always reported "some group is too small for 'qda'". Is it due to the size of test data I used for model ? I increased the test sample size from 30 to 100, it reported the same error.…
user2993059
  • 55
  • 1
  • 1
  • 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,188
  • 5
  • 50
  • 83
1 2
3
25 26