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

xvec = {};
nvec = {};
fvec = {};

Do [ {  xvec = Append [ xvec, 1/4],
nvec = Append [ nvec, i]  },{i,0,10,1}]

Do [ {nvec = Append [ nvec, 3],
xvec = Append [ xvec, i / 10], },{i,0,10,1}]
num = Length [ xvec ];

Do [ {  x = xvec[[i]], 
n = nvec[[i]],
f = LegendreP[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_poly_values.txt"];
SetOptions[fileout,FormatType->TextForm];
Write[fileout,"#  legendre_poly_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];