# Substitute when hold is on

I have an expression for $div$ with Lame coefficients. I want to look at the $div$ in different coordinate systems. So I want to substitute the Lame coefficients not letting Mathematica to actually differentiate, thats why I am using hold. So I need a valid combination of hold and substution to get what I need. Here is my code

divA = Hold[(1/(H1*H2*H3))*(D[Ax*H2*H3, x] + D[Ay*H3*H1, y] + D[Az*H1*H2, z])]

Hold[(D[Ax*H2*H3, x] + D[Ay*H3*H1, y] + D[Az*H1*H2, z])/(H1*H2*H3)]

divA /. {H1, H2, H3} -> {1, 1, 1}


Hold[(D[Ax*H2*H3, x] + D[Ay*H3*H1, y] + D[Az*H1*H2, z])/(H1*H2*H3)]

• Is is not replacing because there is no {H1, H2, H3} to replace... Try divA /. Thread[{H1, H2, H3} -> {1, 1, 1}], it has nothing to do with Hold.
– Kuba
Jun 8, 2016 at 8:58
• @Kuba it helped but not really, cause I got the next expression Hold[(D[Ax*1*1, x] + D[Ay*1*1, y] + D[Az*1*1, z])/(1*1*1)] It didn't do multiplication. I want multiplication to be done but not differentiation. Jun 8, 2016 at 9:04
• There are topics about injecting into held expression but the shortest way is to use Inactivate on D.
– Kuba
Jun 8, 2016 at 9:08
• @Kuba ty, very much. That is exactly what I wanted. It helped! Jun 8, 2016 at 9:13

May be, like this:

A = {H2*H3*Ax[x, y, z], H1*H3*Ay[x, y, z], H1*H2*Az[x, y, z]};


Then

    expr = 1/(H1*H2*H3)*Inactive[Div][A, {x, y, z}]

(*    Inactive[Div][{H2 H3 Ax[x, y, z], H1 H3 Ay[x, y, z],
H1 H2 Az[x, y, z]}, {x, y, z}]/(H1 H2 H3)   *)


And you may substitute:

expr1=expr /. Thread[{H1, H2, H3} -> {1, 1, 1}]

(* Inactive[Div][{Ax[x, y, z], Ay[x, y, z], Az[x, y, z]}, {x, y, z}]  *)


and then activate, if necessary:

expr1 // Activate

Have fun!

• Thank you for the answer. @Kuba has already lit the light on Inactivate[] for me. Jun 8, 2016 at 9:15