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

Sort algorithm for "weak order"?

I have unordered elements in a vector. There's no transitivity; if element A > B and B > C, A > C doesn't need to be true. I need to sort them so that an element is greater than its following one. For example, if we have three elements A, B and C,…
user2208447
  • 131
  • 2
  • 9
0
votes
1 answer

Drawing a quadratic function in mixed effect model

It's a bit of a long question so thanks for bearing with me. Here's my data https://www.dropbox.com/s/jo22d68a8vxwg63/data.csv?dl=0 I constructed a mixed effect model library(lme4) mod <- lmer(sqrt(y) ~ x1 + I(x1^2) + x2 + I(x2^2) + x3 + I(x3^2) +…
user53020
  • 889
  • 2
  • 10
  • 33
0
votes
1 answer

plotting a quadratic function in R

Here's how I plotted a quadratic curve: factor <- 1:7 data <- c(0.1375000,0.2500000,0.3416667,0.4583333,0.7250000,0.9166667,1.0000000) plot(factor, fitted(lm(data~factor+I(factor^2))), type="l") I try to do the same with my another data.…
user53020
  • 889
  • 2
  • 10
  • 33
0
votes
1 answer

Extract coefficients from binomial expression entered as a string in Scala

I am trying to write a program that can find the roots of a quadratic equation using Scala. The input should be a quadratic equation in the form ax^2+bx+c (e.g: 5x^2+2x+3) as a string. I managed to code the calculation of the roots but am having…
0
votes
1 answer

Is it possible to include previous solutions from a quadprog solver into the constraints for subsequent solution values?

I have a question concerning the quadprog solver. I have set up an optimisation problem with 96 values to be optimised and 4 constraints which is working fine. Now I would like to do a somewhat more sophisticated optimisation. The values which are…
T. Wolf
  • 111
  • 1
  • 6
0
votes
1 answer

Python math domain error

I am making a program that solves the quadratic equation and prints the roots. Before I get to the main program, I am just trying to make the square root work. The error I am getting says "math domain error". If someone could give me some help as to…
0
votes
1 answer

Quadratic Primes

I'm asking about Project Euler problem 27 (https://projecteuler.net/problem=27). I have written a piece of code that either doesn't work, or doesn't work fast enough - I'm new to programming and don't fully understand the meaning of the error I'm…
user11128
  • 295
  • 1
  • 2
  • 12
0
votes
2 answers

Program not outputting to file? C++

? I'm stuck on an where we are required to create a quadratic formula program using function headers and pass by value numbers and references. Everything seems to be right with the calculations but it's not outputting anything to the output file I…
0
votes
3 answers

Genetic algorithm to solve a quadratic equation

I have a problem understanding the process for genetic algorithms. I found examples of maximizing a function over an interval, and I think I understand them, but how can a genetic algorithm be used to solve, for example, a quadratic…
Farzad
  • 1,770
  • 4
  • 26
  • 48
0
votes
1 answer

I am making a Quadratic Form Calculator, accepting a, b, and c where a isn't equal to 0

This is not complete, I know i must use if / else statements to return an error if a isn't equal to zero, but right now I'm just trying to get my formula to work. I am supposed to define the discriminant and quadratic formula. When I have the…
Addison
  • 403
  • 8
  • 24
0
votes
1 answer

ASP.NET quadratic calculation returning NaN erroneously

My ASP.NET MVC web application is supposed to calculate the roots of a second-degree polynomial (quadratic) but I'm erroneously getting Nan responses. I believe this is due to my improper setup, so let me post some of my code here: View: <%@ Page…
Qcom
  • 18,263
  • 29
  • 87
  • 113
0
votes
4 answers

How to optimise my C code to solve quadratic equations in R?

I just wanna know how I can optimize my C code. My program works fine, I tested it with many different values, all is good. However, I'd like to reduce the number of lines and write my program in better quality. Here's the source code: #include…
0
votes
0 answers

Hardness of quadratic programming (QP) with linear constrains vs. quadratic constrains

Wikipedia: Quadratic programming says that a positive definite quadratic programming (QP) with linear constraints can be solved in polynomial time: “For positive definite Q, the ellipsoid method solves the problem in polynomial time.[6]” On the…
Behrang
  • 13
  • 5
0
votes
2 answers

Need Help for Quadratic formula on python

I just started learning Python in school, here is my code for the quadratic formula solver. Problem is on line 4. a=int(input('a= ')) # A-stvis mnishvnelobis micema b=int(input('b= ')) # B-stvis mnishvnelobis micema c=int(input('c= ')) # C-stvis…
0
votes
1 answer

Quadratic Formula on Java semi-colon error

I wrote code for finding the roots of a quadratic formula in Java. However, I get the error that I'm missing a semi-colon in line 6, even though I have one there. What's going on? public class Lab2{ public static void main (String[] args){ …
bob
  • 21
  • 1