I thought this was just about order of operations, and it is largely that, but there is an added twist I'll get to.
First, let me note you've defined soln
using SetDelayed
. I think that is a mistake because it means DSolve
is reevaluated every single time you evaluate soln
. If that's slow, soln
will be very slow. In fact, I'd define soln
as follows
soln[t_] = DSolveValue[Derivative[1][x][t] == y[t], Derivative[1][y][t] == -x[t], x[0] == 0, y[0] == 1}, {x[t], y[t]}, t]
Now, as for your mystery. When you evaluate soln'[t]
, this is interpreted as
Derivative[1][soln][t]
Okay, what's the derivative of soln? It's going to be computed as
D[soln[someVar], someVar]
Well, that looks very innocent, but the question is what is someVar
? It depends on the version exactly what temporary expression Derivative
uses, but critically this temporary variable is going into DSolve
, not the solution, beacuse you've used SetDelayed
to define soln
. Moreover, the temporary expression is something that will prevent DSolve
from evaluating successfully. In V12.1, DSolve
returns an empty list, which means First[DSolve[...]]
won't evaluate, which means /.
won't evaluate, and you get the output above. And if you think about, trying to run DSolve
, which solves things about derivatives, while in the process of actually computing a derivative, is going to problematic at best.
When you use D[soln[t],t]
, since D
isn't a holding function, soln[t]
evaluates to {Sin[t], Cos[t]}
before D
ever sees it, and you're fine.
Finally, had you defined soln
using Set
, then someVar
would have been substituted into {Sin[t], Cos[t]}
rather than the original DSolve
expression, and everything would also have been fine. This is another reason why it is typically better to use Set
when you are substituting output from a solver into an expression.
soln[t] := ...
should besoln[t_] := ...
(notice the undescore after thet
). $\endgroup$