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
0
votes
0 answers

How can I plot a linear and quadratic predictors from a regression model, while also controlling for other variables?

Here is some data and a model. It consists of a linear and quadratic predictor (a and a2) and a linear control variable (b). library(data.table) library(ggplot2) d <- as.data.table(cbind(a = rnorm(50), b = rnorm(50), y = rnorm(50))) d$a2 <-…
Dave
  • 232
  • 1
  • 2
  • 14
0
votes
2 answers

Clojure quadratic formula

(ns quadratic_roots) ;name the program (defn quadraticRoots[a b c] (/ (+ (- 0 b) (Math/sqrt (- (Math/expt b 2) (* 4 a c)))) (* 2 a)) (/ (- (- 0 b) (Math/sqrt (- (Math/expt b 2) (* 4 a c)))) (* 2 a))) ) This is only the first part of the…
hkira1
  • 51
  • 5
0
votes
2 answers

How to interpret coefficients returned from `LinearRegression().coef_` when using polynomial regression

I have a training set of data x_train with 6 features/variables and with target y_train. These are stored in pandas dataframes. I have done Linear Regression on this to get a model of the form y = b + m_1*x_1 + m_2*x_2 + ... + m_6*x_6. When I print…
John Doe
  • 189
  • 2
  • 9
0
votes
1 answer

Quadratic formula solver does not give the correct result

This quadratic formula solver is not working. I am not able to find out why. Here is the code (python): def binomio(a,b,c): return (b**2)-(4*a*c) def raiz1(a,b,c): bn = binomio(a,b,c) x = ((-b+(bn **…
0
votes
1 answer

Simulate Data (X,Y) that are Quadratically Related to one another

I'm looking to simulate a dataset with two variables (X,Y) where the relation between these variables is quadratic (some version of an inverted U). Is there a way to do this in R? Understandably, the exact shape of the relationship can differ, as…
Drew
  • 135
  • 4
  • 11
0
votes
0 answers

Solve and minimize quadratic system of inequations with multiple objectives

I have a set of inequalities that I have to solve. These inequalities are related to circle packing, where I have N circles and all of them are interrelated between the rest of the circles. Which functions could I use to solve this? I have tried…
0
votes
1 answer

Changing to values in my program to arrays

This is a question for school, I need to write a method to find real roots. My program currently works but now I need to return the two roots as arrays, and generalize it so when a is equals to 0 the method should return an array holding one…
user10376245
0
votes
1 answer

programming Quadratic equation using functions on fortran 95

I am trying to create a program that uses the quadratic formula. However, I want to do it entirely with external functions on fortran 95. My program keeps giving me weird errors regarding "inconsistent types" and etc. This is what I have so far. If…
sharpphoton
  • 1
  • 1
  • 1
0
votes
1 answer

Using JavaScript. Need to find the Vertex and Axis of Symmetry

Creating a code using JS that can solve and graph quadratics. The parts I'm having an issue with would be finding and reducing axis of symmetry and vertex. I've attempted to do the Axis of Symm but it does not work. The html code is for the box i…
0
votes
1 answer

Simplify Quadratic Vertex Form Equation to Standard Form

I wanted to make a function to get a quadratic equation given the vertex and a point. I got all of this right until, I was using sympy to simplify the expression because that's how it gets to standard form, but it gave me an error. Here is my…
Michael D
  • 1
  • 1
  • 4
0
votes
1 answer

Gurobi solver in matlab

I want to use Gurobi solver in Matlab, but I don't know how to calculate the required matrices (qrow and qcol). For your reference I am copying the example provided in documentation. 0.5 x^2 - xy + y^2 - 2x - 6y subject to x + y <= 2 -x + 2y <= 2,…
0
votes
1 answer

How to plot raw data but use predicted values for line fit in ggplot2 R?

I have a data set (dat), with raw data (raw_x and raw_y). I have predicted a model and the predictions from the model are stored in dat$predict. I wish to plot the raw data but overlay the data with a geom_smooth (here a quadratic function) but…
user8435999
0
votes
0 answers

quadratic equality constraint: Julia+Jump+Gurobi

i'm a newbie to julia and struggling how to handle quadratic equality constraints when using gurobi as the main solver. Can u may take a quick look at the following listing? I alread know that such structures are impossible to solve by using gurobi,…
PTueller
  • 31
  • 2
  • 7
0
votes
1 answer

Quadratic formula with GUI just returns NaN

I was trying to make a program which can do the quadratic formula. I've also done this as a console program and it worked but now I want do do it with a GUI. Now my problem is, that it just shows NaN. I've copied the formula from the working console…
sin-an
  • 33
  • 1
  • 1
  • 5
0
votes
1 answer

Solve quadratic equations without individually specifying cofficients

I am trying to solve equations like: 3*(3x-12)/(x+3)-2*(2x+3)/(3x-1) = 5 This is the code that I use: eqn1 = 3*(3*X-12)/(X+3)-2*(2*X+3)/(3*X-1) == 5; sol = solve(eqn1, X); xSol = sol.X This is the error that I get: Error using sym/subsref Too many…