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

quadratic equation program output numbers

apologies for the wall of text. I have been given the following task from the book I am working from: "Quadratic equations are of the form: a x^2 + b x + c = 0 To solve these, one uses the quadratic formula: (-b±√(b^2-4ac))/2a There is a problem,…
0
votes
1 answer

How to multiply constraint variables in a IBM CPLEX MILP file?

Using IBM CPLEX, I'm struggling to run a MILP file, on the constraints I would like to add the following line: Subject to a_1 P_1 + 22.62 b_2 + a_2 P_2 + 24.87 b_2 - P_3 + A = 0 For this case CPLEX runs, but in some cases some variables are "glued"…
0
votes
1 answer

Quadratic equation solver nan square root positive number

I was coding a very simple quadratic eqation solver but the answer kept coming up nan even when the square root was positive (the example I was using was 1x^2+5x+6 where b^2=25 and 4*a*c= 24) but it was still coming up nan. Please help. import…
Ggu
  • 17
  • 3
0
votes
1 answer

How to program the quadratic formula (without simplifying the roots) on a ti83 plus?

First of all, I apologize if this isn't the correct website to ask this question on. I know how to program the basic formula, but is it possible to program the formula to not simplify the roots? (so as to avoid irrational numbers)
0
votes
1 answer

Fast quadratic minimizer

Given a quadratic function, that is f(x) = ax^2 + bx + c, what is the fastest way to find x in [-1, 1] which minimizes f(x)? So far this is the function I've come up with: double QuadraticMinimizer(double a, double b, double c) { double x =…
user92382
  • 369
  • 3
  • 12
0
votes
1 answer

Solving quadratic congruence

I want to solve this equation x^2= 4 mod 3 in R, I tried many commands but that commands are not related to this equation. Please help me to find the command. For example, I tried modlin(2,4,3) # [1] 2 modpower(2,4,3) # [1] 1 and five other…
0
votes
1 answer

quadraticCurveTo: Can I determine what the vertex will be?

I'm using the quadraticCurveTo function in the HTML5 canvas. My main quip with it is it uses line interpolation when I just want to dictate the vertex. I already know what my starting and ending point is. As far as I know there is no function that…
Cool Guy
  • 21
  • 1
0
votes
2 answers

Quadratic Formula With User Input (Java)

I'm a complete newbie at coding and I'm not really sure how to word this question 100%. I'm trying to figure out why my program is only storing the first input for value 'a' even if that number is a negative. For example: a= -1 (Value must be…
Onoinato
  • 1
  • 1
0
votes
1 answer

What is wrong with my code for quadratic formula

public class QuadraticEqn { private double a, b, c; public QuadraticEqn(double x, double y, double z){ a=x; b=y; c=z; } private double disc = b*b-4*a*c; public boolean hasSolutions(){ if(disc>=0) return true; else …
Miss Desi
  • 5
  • 1
0
votes
1 answer

Calculating a concentric arc in canvas

I'm trying to calculate a 2 concentric arcs (cubic bezier) from a given arc (quadratic bezier). I figured I could calculate control points for the cubic at 1/3 and 2/3 but it doesn't quite match up. var u = 1 / 3; // fraction of curve where Px1…
dreed75
  • 115
  • 1
  • 9
0
votes
2 answers

Quadratic Equations factor computation

Regarding quadratic equations (learn more here), I've taken the a, b, and c of the equation as input. A sample equation will be this: 21x^2 - 8x - 4 Here, a = 21, b = -8, c = -4. So, on solving (without formula), => 21x^2 - 14x + 6x - 4 =…
Mission Coding
  • 301
  • 4
  • 12
0
votes
1 answer

Java: Calling variables of user input from one method to another

I'm currently modifying a previous Java program that computes quadratic formula type math problems by breaking parts of my code down into methods and calling those methods to complete the same task. Currently I'm stuck on creating a method to…
B_Ran
  • 13
  • 1
  • 5
0
votes
2 answers

The most efficient method of drawing multiple quads in OpenGL

I've been producing this 2d tile-based game engine to be used in several projects. I have a class called "ScreenObject" which is mainly composed of a Dictionary The Point key is to show where to render the Tile on the screen, and the…
CPatton
  • 63
  • 1
  • 7
0
votes
1 answer

NaN Error w/ Quadratic Equation Calculator

Having trouble trying to get this code working! Please help! package com.mtndewey.calculator; import java.util.Scanner; public class Calculator { private static double inputA, inputB, inputC; public static void main(String[] args) { final…
Jon Dewey
  • 25
  • 6
0
votes
0 answers

Quadratic form in R

This is probably straightforward, elementary and whatever, but I can't manage to get it. I have 2 Nx1vectors u and w, which are composed by both negative and positive values. I am trying to compute w'u u'w , which should be a quadratic form. I…
Bob
  • 452
  • 6
  • 18