(*  jacobi_poly_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the Jacobi polynomials *)
(*    at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  25 January 2006 *)
(*  Author:  John Burkardt *)

nvec = {};
avec ={};
bvec = {};
xvec = {};
fvec = {};

Do [ { nvec = Append [ nvec, i],
avec = Append [ avec, 0],
bvec = Append [ bvec, 1],
xvec = Append [ xvec, 1/2 ] },{i,0,5,1}]

Do [ { nvec = Append [ nvec, 5],
avec = Append [ avec, i],
bvec = Append [ bvec, 1],
xvec = Append [ xvec, 1/2 ] },{i,1,5,1}]

Do [ { nvec = Append [ nvec, 5],
avec = Append [ avec, 0],
bvec = Append [ bvec, i],
xvec = Append [ xvec, 1/2 ] },{i,2,5,1}]

Do [ { nvec = Append [ nvec, 5],
avec = Append [ avec, 0],
bvec = Append [ bvec, 1],
xvec = Append [ xvec, i/5 ] },{i,-5,5,1}]

num = Length [ xvec ]

Do [ { n = nvec[[i]],
a = avec[[i]],
b = bvec[[i]],
x = xvec[[i]],
f = JacobiP[n,a,b,x] ,
fvec = Append [ fvec, f ],
      Print["f=",N[f,16]] },{i,1,num,1}]

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