For which values of $a\in\mathbb{R} $ the equation $2 \log(x+3)=\log(ax)$ has exactly one root? I have to investigate the possible roots of the equation according to $a$, i.e. i have to see whether there is only one root, two roots, or no roots and also what their sign is each time. This is from a book i'm reading and the answer it gives is $a<0$ or $a=12$.
Now first we have to to make the restriction that $x>-3$ due to logarithm. What is troubling me is the $a<0$ part.
In the solution it says that after getting rid of the logarithms we have $x^2-(a-6)x+9$. Now if $a<0 \land x>0$, then $\log(ax)$ is undefined so the equation has no solution. But we're asked about $a$, not $x$. So it proceeds to say that if $a<0 \land x<0$, i.e. $-3<x<0$ (due to our restriction) then:

Let $f(x)=x^2-(a-6)x+9$, so $f(-3)=3a<0$. [The following is primarily what i don't understand.] This means that $-3$ will be between the two roots $x_1$ and $x_2$, so $x_1<-3<x_2<0$, but since we have the constriction $-3<x<0$ then $x_1$ is not possible so $x_2$ is one and only root of the original equation. Thus for $a<0$ there is exactly one root.

How could they even do that, plug $-3$ for $f(x)$ to test the roots of the equation, since for $x=-3$ the equation is not defined. Also what i'm not sure i understand is why it says that since $f(-3)<0$ then $x_1<-3<x_2$. I would like to understand that. Help please. Thanks in advance.
 A: The case we're considering here is the one where exactly one of the two roots of the quadratic $f$ is to the right of $-3$. That is the same as saying that $x=-3$ lies between the two roots of $f$. And from our general knowledge of how quadratics behaves, since the $x^2$ coefficient of $f$ is positive, the points between the two roots are exactly the ones where $f(x)<0$. Thus $-3$ is such a point (implying that the logarithmic equation will have exactly one solution) if and only if $f(-3)<0$.
Note that $f(x)$ is just a quadratic polynomial -- when we're investigating the shape and position of the parabola, it makes perfect sense to evaluate it at any $x$, even though the original logarithmic equation that led you to consider that polynomial is only defined for some values.
A: For the functions to be defined we must have $x >-3$ and $ax>0$
Now take Case 1: a>0. Then $x>0$ and $x >-3$ So, in conclusion $x>0$.
So, $(x+3)^2 =ax$ should have exactly one positive root (since x>0)
But $x^2+x(6-a) +9=0$ has either two positive roots or two negative roots or non-real roots ( as product of roots is positive =9).
So, the only option is two equal positive roots which give $a=12$ (using discriminant. 
Case 2: a< 0. Now we must have $x >-3$ and $x<0$. 
So,  $f(x)=x^2+x(6-a) +9=0$ must have exactly one root between $(-3, 0)$.
So, $f(-3)f(0) <0$ which is equivalent to $a < 0$.
So, $a<0$ or $a=12$
A: Reducing $2\log(x+3)=\log(ax)$ to
$$
(x+3)^2=ax
$$
should be done with some care. This equation should either have a single solution (zero discriminant), or just one solution satisfying $x+3>0$ and $ax>0$.
First we can dismiss the easy case: the discriminant of $x^2+(6-a)x+9=0$ is $(6-a)^2-36=a^2-12a$. This is zero for $a=12$ or $a=0$, but this last value is not acceptable. The double root when $a=12$ is $x=3$ that satisfies the conditions $x+3>0$ and $12x>0$.
For the harder case, we first have to ensure the discriminant is positive, so either $a<0$ or $a>12$.
For $a>12$ the roots are both positive, so they both satisfy $x+3>0$ and $ax>0$. Thus this is not part of our solution.
For $a<0$ we have $6-a>0$ so both roots are negative and we need to ensure just one of them is in the interval $(-3,0)$.
Let $f(x)=x^2+(6-a)x+9$; then $f(-3)=3a<0$ and $f(0)=9>0$; the graph of $f$ is a parabola which is decreasing in the interval $(-\infty,(6-a)/2)$ and increasing in the interval $((6-a)/2,\infty)$. Since $(6-a)/2>0$, we see that just one root is in the interval $(-3,0)$, as required.
