Re: Trouble with FindRoot
- To: mathgroup at smc.vnet.net
- Subject: [mg79229] Re: Trouble with FindRoot
- From: chuck009 <dmilioto at comcast.com>
- Date: Sat, 21 Jul 2007 04:34:30 -0400 (EDT)
> Sooraj R wrote:
> > Now for the initial guess for second row, I need to
> > use the first row as the initial guess, and so on.
> > How do I do this?
Jean-Marc, Looks like your code is not doing this. I modified it to do so:
eh = Table[Eh, {10}, {16}];
m = 3.85857975 10^-31;
charge = 1.602 10^-19;
hbar = 1.054571 10^-34;
LH = {88.83663979522105,
93.83693172861489, 98.83720928295747, 103.83746882256844, \
108.83770913229637, 113.837930338503, 118.83813328307562, 123.83831915913095, \
128.83848929997706, 133.8386450587284, 138.83878774185274, 143.8389185748323, \
148.8390386868427, 153.83914910653547, 158.83925076412058, \
163.83934449683832};
F = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 10^6;
ZeroField = Table[0, {16}];
For[i = 1, i < 17, i++, ZeroField[[i]] = (Pi hbar)^2/(2 m charge (LH[[i]]
10^-10)^2)]
(*Added Print function so ZeroField is displayed*)
Print[ZeroField // MatrixForm];
(* now do the first row *)
For[i = 1, i < 17, i++, eh[[1, i]] = Eh /. FindRoot[AiryAi[-((2*
m)/(charge*hbar*F[[j]])^2)^(1/3) (Eh
charge + charge*F[[j]]*(LH[[i]] 10^-10)/2)] AiryBi[-((2*m)/(charge*hbar*
F[[j]])^2)^(1/3) (Eh charge - charge*F[[j]]*(LH[[i]]
10^-10)/2)] == AiryAi[-((2*m)/(charge*hbar*F[[j]])^2)^(1/
3) (Eh charge - charge*F[[j]]*(
LH[[i]] 10^-10)/2)] AiryBi[-((2*m)/(charge*
hbar*F[[j]])^2)^(
1/3) (Eh charge + charge*F[[j]]*(LH[[i]]
10^-10)/2)], {Eh, ZeroField[[i]]}]]
(* now do succeeding
rows by using the
row above each as the starting values for \
FindRoot *)
For[j = 2, j < 11, j++, For[i = 1, i < 17,
i++,(*Here we are : the symbol Eh located at (j, i) is going to be replace \
by the value returned by FindRoot by applying the replacement operator /. to \
the transformation rule of the form {Eh -> somenumber}*)eh[[j,
i]] = Eh /. FindRoot[AiryAi[-((2*m)/(
charge*hbar*F[[j]])^2)^(1/3) (Eh charge + charge*F[[j]]*(
LH[[i]] 10^-10)/2)] AiryBi[-((2*m)/(charge*hbar*F[[j]])^2)^(
1/3) (Eh charge - charge*F[[j]]*(LH[[i]] 10^-10)/2)] == \
AiryAi[-((2*m)/(charge*hbar*F[[j]])^2)^(1/3) (Eh charge - \
charge*F[[j]]*(LH[[i]] 10^-10)/2)] \
AiryBi[-((2*m)/(charge*hbar*F[[j]])^2)^(1/3) (Eh
charge + charge*F[[j]]*(LH[[i]] 10^-10)/2)], {Eh, eh[[j - 1, i]]}]]]
eh // MatrixForm