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

Plot a quadratic relation for a predictor of a cox regression with R

I need to plot the relative risk for a quadratic effect in a cox regression. My model looks like this: cox_mod <- coxph(Surv(time, status) ~ ph.karno + pat.karno + meal.cal + meal.cal_q, data = lung) Where meal.cal_q is…
user9413061
0
votes
1 answer

My Quadratic equation code terminates when I enter a non integer value, how can I get it to loop properly?

So I'm trying to get my Quadratic equation solution code to loop unless "0" is entered as any 1 of the quadratic coefficients. It works fine up until entering a non integer value, in which the program terminates. I'd like the code to spit out a…
Nick Chr
  • 3
  • 3
0
votes
4 answers

React Quadratic Calculator

I'm new to React and I am trying to build a simple quadratic calculator web app. There are three inputs for each variable, a, b, and c. No matter what numbers I put in the values returned are always NaN. Help would be much appreciated. Code: import…
user9621725
0
votes
1 answer

Quadratic Function in C

I am trying to build a small quadratic calculator in C, but I am getting the following result no matter what my input is.... Here is my code: #include #include #include int main(void) { float a, b, c; printf("Enter…
slickset
  • 179
  • 13
0
votes
1 answer

Plot Quadratic Effects in multilevel model in R

I've calculated the following model: a.Pfad<-lmer(FlowZ~MTsqZ+(1|VP04_01), data=MT) with MTsqZ being a quadratic term. I am looking for a way to plot this model: I want to see if there is an inverted u-shaped relationship between the variables.…
Gina W.
  • 11
  • 2
0
votes
1 answer

Quadratic fitting for grouped data in R

although I've found plenty of help regarding fitting models in general, I keep running into a specific issue with my data because of the way it's organized. It's from an intro stats book and is supposed to represent sample data of errors as a…
0
votes
1 answer

Why the procedural code works for the solution of this code sequence but the function fails?

//Procedural Works!! $x=0; $e1=$x/450+1/2; $e2=$x==0?false:6300/$x; while($e1 !== $e2){ ++$x; $e1=$x/450+1/2; $e2=$x==0?false:6300/$x; if($e1 == $e2){ echo "x Solution: ". $x . "
y Solution: ".$e1; exit; } } //Function…
0
votes
2 answers

Quadratic Function with Complex Numbers

I'm writing a function in R that needs to solve the basic quadratic equation and gives you the roots. I need to print out imaginary numbers if applicable. Below is my code. Could anyone give me advice on how I could improve my coding? quad =…
J. Nav
  • 55
  • 2
  • 9
0
votes
2 answers

Performance issue with setting quadratic objective in CPLEX

I am solving a large sparse quadratic problem. My objective function has only quadratic terms and the coefficients of all terms are the same and equal to 1 and it includes all of the variables. I use objective.set_quadratic_coefficients function in…
Mirza
  • 31
  • 4
0
votes
1 answer

how to set a factor exposure constraint for quadratic programming using cvxopt.qp?

Trying to optimize a portfolio weight allocation here which minimize risk for a classic Markowitz portfolio. Let's say if I have a factor exposure constraint dataframe which denotes like In [138]: exp_sub = pd.DataFrame(data=[[-10, 20],[-10,…
Wei Wu
  • 1,023
  • 1
  • 9
  • 14
0
votes
0 answers

Length of a Segment of a cgPath using Swift for segments created with .addQuadCurveToPoint and .addCurveToPoint?

I'm placing items along a UIBezierPath. I would like to be able to specify how many points apart these items are. In other words, place an item every x points along the path. I found very nice clean code for something similar here:…
TheCodePig
  • 122
  • 10
0
votes
0 answers

One time vs Iteration Model in vowpal wabbit with --lrq option

I am using vowpal wabbit logistic regression with Low Rank Quadratic options (--lrq ) for CTR prediction.I have trained model with two scenario Model building in one time with command vw -d traning_data_all.vw --lrq ic2 --link logistic …
0
votes
1 answer

Quadratic equation solver in TI-BASIC returns incorrect roots

When I was in high school, I figured out how to program my TI-84 Plus calculator to do quadratic equations for me. Like the goody-two-shoes I was, I deleted the program before the final exam. I am trying to recreate the program now, but it's not…
Shokhet
  • 111
  • 5
0
votes
2 answers

Python quadratic formula not working

I am trying to create a simple program to sole for the roots of a quadratic equation in python, but my code is not working. Here is what I have so far: from math import * def qf(a, b, c): print((-b+sqrt(b*b-4*a*c))/(2*a)); …
Programah
  • 179
  • 1
  • 10
0
votes
0 answers

How to call Gurobi_c++.h in a S-function of matlab Simulink?

I tried to use the header "gurobi_c++.h" to make an optimization using Gurobi Solver in Matlab but all time I get the following error: fatal error: 'gurobi_c++.h' file not found #include "gurobi_c++.h" I notice I already install a C++ compiler and…
Nll
  • 819
  • 5
  • 19
  • 41