Category : C Source Code
Archive   : RECIPEX.ZIP
Filename : XRTSAFE.C

 
Output of file : XRTSAFE.C contained in archive : RECIPEX.ZIP
/* Driver for routine RTSAFE */

#include
#include "nr.h"
#include "nrutil.h"

#define N 100
#define NBMAX 20
#define X1 1.0
#define X2 50.0

static float fx(x)
float x;
{
return bessj0(x);
}

static void funcd(x,fn,df)
float x,*fn,*df;
{
*fn=bessj0(x);
*df = -bessj1(x);
}

main()
{
int i,nb=NBMAX;
float xacc,root,*xb1,*xb2;

xb1=vector(1,NBMAX);
xb2=vector(1,NBMAX);
zbrak(fx,X1,X2,N,xb1,xb2,&nb);
printf("\nRoots of bessj0:\n");
printf("%21s %15s\n","x","f(x)");
for (i=1;i<=nb;i++) {
xacc=(1.0e-6)*(xb1[i]+xb2[i])/2.0;
root=rtsafe(funcd,xb1[i],xb2[i],xacc);
printf("root %3d %14.6f %14.6f\n",i,root,fx(root));
}
free_vector(xb2,1,NBMAX);
free_vector(xb1,1,NBMAX);
}


  3 Responses to “Category : C Source Code
Archive   : RECIPEX.ZIP
Filename : XRTSAFE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/