0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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$? $\endgroup$ – Dr. Sonnhard Graubner Jan 26 '18 at 15:00
  • $\begingroup$ Is the underlying problem that you want to generate random quadratic with roots in $[-5,5]$? If so why do you need this inequality? $\endgroup$ – Winther Jan 26 '18 at 15:03
  • $\begingroup$ 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)$ $\endgroup$ – Winther Jan 26 '18 at 15:14
  • $\begingroup$ Thank you for clarifying. Yes I wanted to generate roots in [−5,5] but approached the problem in the wrong way. $\endgroup$ – Kin Jan 26 '18 at 15:18
  • $\begingroup$ Do you mean $0=\dots$ rather than $y=\dots$? $\endgroup$ – Thomas Andrews Jan 26 '18 at 15:22
1
$\begingroup$

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$?

$\endgroup$
  • $\begingroup$ Thanks this is a much better way to approach the problem. $\endgroup$ – Kin Jan 26 '18 at 15:15
0
$\begingroup$

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$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.