I want to factorize any quadratic expressions into two complex-valued linear expressions.
My effort below
a := 1;(*needed*)
p := 2;(*needed*)
q := 3;(*needed*)
f[x_] := a (x - p)^2 + q;(*needed*)
AA := Coefficient[f[x], x^2];
BB := Coefficient[f[x], x];
CC := f[0];
DD = BB^2 - 4 AA CC;
EE = Times @@ (#[[1]] & /@
Select[FactorInteger[DD], Mod[#[[2]], 2] == 1 &])
Factor[f[x], Extension -> Sqrt[EE]] // TeXForm (*needed*)
produces $\left(-i x+\sqrt{3}+2 i\right) \left(i x+\sqrt{3}-2 i\right)$ rather than the expected $\left(x-2+i\sqrt{3}\right) \left(x-2-i\sqrt{3}\right)$.
Question
How to convert $a(x-p)^2+q$ to $a(x-\alpha+i\beta)(x-\alpha-i\beta)$ for any real $a$, $p$ and $q$.
Note that $a(x-\alpha+i\beta)(x-\alpha-i\beta)$ must be rendered with the leading $x$ rather than $a(-\alpha+i\beta+x)(-\alpha-i\beta+x)$.
Edit
The order is IMPORTANT: I need $a(x-\alpha+i\beta)(x-\alpha-i\beta)$
NOT $a(-\alpha+i\beta+x)(-\alpha-i\beta+x)$
because it will be piped to TeXForm!
a:=1? – David G. Stork Jul 01 '21 at 16:47Times @@ (x - y /. Solve[f[y] == 0, y])– yarchik Jul 01 '21 at 17:06a = 1but not otherwise. – Michael Seifert Jul 01 '21 at 17:13aat the end.) – Michael Seifert Jul 01 '21 at 17:25f[x_]:= a (x - p)^2 + q, to take one example? – David G. Stork Jul 01 '21 at 17:30a, etc. Moreover, you won't get mixed up by solutions that happen to work with $a=1$ but not for $a \neq 1$. – David G. Stork Jul 01 '21 at 19:51Times @@ Subtract @@@ Flatten @ Solve[f[x] == 0, x](see also Daniel Lichtblau’s answer to the linked duplicate). – Michael E2 Jul 02 '21 at 13:26TeXFormthen it doesn't seem like the position ofxshould matter. Both(x+1)(x+2)and(1+x)(2+x)yield $(x+1) (x+2)$ when piped toTeXForm. – Michael Seifert Jul 02 '21 at 19:14PlusisOrderless. You don't get to pick the position ofx. Perhaps you want something likeTraditionalForm, but likeTeXForm, it formats output display, not the expression itself. – Michael E2 Jul 02 '21 at 21:10a (Times @@ Subtract @@@ Expand@Flatten@Solve[f[x] == 0, x])?: image of full code & output – Michael E2 Jul 03 '21 at 04:33