목차
/* 수치해석 레포트1-1*/
/* The Incremental Search Method */
/* 수치해석 레포트1-2*/
/* The Bisection Method */
/* 수치해석 레포트1-3*/
/* The Method of False Position */
/* 수치해석 레포트1-4*/
/* Newton-Raphson Method */
/* The Incremental Search Method */
/* 수치해석 레포트1-2*/
/* The Bisection Method */
/* 수치해석 레포트1-3*/
/* The Method of False Position */
/* 수치해석 레포트1-4*/
/* Newton-Raphson Method */
본문내용
/* 선행처리기 */
#include
#include
#include
/* 함수 정의문 */
#define f(x) a[4]*pow((x),4)+ a[3]*pow((x), 3)+a[2]*pow((x), 2)+a[1]*(x)+a[0]
/* 본문 */
void main(void)
{
double a[5];
double xi, xd, y1, y2, eps=1.0e-3, del_x=0.1;
/* 파일 입출력을 위한 파일 지정 부분 */
FILE *in, *out;
in=fopen(\"data.in\",\"r\");
out=fopen(\"data.out\", \"w\");
int it_max, it=0;
fscanf(in,\"%lf%lf%lf%lf%lf\", &a[4], &a[3], &a[2], &a[1], &a[0]);
fprintf(out, \"Input [Max Iteration] & [inirial x]:\");
fscanf(in, \"%d%lf\", &it_max, &xi);
fprintf(out, \"\n Initial dx= %f Tolerance= %f\n\", del_x, eps);
while(1){
it++;
xd=xi+del_x;
y1=f(xi);
y2=f(xd);
if(y1*y2>0) xi=xd;
if(y1*y2<0)
if(del_x
else del_x=del_x/10.0;
if(y1*y2==0)break;
if(it>it_max){
fprintf(out, \"iteration=%d Check Error!!!!\", it);
exit(1);
}
}
fprintf(out, \"\nf(x)=%10.3lfx^4 + %10.3lfx^3 + %10.3lfx^2 + %10.3lfx + %10.3lf\n\",
a[4], a[3], a[2], a[1], a[0]);
fprintf(out,\"First=%10.3lf \n iteration= %d \n\", xd,it);
fclose(in);
fclose(out);
#include
#include
#include
/* 함수 정의문 */
#define f(x) a[4]*pow((x),4)+ a[3]*pow((x), 3)+a[2]*pow((x), 2)+a[1]*(x)+a[0]
/* 본문 */
void main(void)
{
double a[5];
double xi, xd, y1, y2, eps=1.0e-3, del_x=0.1;
/* 파일 입출력을 위한 파일 지정 부분 */
FILE *in, *out;
in=fopen(\"data.in\",\"r\");
out=fopen(\"data.out\", \"w\");
int it_max, it=0;
fscanf(in,\"%lf%lf%lf%lf%lf\", &a[4], &a[3], &a[2], &a[1], &a[0]);
fprintf(out, \"Input [Max Iteration] & [inirial x]:\");
fscanf(in, \"%d%lf\", &it_max, &xi);
fprintf(out, \"\n Initial dx= %f Tolerance= %f\n\", del_x, eps);
while(1){
it++;
xd=xi+del_x;
y1=f(xi);
y2=f(xd);
if(y1*y2>0) xi=xd;
if(y1*y2<0)
if(del_x
if(y1*y2==0)break;
if(it>it_max){
fprintf(out, \"iteration=%d Check Error!!!!\", it);
exit(1);
}
}
fprintf(out, \"\nf(x)=%10.3lfx^4 + %10.3lfx^3 + %10.3lfx^2 + %10.3lfx + %10.3lf\n\",
a[4], a[3], a[2], a[1], a[0]);
fprintf(out,\"First=%10.3lf \n iteration= %d \n\", xd,it);
fclose(in);
fclose(out);
소개글