# replace a part of equation by a symbol

I have an equation: $$\frac{d\text{\phi 0}}{dx} \left(-\frac{\text{A1}(x) \frac{d\text{A0}}{dx}}{\text{A0}(x)^2}+\frac{\frac{d\text{A1}}{dx}}{\text{A0}(x)}+\frac{\text{B1}(x) \frac{d\text{B0}}{dx}}{\text{B0}(x)^2}-\frac{\frac{d\text{B1}}{dx}}{\text{B0}(x)}-\frac{2 \text{c1}(x) \frac{d\text{c0}}{dx}}{\text{c0}(x)^2}+\frac{2 \frac{d\text{c1}}{dx}}{\text{c0}(x)}\right)-\frac{2 \text{B0}(x) \text{\phi 0}(x)}{x^4}-\frac{2 \left(\frac{d^2\text{\phi 0}}{dx^2}+\frac{2 \frac{d\text{\phi 0}}{dx}}{x}\right) \frac{d\text{\phi 1}}{dx}}{\frac{d\text{\phi 0}}{dx}}$$ and I want to replace $$\frac{A1(x)}{A0(x)}$$ and $$\frac{B1(x)}{B0(x)}$$ and $$\frac{c1(x)}{c0(x)}$$ with u(x) , v(x) , w(x) what pattern can I use?

• please, provide the expression in Mathematica form as well. Mar 13 '16 at 10:46
• Could try this: How to group certain symbolic expressions? Mar 13 '16 at 10:48

Mathematica often is not cooperative with respect to simplification, but in this case it works well as follows.

-((2 b0[x] ϕ0[x])/x^4) + (-((a1[x] Derivative[a0][x])/a0[x]^2) +
Derivative[a1][x]/a0[x] - (b1[x] Derivative[b0][x])/b0[x]^2 +
Derivative[b1][x]/b0[x] + 2 (-((c1[x] Derivative[c0][x])/c0[x]^2) +
Derivative[c1][x]/c0[x])) Derivative[ϕ0][x] - (2 Derivative[ϕ1][x]
(2 Derivative[ϕ0][x] + (ϕ0^′′)[x]))/Derivative[ϕ0][x]

% //. {D[a1[x]/a0[x], x] -> D[u[x], x], D[b1[x]/b0[x], x] -> D[v[x], x],
D[c1[x]/c0[x], x] -> D[w[x], x]}

(* (-2*b0[x]*ϕ0[x])/x^4 + (Derivative[u][x] + Derivative[v][x] +
2*Derivative[w][x])*Derivative[ϕ0][x] -
(2*Derivative[ϕ1][x]*(2*Derivative[ϕ0][x] + Derivative[ϕ0][x]))/
Derivative[ϕ0][x] *)


there might be another way:

 f[num_, den_, d_] := Module[{a1 = num, ao = den},
(a1/ao^2) ->  (a1/ao) /. (a1/ao) ->  d[x]]

a1[x]/ao[x]^2 /. f[a1[x], ao[x], u]  (* u[x] *)
b1[x]/bo[x]^2 /. f[b1[x], bo[x], v]  (* v[x] *)
c1[x]/co[x]^2 /. f[c1[x], co[x], w]  (* w[x] *)