c源码

源代码在线查看: xinum.h

软件大小: 34 K
上传用户: jun604001464
关键词: 源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				/* f.h                    freeware                          xhunga@tiscali.fr */
				
				
				/* ------------------------------------- FUNCTION --------------------------  */
				/* Do    :                                                                    */
				/*                                                                            */
				/* -------------------------------------------------------------------------- */
				double trapezoid(
				double (*P_f)(double x),
				double a,
				double b,
				   int n
				)
				{
				   int i = 0;
				double m = 0.;
				double M = 0.;
				
				 for(i = 0; i 				 {
				    if(i ==0 || i== n){m = 1.;}
				  else                {m = 2.;}
				
				  M += m * (*P_f)(a + i*(b-a)/n);
				 }
				
				  return( ((b -a)*M) / (2*n) );
				}
				
				
				/* ------------------------------------- FUNCTION --------------------------  */
				/* Do    :                                                                    */
				/*                                                                            */
				/* -------------------------------------------------------------------------- */
				double simpson(
				double (*P_f)(double x),
				double a,
				double b,
				   int n
				)
				{
				   int i = 0;
				double m = 0.;
				double M = 0.;
				
				 for(i = 0; i 				 {
				       if(i ==0 || i== n){m = 1.;}
				  else if(fmod(i,2) == 0){m = 2.;}
				  else                   {m = 4.;}
				
				  M += m * (*P_f)(a + i*(b-a)/n);
				 }
				
				  return( ((b -a)*M) / (3*n) );
				}
				
				
							

相关资源