(*  legendre_function_q_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the derivative of the Legendre *)
(*    function at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  29 January 2006 *)
(*  Author:  John Burkardt *)

xvec = { 1/4, 1/4, 1/4, 1/4, 1/4,
1/4, 1/4, 1/4, 1/4, 1/4,
1/4, 0, 1/10, 2/10, 3/10,
4/10, 5/10, 6/10, 7/10, 8/10,
9/10 }
nvec = { 0, 1, 2, 3, 4,
5, 6, 7, 8,9,
10, 3, 3, 3, 3,
3,3,3,3,3,
3 }
fvec = {};
num = Length [ xvec ];

Do [ {x = xvec[[i]],
n = nvec[[i]],
 f = LegendreQ[n,x] ,
fvec = Append[fvec,f],
      Print["f=",N[f,16]] },{i,1,num,1}]

fileout=OpenWrite["C:\\Documents and Settings\\burkardt\\Desktop\\Misc\\mathematica\\legendre_function_q_values.txt"];
SetOptions[fileout,FormatType->TextForm];
Write[fileout,"#  legendre_function_q_values.txt"];today=DateList[];Write[fileout,"#  Created on ",today];Write[fileout,"#"];
Write[fileout,"#  n  x  f"];
Write[fileout,"#"];
Do[{n=nvec[[i]];x=xvec[[i]];f=fvec[[i]];Write[fileout,n,"  ",N[x,16],"  ",N[f,16]]},{i,1,num,1}];Close[fileout];