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

xvec = {};
mvec={};
nvec = {};
fvec = {};
Do [ { x = 2/10,
xvec = Append [ xvec, x ],
m = 5/10,
mvec = Append [ mvec, m],
nvec = Append [ nvec, n ] },{n,0,16,1}]

Do [ { x = 4/10,
xvec = Append [ xvec, x] ,
mvec = Append [ mvec, m],
n = 2,
nvec = Append [ nvec, n]},{m,0,16,1}]

Do [ { x = i / 10,
xvec = Append [ xvec, x ],
m = 3,
mvec = Append [mvec, m],
n = 5,
nvec = Append [ nvec, n]},{i,-5,10,1}]
num = Length [ xvec ];

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

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