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

Math Domain Error Quadratic Formula

Figured out the errors except for this last one, Im now getting this error message, and can't figure out why, I'm using the exact formulas for x1 and x2 that my teacher gave us to use and i'm not able to figure the error out. # Quadratic…
0
votes
0 answers

Utilizing Quadratic Equation to Output Roots or Message saying Undefinable

Finding quadratic roots: import math def main(): print "Hello! This program finds the real solutions to a quadratic" print a, b, c = input("Please enter the coefficients (a, b, c): ") d = (b**2) - (4*a*c) # finding the…
0
votes
1 answer

Quadratic Formula returns NaN, even when negative radical is accounted for

This question is for my intro to Java class and the question is asking me to use classes to solve a quadratic equation. I am trying to fix my class so that it doesn't return NaN. I have used Math.abs() to try and fix any situation where the number…
eecenja
  • 15
  • 5
0
votes
2 answers

In my equation solving program, inputting nil value crashes app

I have made an app that solves quadratic equations (just to see if I could), however, I don't want the app to crash if the user accidentally inputs no value for one of the slots. Please help. @IBAction func solveButton(sender: AnyObject) { …
RufusV
  • 408
  • 3
  • 17
0
votes
3 answers

Write an overloaded operator+ function so that two instances of the quadratic class can be added together as in the following code:

Write an overloaded operator+ function so that two instances of the quadratic class can be added together as in the following code: quadratic y1 = quadratic (1.0, -5.0, 7.0); quadratic y2 = quadratic (-3.0, -2.0, 10.0); quadratic y3; double…
Zach Smith
  • 5,490
  • 26
  • 84
  • 139
0
votes
3 answers

Quadratic Equation Solver PHP

everyone. I am trying to make a Quadratic Equation Solver but nothing is working. It is giving me the wrong answer. I get x = - 2.5 and x = - 3.5 when the answer is -2 and -1 for this equation: x^2 + 3x + 2 Here is my code:
Kammy NGU
  • 11
  • 2
0
votes
1 answer

How do I get imaginary numbers without using cmath when calculating the quadratic equation?

I'm currently having trouble understanding how to make imaginary numbers appear when I'm doing the quadratic equation. My assignment is to make the quadratic equation, and get imaginary numbers but I'm having an extremely difficult time getting…
0
votes
2 answers

Implementing a Quadratic Algorithm

I'm reading a Introductory programming book by Robert Sedgewick and Kevin Wayne. In one of the examples they implement a quadratic class as follows: public class Quadratic { public static void main(String[] args) { double b =…
dcrearer
  • 1,972
  • 4
  • 24
  • 48
0
votes
2 answers

A simple quadratic equation solver

I wanted to create a simple quadratic equation solver but when I run it, it gets caught at the first if statement of each button. Any ideas? public class MainActivity extends AppCompatActivity { Button button1, button2; String a_temp; …
Giannis B
  • 3
  • 1
0
votes
1 answer

Matlab Quadratic equation

Struggling with a MATLAB quadratic equation. I keep getting a complex number as my answer and other errors keep occurring. Write a MATLAB function that solves a quadratic equation of the form a*x^2 + b*x + c = 0 The syntax of your function…
0
votes
1 answer

R quadratic programming

i have a problem that i'd like to solve in R. I see that i can use the function lsei in the package limSolve to minimise a system of linear equations written Ax=b in the matrix form, subject to equality constraints Ex=f and the inequality…
chrisjacques
  • 635
  • 1
  • 5
  • 17
0
votes
1 answer

How to plot a quadratic function in Matlab (with differently scaled axes)

I am trying to create a plot of a root function with 2 differently scaled axes, so let's say the x axis goes from 0 to 1.2 with steps of 0.1 and the y axis goes from 0 to 1.4 with steps of 0.2 (one function, 2 differently scaled axes). I think I got…
user3032689
  • 627
  • 1
  • 10
  • 23
0
votes
1 answer

Java. Quadratic formula program with variables a, b, and c read from file. Unexpected error

I'm making a program that reads from a file 3 numbers, doubles or integers, per line except the first one. The first line is the the number of lines after. The 3 numbers in each line are variables a, b, and c in the quadratic formula. Then the…
0
votes
2 answers

Print numbers with under square root symbol

I have to print the output of my solution(quadratic equation) in below format: Quadratic Equation Format I have the numeric values and can print the square root symbol using "Square Root: \u221A". However, I have no clue on how to insert numbers…
Saurav
  • 96
  • 1
  • 5
0
votes
2 answers

Creating Quadratic class containing four class methods - Java

My job is to create a quadratic class containing four class methods. One method being plusRoot() which returns the root when the quadratic formula uses plus sign (-b+squarerootof D) / 2a Another being minusRoot() which returns the root when the…
SethZiotic
  • 125
  • 2
  • 8