# Why doesn't my code evaluate element of a vector at a given t?

I have written a code to solve the Shrodinger equation for a particular three level siystem in two ways: the first way I defined three functions C1[t], C2[t], C3[t] and I solved three ODEs;

the second way I defined a vector Cn[t_]:={C1[t],C2[t],C3[t]} and solved a single equation.

My code needs to evaluate, at the final time t0, the value of (Abs[C3[t0]])^2. This task is easily accomplished in the first code:

but not in the second, where the output doesn't give me the numerical value:

Can anyone explain me what am I doing wrong?

Edit: Here's the code that gave me problems:

\[CapitalDelta] = 0
\[Gamma] = 0
\[Delta] = 0
T = 100
\[CapitalOmega] = 1
t0 = 5*T
\[Tau] = 0.7*T
\[CapitalOmega]s[t_] := \[CapitalOmega]*Exp[-((t + \[Tau])/T)^2]
\[CapitalOmega]p[t_] := \[CapitalOmega]*Exp[-((t - \[Tau])/T)^2]

H[t_] := (1/2)*{{0, \[CapitalOmega]p[t], 0}, {\[CapitalOmega]p[t], 2*\
[CapitalDelta] - I*\[Gamma], \[CapitalOmega]s[t]}, {0, \
[CapitalOmega]s[t], 2*\[Delta]}}
Cn[t_] := {C1[t], C2[t], C3[t]}

s = NDSolve[{D[Cn[t], t] == (1/I)*H[t] . Cn[t], Cn[-t0] == {1, 0, 0}},
Cn[t], {t, -t0, t0}]
Evaluate[Abs[C3[t0]]^2 /. s]

• Please include the actual Mathematica code in your question, not a picture of it. Also, provide the complete code, including values of constants. Commented Nov 9, 2021 at 17:44
• My first thought is that the use of uppercase C is reserved. While you are preparing to paste your code, please switch to lowercase symbol names.
– Syed
Commented Nov 9, 2021 at 18:07
• In the second bit of code, it spits out a replacement rule for C3[t], whereas in the first it spits out a replacement rule for C3. The first then works because in the replacement Abs[C3[t0]]^2 /. s, it matches the pattern for C3, but in the second, it matches the pattern for C3[t], and nothing in Abs[C3[t0]]^2 /. s matches C3[t]. Instead, do Abs[C3[t]]^2 /. s /. t -> t0. Commented Nov 9, 2021 at 19:11
• In such a case, if you feel the pictures of the code make it significantly easier to read, please also provide the (input) code itself alongside those pictures—this allows people to easily copy-paste and test out your code (and test modifications to it) without re-typing it all themselves. Commented Nov 9, 2021 at 20:30
• Sara, there’s no answer to this question, yet (SE displays 0 answers). I would recommend putting your code in your question here as an update, then perhaps providing a self-answer using march’s suggestion that helped you. Commented Nov 10, 2021 at 15:59

As suggested by @march, the problem was that the second bit of code spit out a replacement rule for C3[t] instead of C3; Substituting what I initially wrote with Abs[C3[t]]^2 /. s /. t -> t0 solved the problem.