0
$\begingroup$

I'm new to Mathematica, and I am still having some issues figuring out the general syntax. I've got to use Mathematica, as my research requires a powerful symbolic math program.

I'm having trouble taking values from Solve and plugging them back into functions. My code is below. I would ultimately like to be able to take the values from solve, and plug them back into psi_n+1 and E_n+1, and make these values become the new psi_n and E_n, and do this iteratively in a for loop.

ClearAll["Global`*"]
ℏ = 1;
m = 1;
L = 1;
Subscript[ψ, n][x_] = x (L - x);
g[x_] = x;
H[f_, x_] := (-ℏ^2/(2 m)) D[f, {x, 2}];
a[x_] = H[Subscript[ψ, n][x], x];

Subscript[E, n] =
  Integrate[Conjugate[Subscript[ψ, n][x]] g[x] a[x], {x, 0, L}] /
  Integrate[Conjugate[Subscript[ψ, n][x]] Subscript[ψ, n][x], {x, 0,L}];

Subscript[ψ, n + 1][x_, C1_, C0_] :=
  Subscript[ψ, n][x] + g[x] (C1/C0) (a[x] - Subscript[E, n] Subscript[ψ, n][x]);

Subscript[E, n + 1][C1_, C0_] =
  Integrate[
    Conjugate[Subscript[ψ, n + 1][x, C1, C0]] g[x] 
      H[Subscript[ψ, n + 1][x, C1, C0], x], 
    {x, 0, L}] /
  Integrate[
    Conjugate[Subscript[ψ, n + 1][x, C1, C0]] Subscript[ψ, n + 1][x, C1, C0],
    {x, 0, L}];

b[x_] = Subscript[E, n] Subscript[ψ, n][x];
c[x_, C1_, C0_] = Subscript[E, n + 1][C1, C0] Subscript[ψ, n][x];
e[x_] = a[x] - b[x];
f[x_, C1_, C0_] = a[x] - c[x, C1, C0];

eqn1[C0_, C1_] =
  C0 Integrate[Conjugate[Subscript[ψ, n][x]] f[x, C1, C0], {x, 0, L}] +
  C1 Integrate[
       Conjugate[Subscript[ψ, n][x]] 
         (H[g[x] e[x], x] - Subscript[E, n + 1][C] g[x] e[x]),
       {x, 0, L}];

eqn2[C0_, C1_] =
  C0 Integrate[
       Conjugate[Subscript[ψ, n][x]] H[g[x] f[x, C1, C0], x] - 
         Subscript[E, n + 1][C1, C0] g[x] f[x, C1, C0],
       {x, 0, L}] +
  C1 Integrate[
       Conjugate[Subscript[ψ, n][x]] 
         (H[g[x](H[g[x] e[x], x] - Subscript[E, n + 1][C1, C0] g[x] e[x]), x] - 
            Subscript[E, n] g[x] (H[g[x] e[x], x] - 
            Subscript[E, n + 1][C1, C0] g[x] e[x])),
       {x, 0, L}];

Solve[eqn1[C0, C1] == 0 && eqn1[C0, C1] == 0, {C1, C0}, Reals]
$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.