# Derivation after substitution not working

I have a code that will output an expression in form of a functions like this

(Λ[θ]^3 Ω[θ] - 4 (3 Derivative[Λ][θ] Derivative[Ω][θ] + Ω[θ] ( Λ′′)[θ]) -
4 Λ[θ] (Ω[θ] + 3 (Ω′′)[θ]))/(4 G J Λ[θ] Ω[θ]^3)


Now, I have functions $\Lambda(\theta)$ and $\Omega(\theta)$, that I'd like to replace with some values of theta. I tried with -> and :> and none of the replacement rules will differentiate my replacement. I can differentiate the variables separately, and then specify replacement rule Λ'[θ] -> value(θ), and then use /. Derivative[Λ][θ]-> value[θ], but that seems kinda redundant.

Why isn't Mathematica doing it on it's own, recognising that it is the same expression, and just evaluating the derivative? This way Mathematica is treating differentiated lambdas or omegas as something not connected to original lambda and omega.

Why is this so, and can it be circumvented?

• If you can't install the script don't use Greek letters ... it isn't that hard – Dr. belisarius Nov 1 '13 at 14:40

I hope I understood correctly what you try to do... Assume the following simple example where you have derivatives

expr=Expand[(D[f[x],{x,2}]+f[x])^3]
(* f[x]^3+3 f[x]^2 f''[x]+3 f[x] f''[x]^2+f''[x]^3 *)


The problem you are facing is that you want to apply a rule like

f[x_] :> Cos[x]*Sin[x]


This will not work on the derivatives because there FullForm does not match the lhs of the rule. What you probably want is to

1. replace the head f with your function
2. replace all x with the value

Therefore, if you know your function f[x] is now Cos[x]*Sin[x] you can do

expr /. f -> (Sin[#]*Cos[#] &)

(* -27 Cos[x]^3 Sin[x]^3 *)


and then you replace the value for x

% /. x->Pi
(* 0 *)

• This one expr /. f -> (Sin[#]*Cos[#] &) is what I needed! Now it works :) Thank you very much :) I was wondering if it's because the FullForm expression for each one isn't the same and that is making an issue, and I guess it's true. Thanks again :) – dingo_d Nov 2 '13 at 8:11
• Yes, when you replace something, you should always look at the FullForm when something doesn't work as you like it. – halirutan Nov 2 '13 at 9:53
• I'll have that in mind in the future :) Thanks – dingo_d Nov 3 '13 at 12:55