I would like to transform rules algebraically. A very simple example would be: -
k^2 - 2 k x + x^2 /. {2*k -> 1}
This transforms to: -
$$k^2-2 k x+x^2$$
However, I would like it to return something more like: -
$$\frac{1}{4}- x+x^2$$
In fact, I am more interested in solving quadratic, cubic and quartic polynomials. For example, I am able to set the discriminant of a quadratic to zero as a rule since the solution of a quadratic is already in an expanded form: -
quadratic = a*x^2 + b*x + c
Solve[quadratic == 0, x] /. { Discriminant[quadratic, x] -> 0 }
This yields the correct results: -
$$\left\{\left\{x\to -\frac{b}{2 a}\right\},\left\{x\to -\frac{b}{2 a}\right\}\right\}$$
To achieve something similar for the cubic one must expand the solution while also transforming the discriminant.
cubic := a*x^3 + b*x^2 + c*x + d;
ExpandAll[Solve[cubic == 0 , x]] /. { Expand[-27*a^2*Discriminant[cubic, x]] -> 0 }
This process requires some forward thinking and doesn't easily apply to a quartic.
I am hoping Mathematica has some built in transformation rules for substituting expressions algebraically (obviously assuming certain criteria, i.e field/ring etc..) Does anyone have any suggestions?
k^2 - 2 k x + x^2 /. {k -> 1/2}. – b.gates.you.know.what Feb 20 '13 at 17:19cubic/.Evaluate[Solve[Discriminant[cubic,x]==0,a]]– chuy Feb 20 '13 at 17:45Simplify[Solve[cubic == 0, x], Discriminant[cubic, x] == 0]? (not sure if that is what you wanted) – Pinguin Dirk Feb 20 '13 at 17:49