⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex_2qn3.c

📁 an quasi-newton method used in non-linear programming and especially in optimization
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <math.h>#include <time.h>#include "math_util.h"int n_fun;main(){    clock_t time_0, time_1;    long double dtime;    long double tol, *x;    int n;    long double ex2_fun( long double * );    void q_newton_3( long double(*)(),                 long double *, int, long double );    	n_fun = 0;	n = 2;	x = a1d_allo_dbl( n );	x[0] = 0.5;	x[1] = 0.5;	tol = 1.0e-4;	    time_0 = clock();    q_newton_3( ex2_fun, x, n, tol );    time_1 = clock();    dtime = (long double)(time_1-time_0)/((long double)CLOCKS_PER_SEC);        printf("Solution x: ");print_vec_dbl( x, n );    printf("\n # of function evaluations: %d\n",n_fun);    printf(" Solution time: %Le",dtime);}/*	Easson function*/long double ex2_fun( x )long double *x;{   long double f, t1, t2, t8, t11, x1, x2;      n_fun++;      x1 = x[0];   x2 = x[1];   t1 = x1*x1;   t2 = x2*x2;   t8 = t1*t1;   t11 = t2*t2;   f = 6.0/5.0+t1/10+(1.0+t2)/t1/10+(t1*t2+100.0)/t8/t11/10;        return( f );}/****  Norm( h ) <= epsSolution x:  1.743439e+00  2.029691e+00 # of function evaluations: 112 Solution time: 1.133333e+00*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -