0

Background info: I am trying to randomly generate quadratics on a graph with roots between -5 and 5. $$ 0=ax^2+bx+c \Rightarrow x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}$$

If I keep "a" constant at 1 for simplicity then I end up with: $b-10\le \pm \sqrt{b^2 -4c} \le b+10 $

I thought I could square everything to continue rearranging the inequality but that doesn't appear to work. I end up with $$ -25-5b\le c \le -25+5b $$

Playing around with a quadratic plotter https://www.desmos.com/calculator/pfdwlq5qht

$$ y=x^2+5x-6$$ satisfies this inequality but does not have roots between -5 and 5.

I think my error is related to Should the sign be reversed if I square both sides of an inequality? but I am unsure how to proceed. Any help would be appreciated. Thanks in advance.

Kin
  • 15
  • 4
  • do you want to solve $$b-10\le \sqrt{b^2-4c}\le b+10$$ or $$b-10\le -\sqrt{b^2-4c}\le b+10$$ for $c$? – Dr. Sonnhard Graubner Jan 26 '18 at 15:00
  • Is the underlying problem that you want to generate random quadratic with roots in $[-5,5]$? If so why do you need this inequality? – Winther Jan 26 '18 at 15:03
  • Addressing the inequality problem: note that it has to be satisfied for both signs $\pm$. Write out both of these inequalities and combine them (the one with $-$ has to be multiplied with $-1$ for which $\leq \to \geq$) to get $\max(b-10,-b-10)\leq \sqrt{b^2 - 4c} \leq \min(b+10,10-b)$ where I have used $A \leq X \leq B$ and $C \leq X \leq D$ implies $\max(A,C) \leq X \leq \min(B,D)$ – Winther Jan 26 '18 at 15:14
  • Thank you for clarifying. Yes I wanted to generate roots in [−5,5] but approached the problem in the wrong way. – Kin Jan 26 '18 at 15:18
  • Do you mean $0=\dots$ rather than $y=\dots$? – Thomas Andrews Jan 26 '18 at 15:22
  • Yes I do, edited for clarity. – Kin Jan 26 '18 at 15:25

2 Answers2

2

Why not choose the roots $r$ and $s$ randomly in that interval and then return the quadratic $(x - r)(x - s) = x^2 - (r+s)x + rs$?

Ethan Bolker
  • 95,224
  • 7
  • 108
  • 199
0

A quadratic with roots between $-5$ and $5$ is just $(x-a)(x-b)=x^2-(a+b)x+ab$ with $(a,b)\in[-5,5]^2$.

zwim
  • 28,563