# Expanding complex expression and replacing variables in the result

When I'm finished expanding my expression I would like the result to be expressed again in terms of the original variables (like α, S1, T1, T2). I've tried replace, but can't seem to have good results. Any suggestions?

c = ((1 + I) Pi)/D1;
τ = I τy;
u0 = ((1 - I) π τ)/(D1 *ρ0* f);
ζ[h_] := (π h)/D1;
α[h_] := (Cosh[ζ[h]]*
Cos[ζ[h]])^2 + (Sinh[ζ[h]]*Sin[ζ[h]])^2;

S1[h_] := (Cosh[ζ[h]]*Cos[ζ[h]])/α[h];
T1[h_] := (Cosh[ζ[h]]*Sinh[ζ[h]])/α[h];
T2[h_] := (Cos[ζ[h]]*Sin[ζ[h]])/α[h];

vg[h_] := (
2*π)/(ρ0*f*D1)*((1 - S1[h])/(T1[h] - T2[h])*τy) -
ug*(T1[h] + T2[h] - 2*π*h/D1)/(T1[h] - T2[h]);
ugc[h_] := ug + I vg[h];
uec[z_, h_] :=
u0*Sinh[c*(z + h)]/Cosh[c*h] - ugc[h]*Cosh[c*z]/Cosh[c*h];
uc[z_, h_] := uec[z, h] + ugc[h];

expr = ComplexExpand[uc[z, h], TargetFunctions -> {Re, Im}]

• Something like this: but I'm not sure why I don't see S1/T1/T2 rules = {S1[h_] :> Inactivate[S1[h]], T1[h_] :> Inactivate[T1[h]], T2[h_] :> Inactivate[T2[h]], \[Alpha][h_] :> Inactivate[\[Alpha][h]], \[Zeta][h_] :> Inactivate[\[Zeta][h]]}; FullSimplify[ReplaceRepeated[FullSimplify@expr, rules]] – flinty May 21 at 20:08
• Any symbol that appears on the LHS of a Set or SetDelayed can never appear outside a held expression since the specified replacement will always be automatically done. If you want to use these symbols in expressions, use Equal rather than Set or SetDelayed to define equations then solve the system of equations for the desired variables. – Bob Hanlon May 21 at 20:08