-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler_implicit.c
More file actions
71 lines (58 loc) · 1.36 KB
/
euler_implicit.c
File metadata and controls
71 lines (58 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <stdlib.h>
float m(float x,float y)
{
return(-1000*(y-(x+2))+1);
}
int main()
{
float x_init,y_init;
printf("Enter the value y_init \n");
scanf("%f",&y_init);
printf("Enter the value of x_init\n");
scanf("%f",&x_init);
int n;
int n1;
printf("Enter the number of values of h\n");
scanf("%d",&n1);
printf("Enter the value of h\n");
float h[n1];
int j;
for(j=0;j<n1;j++)
{
scanf("%f",&h[j]);
}
//printf(" X_INIT %f|| Y_INIT %f\n",x_init,y_init);
printf("\nH are :\n");
for(j=0;j<n1;j++)
{
printf("%f \n",h[j]);
}
int i;
float x,y,f,a,b;
for(j=0;j<n1;j++)
{
printf("\n\n\n######For h==%f\n",h[j]);
a=x_init;
b=y_init;
float k=(0.01)/h[j];
n=k;
printf(" X_INIT %f|| Y_INIT %f\n",x_init,y_init);
printf("A %f B %f\n",a,b);
f=m(a,b);
// printf("Function %f\n",f);
printf("the number of iteration %d\n",n);
for(i=0;i<n;i++)
{ // printf("Iteration %d\n",i);
f=m(a,b);
//printf("Function %f\n",f);
y=(b+1000*h[j]*(x_init+(i+1)*h[j]+2)+h[j])/(1000*h[j]+1);
x=a+h[j];
//printf("Y %f||X %f\n",y,x);
a=x;
b=y;
}
printf("Y %f||X %f\n",y,x);
}
return 0;
}