I am solving a system of differential equation whose unknown are saved under variable vec={C00,C01,C10,C11} and the solutions are saved under variable sol. However I observe a strange behavior using the Evaluate function. If I do

Evaluate[#[t] /. sol] & /@ vec 

I get


That does not allow me to plot the function whereas if I do

1*Evaluate[#[t] /. sol] & /@ vec

I obtain an InterpolatingFunction that allows me to plot the function

{{2 InterpolatingFunction[{{0.,10.}},<>][t]},{2 InterpolatingFunction[{{0.,10.}},<>][t]},{2 InterpolatingFunction[{{0.,10.}},<>][t]},{2 InterpolatingFunction[{{0.,10.}},<>][t]}}

I would like to understand what happened here and why the function behave differently in these two cases?


As stated on the Evaluate help page (Possible Issues section):

Evaluate works only on the first level, directly inside a held function:

Your first version -when used with Hold- looks like this:

Evaluate[#[t] /. sol] & /@ vec // Hold // FullForm


The second function:

1*Evaluate[#[t] /. sol] & /@ vec // Hold // FullForm


As you can see, Evaluate has gotten a level deeper and is therefore not effective anymore.


This is a bit subtle. I assume that your sol is something like


Evaluate is used to overrule an Hold attribute (not for evaluating expressions). The command Function has attribute HoldAll. So in your first situation you map

Function[ Evaluate[#[t] /. sol]]

(* {#1[t]}& *)

In the second situation, Evaluate is in a Times expression, so it has no effect on Function. So you map

Function[Times[1, Evaluate[#[t] /. sol]]]

(* 1 Evaluate[#1[t]/. sol]& *)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.