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.

380 questions
-2
votes
2 answers

Solving circle equations

I'm looking for some assistance with solving the below equations in Java (a-x1)^2 + (b-y1)^2 = r1^2 + r^2 (a-x2)^2 + (b-y2)^2 = r2^2 + r^2 (a-x3)^2 + (b-y3)^2 = r3^2 + r^2 Values of x1, y1, r1, x2, y2, r2 & x3, y3, r3 are known. I need to solve for…
Pavan Kulkarni
  • 456
  • 3
  • 15
-2
votes
1 answer

How to program a quadratic calculator?

Here is the code for my quadratic calculator: puts "A?" a = gets.to_f puts "B?" b = gets.to_f puts "C?" c = gets.to_f d = (-b + (((b**2) - (4*a*c))**(1/2)))/(2*a) puts d f = (-b - (((b**2) - (4*a*c))**(1/2)))/(2*a) puts f However, the answers are…
-3
votes
2 answers

C++ Quadratic equation outputs: -1.#IND

My code works fine with: (1, -2, -8), It gives me the error above when I input a=1 b=0 c=1, Here is my code: double x=0,a=0,b=0,c=0,d=0; complexType solu1; complexType solu2; cout << "\n\nEnter values of quadratic a,b,c:"; cin…
Nick
  • 8,824
  • 32
  • 98
  • 143
-3
votes
1 answer

How can I find the optimal solution of quadratic function

How can I minimize or maximize a quadratic function? what is the algorithm for that? Thanks!
AdyM
  • 13
  • 3
-3
votes
1 answer

Why do I keep getting a ValueError: math domain error in Python?

So I was making a quadradic equation solver in Python and when the calculation was happening, an error came up and I'm not sure what is happening. from math import sqrt a = float(input("a: ")) b = float(input("b: ")) c = float(input("c: ")) Z = (b…
Aidan
  • 23
  • 3
-3
votes
2 answers

Java program to find integer root of a quadratic equation

So, here is my requirement. If a quadratic equation has two roots(an int & a float), I want to take only integer value for further manipulation. I can't figure it out how it's made. Can anyone tell me please. (Java would be better).
-3
votes
2 answers

Quadratic equation program is not giving values

Could you tell me what's wrong with my code for solving a quadratic equation? Don't be cringed out by my work, because I'm still very new to the program. class Program { static void Main(string[] args) { double a, b, c, x1, x2, x,…
-3
votes
1 answer

Using python in math

Ok so i want to solve this equation through python but cant figure out what to do! I tried using for loops but that didn't work so well Im new to python so can anyone suggest what I should do RWBG-(WBR^2)-WBR-(BR^3)-(3BR^2)+2BR-(R^3)-(6R^2)+11R-6 =…
-3
votes
2 answers

pq method math to the function of a*x*x+b*x+c=0

Question : I thought the source code is right and it worked well a lot of times for example at functions like : x^2 + 4x +4 or 3x^2 +5x+1 but in some functions the output is NaN and i don't understand why (function that outputs NaN : 4x^2 - 2x +8…
burakburi
  • 23
  • 7
-3
votes
3 answers

Why does it show Nan when i run this?

This code is to solve a quadric equation in Java. It output puts Nan. What is the wrong and how can I resolve this? I tried a=1, b=2, c=10. import java.util.*; class equation { public static void main(String args[]) { int a, b, c; String…
Nimantha
  • 147
  • 4
-3
votes
1 answer

How can I change this if-statement to switch?

//is the following code about quadratic formulas convertible to switch method? Public class blah blah Public static void main(String[] args) { System.out.println("enter letter a"); New Scanner= System.in Int a = input.nextint() //same…
-3
votes
2 answers

Quadratic equation with complex roots

I am just learning visual basic and have been trying to write a code to solve quadratic equations with complex number as roots. Any pointer in the right direction would be appreciated. Public Class Form1 Dim a, b, c As Integer Dim x1, x2 As…
High Zedd
  • 67
  • 10
-3
votes
1 answer

c++ quadratic equation code output error

Ok, so i am creating a quadratic equation solver in c++ and cant seem to get the right output on imaginary numbers. the real number roots come out fine (e.g. x= 2 and x = 5) but when the imaginary numbers come out, something weird happens where it…
-3
votes
3 answers

TypeError: 'int' object is not callable: Quadratic

(Finding the values of x in a quadratic equation w/o importing.) Whenever I run the program, Python stops at discriminant = (b ** 2) - 4(a * c) and shows TypeError: 'int' object is not callable. What's…
-3
votes
3 answers

using math class in java

I'm trying to calculate the power of a double to calculate the Quadratic Formula Here is the code: private Scanner sc; double a, b, c; // Input Coefficients public void InputCoeff() { sc = new Scanner(System.in); System.out.println("Please…
1 2 3
25
26