x = _ _, _ ;
.
:
,
,
;
i = i + 1 .
( ) , x (, x = 0,1) .
:
, .. ;
, . .
( ). yi i, ( yi = 0, i = 0), (yi = yi-1 x/i, i = i+1). ( ), ( ) , .
, () .
, () . (. 8.7), , (ex) , . (yi-1 = 1) (i = 1). i = i + 1. , ( 5), ( 6, 7, 8, 9) ( 10). . .
. 8.3.
8.3
x | i | ex | yi | yi-1 | ||
x | eps | i | ex | yi | yi1 |
. 8.7. 8.3
.
#include <stdlib.h> /* */
#include <stdio.h> /* */
#include <conio.h>
#include <math.h>
#include <windows.h>
main() /* */
{
float x, eps, yi, yi1, ex; /* */
int i; /* */
char buf[50]; /* */
clrscr();
CharToOem(" x: ",buf);
printf("\n %s ",buf);
scanf("%f", &x);
CharToOem(" : ",buf);
printf("\n %s ",buf);
scanf("%f", &eps);
|
|
printf("\n x=%.2f eps=%.2e ", x, eps);
i = 1;
yi1 = 1;
ex = 1;
printf("\n ------------------------------------"
"\n | i | yi | ex |"
"\n -------------------------------------");
do
{
yi = yi1 * x/i;
ex = ex + yi;
printf("\n | %2d | %12.6f|%15.6f|", i, yi, ex);
i = i + 1;
yi1 = yi;
}
while(fabs(yi) >= eps);
printf("\n ------------------------------------");
CharToOem(" i= ",buf);
printf("\n %s %4d \n",buf,i-1);
CharToOem(" exp(x) = ",buf);
printf("\n %s % 15.6f\n",buf,ex);
getch();
}
12.5
1e-2
12.5
1e-4
12.5
1e-6
.
8.5 (, , ).
. (EditX, EditEps). - (ListBoxYi, ListBoxExp). ( ) (PoleIter, PoleExp).
|
|
, . .
.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
.
void TSumprDlgClient::BNClickedOk()
{
// INSERT>> Your code here.
float x, eps, yi, yi1, ex; /* */
int i; /* */
char buf[50]; /* */
ListBoxYi->ClearList(); /* */
ListBoxExp->ClearList();/* */
EditX->GetText(buf,10); /* */
x=atof(buf); /* */
EditEps->GetText(buf,10); /* */
eps=atof(buf); /* */
i = 1; /* */
yi1 = 1; /* */
ex = 1; /* */
do
{
yi = yi1 * x/i; /* */
ex = ex + yi; /* */
sprintf(buf,"%8.2f",yi); /* */
ListBoxYi->AddString(buf); /* yi*/
sprintf(buf,"%15.1f",ex); /* */
ListBoxExp->AddString(buf); /* ex*/
i = i + 1; /* */
yi1 = yi; /* */
}
while(fabs(yi) >= eps);
sprintf(buf,"%s %3d"," ",i); /* */
PoleIter->SetText(buf); /* */
sprintf(buf,"%s %12.2f"," ",ex); /* */
PoleExp->SetText(buf); /* */
}
12.5
1e-2
12.5
1e-4
12.5
1e-6
.
8.6.
|
|