Algebraic process to find numbers so that $xy=45$ and $x+y=18$ Can someone help me with the following question?
The sum of two numbers is $18$ and their product is $45$. Find the numbers.
I know that the answer is $15$ and $3$. But how do I find that answer algebraically?
It tried doing it as $x+y=18$ and $xy=45$ and then $x= 18-y$ and I substituted in $xy=45$. I got it as $(18-y)y =45$, and I don't know what to do next.
 A: A nice method for this type of problem is to note that since the two numbers add to $18$, they may be expressed as $9-a$ and $9+a$.  Then the product being $45$ gives
$$(9-a)(9+a)=45$$
$$81-a^2=45$$
$$a^2=36$$
$$a=\pm 6$$
The two values of $a$ give $x$ and $y$ as $9-6$ and $9+6$; or as $9-(-6)$ and $9+(-6)$.  That is, $3$ and $15$ in either case.
A: While one can rotely apply the quadratic formula, their is a simpler way. Let the roots be  $\, r,s.\,$ $\,(x\!-\!r)(x\!-\!s) = x^2\!-(r\!+\!s)x+rs = x^2\!-18x+45,\,$ so $\,r,s\,$ are integers by the Rational Root Test. But there are few integer factorizations $\,45 = rs.\,$ One quickly finds the one with $\,r\!+\!s = 18\,$ 
Optimizing further: $\,3\,$ divides the root sum,  $\,3^2$ divides root product $\,\Rightarrow 3\,$ divides both roots, because $\, X^2 - 18 X + 45 = 9(x^2 - 6 x + 5),\ X = 3x,\,$ so we reduce to root sum $ = 6,\,$ product $= 5,\,$ which is easy to solve, since $\,5\,$ has only two factorizations $\, 5\cdot 1\,$ and $\ {-}5(-1).\,$
Remark $\ $ We factored the polynomial by exploiting the fact that its constant term (= value at $\,0)$ had few factorizations. This works much more generally, namely
Key Idea $\ $ The possible factorizations of a polynomial $\in\Bbb Z[x]$ are constrained by the factorizations of the integer values that the polynomial takes. For a simple example, if some integer value has few factorizations (e.g. a unit $\,\pm1 $ or prime $p$) then the polynomial must also have few factors, asssuming that that the factors are distinct at the evaluation point. More precisely
If $\, f(x) = f_1(x)\cdots f_k(x)\,$ and $\,f_i\in\Bbb Z[x]\,$ satisfy $\color{#0a0}{f_i(n) \ne f_j(n)}\,$ for $\,i\ne j,$ all $\,n\in \Bbb Z$
$\quad \color{}{f(n) =\pm1}\,\Rightarrow\, k\le 2\ $ else $1$ would have $\rm\,3\,\ \color{#0a0}{distinct}$ factors $\,f_1(n),f_2(n),f_3(n)$  
$\quad f(n) = \pm p\,\Rightarrow\, k\le \color{#c0f}4\ $ since a prime $p$ has at most $\,\color{#c0f}4\,$ distinct factors $\,\pm1,\pm p$
You can find specific applications of these ideas in some prior posts here.
Remark $\ $ One can push the key idea to the hilt to obtain a simple algorithm  for polynomial factorization using factorization of its integer values and Lagrange interpolation. The ideas behind this algorithm are due in part to Bernoulli, Schubert, Kronecker. See this answer for references.
A: As Travis says, you can use the quadratic formula:
$$18y - y^2 = 45$$
$$y^2 - 18y + 45 = 0$$
$$y = 9 \pm \sqrt{9^2-45} = 9 \pm 6$$
A: So, suppose the two numbers we seek are $r_1$ and $r_2$. Then, expanding the polynomial $(x - r_1)(x - r_2)$ gives
$(x - r_1)(x - r_2) = x^2 - (r_1 + r_2) x + (r_1 r_2)$,
or in other words, $r_1$ and $r_2$ are roots of the polynomial
$x^2 - S x + P$,
where S is their sum and P is their product.
Turning this around says that we're given any sum $S$ and product $P$, we can form this polynomial, and the numbers we seek are exactly its roots. In our case, we were given $S = 18$, $P = 45$, so the polynomial is
$x^2 - 18x + 45x = (x - 3)(x - 15)$,
the roots of which are $3$ and $15$ as desired.
Remark Of course, quadratic polynomials only sometimes have real roots; in the likely event we want to avoid producing polynomials with complex roots, we have to restrict ourselves to the case where the discriminant $S^2 - 4P$ is positive, that is, to the case where $S^2 > 4 P$.
A: $p+q=18 \\
\text{& } pq=45$
So,
$p=\large\frac{45}q$
$\frac{45}q+q=18$
$q^2+45-18q=0$
$q^2-15q-3q+45=0$
$q(q-15)-3(q-15)=0$
$(q-3)(q-15)=0$
Or, q is either 3 or 15. 
That makes p either 15 or 3.
