# Strange behavior of the Evaluate function

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

{{C00[t]},{C01[t]},{C10[t]},{C11[t]}}


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?

## 2 Answers

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


Hold[Map[Function[Evaluate[ReplaceAll[Slot[1][t],sol]]],vec]]

The second function:

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


Hold[Map[Function[Times[1,Evaluate[ReplaceAll[Slot[1][t],sol]]]],vec]]

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

sol={{x->3}}


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]& *)