- #1
dmriser
- 50
- 0
Homework Statement
I am creating a program to help me analyze a quantum system. I am having a problem creating a large function that I can pass 6 initial values to and get the result out (IT).
I am new to this language but have been asked to code in it.
Homework Equations
I am trying to use a Module to encapsulate my code in, however I cannot succeed.
The Attempt at a Solution
CWF[a1_, a2_, r1_, r2_, s1_, s2_] = Module[{w1_, w2_, nw1_,
nw2_, f1_, f2_, nf1_, nf2_, I1_, I2_, IT_},
w1[r1_, a1_] := r1 Exp[-a1 r1]; (* DEFINE
THE W OPERATOR AS 2 PARTS, SEPERATE FUNCTIONS OF R1/A1 AND R2/A2 *)
w2[r2, a2] := r2 Exp[-a2 r2] ;
nw1[r1_, a1_] := w1[r1, a1] / (Sqrt[
Integrate[w1[r1, a1]^2, {r1, 0, Infinity}]]) ;(* NORMALIZE BOTH \
FUNCTIONS AND CREATE A NEW FUNCTION FOR EACH *)
nw2[r2_, a2_] := w2[r2, a2] / (Sqrt[
Integrate[w2[r2, a2]^2, {r2, 0, Infinity}]]);
f1[r1_, s1_] := r1 Exp[-s1 r1]; (* CREATE THE FUNCTIONS F1 AND F2 *)
f2[r2_, s2_] := r2 Exp[-s2 r2];
nf1[r1_, s1_] := f1[
r1, s1] / (Sqrt[Integrate[f1[r1, s1]^2; {r1, 0, Infinity}]]), (*
NORMALIZE BOTH FUNCTIONS AND CREATE A NEW FUNCTION FOR EACH *)
nf2[r2_, s2_] := f2[r2, s2] / (Sqrt[Integrate[f2[r2, s2]^2; {r2, 0,
Infinity}]]),
whhw[r1_, r2_, a1_, a2_, s1_, s2_] := \
(* CONSTRUCT THE INTEGRAND *)
((nw1 * nw2) * (- D[(nf1*nf2), {r1, 2}] - D[(nf1*nf2), {r2, 2}]))
+ D[(nw1*nw2*nf1*nf2), {r1, 2}] +
D[(nw1*nw2*nf1*nf2), {r2, 2}];
I1[r1_, r2_, a1_, a2_, s1_, s2_] := (* INTEGRATE OVER R1 *)
Integrate[whhw, {r1, 0, Infinity}];
I2[r1_, r2_, a1_, a2_, s1_, s2_] := (* INTEGRATE OVER R2 *)
Integrate[whhw, {r2, 0, Infinity}];
IT[r1_, r2_, a1_, a2_, s1_, s2_] := (* OUTPUT THE SUM OF
THOSE INTEGRALS OVER R1 AND R2 *)
I1[r1, r2, a1, a2, s1, s2] + I2[r1, r2, a1, a2, s1, s2];
IT
]
The error message is:
1. Module::argrx: Module called with 4 arguments; 2 arguments are expected.
2. Set::write: Tag Function in Function[{a1_, a2_, r1_, r2_, s1_, s2_}, \
\[LeftSkeleton]1\[RightSkeleton]][a1_, a2_, r1_, r2_, s1_, s2_] is Protected.
Then the output is a long mess that is my code. When I try to call the function with some values (for example CWF[1,1,1,1,1,1]) the error is as follows:
1. Function::flpar: Parameter specification {a1_, a2_, r1_, r2_, s1_, s2_} in \
Function[{a1_, a2_, r1_, r2_, s1_, s2_}, \[LeftSkeleton]1\[RightSkeleton]] \
should be a symbol or a list of symbols
I suspect that the problem may actually not be that complex but a few simple syntax errors. I hope that I have posted this in the correct place.