import
java.util.*;
class
GFG {
static
double
Y1(
double
x)
{
return
(
1
+ (x) + Math.pow(x,
2
) /
2
);
}
static
double
Y2(
double
x)
{
return
(
1
+ (x) + Math.pow(x,
2
) /
2
+ Math.pow(x,
3
) /
3
+ Math.pow(x,
4
) /
8
);
}
static
double
Y3(
double
x)
{
return
1
+ (x) + Math.pow(x,
2
) /
2
+ Math.pow(x,
3
) /
3
+ Math.pow(x,
4
) /
8
+ Math.pow(x,
5
) /
15
+ Math.pow(x,
6
) /
48
;
}
public
static
void
main(String[] args)
{
double
start_value =
0
, end_value =
3
,
allowed_error =
0.4
, temp;
double
y1[] =
new
double
[
30
];
double
y2[] =
new
double
[
30
];
double
y3[] =
new
double
[
30
];
int
count;
for
(temp = start_value, count =
0
;
temp <= end_value;
temp = temp + allowed_error, count++) {
y1[count] = Y1(temp);
y2[count] = Y2(temp);
y3[count] = Y3(temp);
}
System.out.printf(
"\nX\n"
);
for
(temp = start_value; temp <= end_value;
temp = temp + allowed_error) {
System.out.printf(
"%.4f "
, temp);
}
System.out.printf(
"\n\nY(1)\n"
);
for
(temp = start_value, count =
0
;
temp <= end_value;
temp = temp + allowed_error, count++) {
System.out.printf(
"%.4f "
, y1[count]);
}
System.out.printf(
"\n\nY(2)\n"
);
for
(temp = start_value, count =
0
;
temp <= end_value;
temp = temp + allowed_error, count++) {
System.out.printf(
"%.4f "
, y2[count]);
}
System.out.printf(
"\n\nY(3)\n"
);
for
(temp = start_value, count =
0
;
temp <= end_value;
temp = temp + allowed_error, count++) {
System.out.printf(
"%.4f "
, y3[count]);
}
}
}