Below first case which gives particular solutions of an OED correctly:
ClearAll[soln]; (* case 1 *)
soln[a_?NumericQ] :=
soln[a] =
DSolve[{y''[t] + y[t] == Sin[t], y[0] == a, y'[0] == 0}, y[t],
t];
res1 = Grid[
Partition[
Table [soln[i][[1, 1, 2]], {i, 0, 2, 1}] // FullSimplify , 1],
Frame -> All]
As the OED is manipulated elsewhere in my notebook I need to rewrite the above code using an assignment for the equation:
ClearAll[solp]; (* case 2 *)
eqd := {y''[t] + y[t] == Sin[t], y[0] == a, y'[0] == 0};
solp[a_?NumericQ] := solp[a] = DSolve[eqd, y[t], t];
res2 =
Grid[Partition[
Table [solp[i][[1, 1, 2]], {i, 0, 2, 1}] // FullSimplify , 1],
Frame -> All]
However this time I only get the general solution with the particular solutions left unevaluated for the arbitray value "a". What's wrong here?
I checked that it is possible to use an assignement for the equation given to DSolve but after rewriting the first case like that:
solq = DSolve[eqd, y[t], t] ; (* case 3 *)
res3 = Grid[
Partition[
Table [solq[[1, 1, 2]] /. a -> i, {i, 0, 2, 1}] // FullSimplify ,
1], Frame -> All]
res3 == res1
Why is it OK here and not in case 2? Thanks