restart; # makephi.mpl -- Make phi to solve F=x for Newton's Iteration # Written October 15, 2012 for Math 701 by Eric Olson # # F is an expression in x # N is the number of the function # kernelopts(printbytes=false); fname:=sprintf("phi%d.i",N); fd:=open(fname,WRITE); fprintf(fd,"/* %s -- Created by Maple */\n",fname); close(fd); with(codegen,C,optimize): cmp:=[I=cI,cos=ccos,sin=csin,exp=cexp]; tmp:=[seq(t||i=T[i],i=1..64)]; f:=F; df:=diff(f,z); r1:=[phi=z-f/df]; r2:=[optimize(r1,'tryhard')]; r3:=subs(cmp,r2); r4:=subs(tmp,r3); C(r4,filename=fname);