#include<stdio.h> #include<conio.h> #include<math.h> float l; float fun(float x) { return((-5*x*x*x*x+6*l*l*x*x-l*l*l*l)); } int main() { float a,b,eps,w,j,e,y,x; int i=0; printf("\n enter the intensity of Traingular load \n" ); scanf("%f",&w); printf("\n enter the moment of inertia \n" ); scanf("%f",&j); printf("\n enter the modulus of elsticty \n" ); scanf("%f",&e); printf("\n enter the length of the beam \n" ); scanf("%f",&l); printf("\n enter the lower and upper limit \n" ); scanf("%f""%f",&a,&b); printf("\n enter the epsilon value"); scanf("%f",&eps); if((fun(a)*fun(b))>0) printf("\n starting value is unsuitable "); else while(fabs((b-a)/b)>eps) { x=(a+b)/2; i++; if((fun(x)*fun(a))>0) a=x; else b=x; } printf("\n solution converges to a root \n"); printf("\n number of iterationo=%d\n",i); printf("%f\n",x); y=(w/(120*e*j*l))*(-x*x*x*x*x+2*l*l*x*x*x-l*l*l*l*x); printf("\n maximum deflection \n"); printf("%f\n",y); getch(); }
2.Using false position method
#include<stdio.h> #include<conio.h> #include<math.h> float l; float fun(float x) { return((-5*x*x*x*x+6*l*l*x*x-l*l*l*l)); } int main() { float a,b,eps,w,j,e,y,x; int i=0; printf("\n enter the intensity of Traingular load \n" ); scanf("%f",&w); printf("\n enter the moment of inertia \n" ); scanf("%f",&j); printf("\n enter the modulus of elsticty \n" ); scanf("%f",&e); printf("\n enter the length of the beam \n" ); scanf("%f",&l); printf("\n enter the lower and upper limit \n" ); scanf("%f""%f",&a,&b); printf("\n enter the epsilon value \n"); scanf("%f",&eps); if((fun(a)*fun(b))>0) printf("\n starting value is unsuitable "); else while(fabs((b-a)/b)>eps) {
x=(((a*fun(b))-(b*fun(a)))/(fun(b)-fun(a))); i++; if((fun(x)*fun(a))>0) a=x; else b=x; } printf("\n solution converges to a root \n"); printf("\n number of iterationo=%d\n",i); printf("%f\n",x); y=(w/(120*e*j*l))*(-x*x*x*x*x+2*l*l*x*x*x-l*l*l*l*x); printf("\n maximum deflection \n"); printf("%f\n",y); getch(); } 3. Simple point Iteration
#include<stdio.h> #include<conio.h> #include<math.h> float l; float fun(float x) { return(sqrt(((5*x*x*x*x)+(l*l*l*l))/(6*l*l))); } int main() { float a,b,eps,w,j,e,y,x; int i=0; printf("\n enter the intensity of Traingular load \n" ); scanf("%f",&w); printf("\n enter the moment of inertia \n" ); scanf("%f",&j); printf("\n enter the modulus of elsticty \n" ); scanf("%f",&e); printf("\n enter the length of the beam \n" ); scanf("%f",&l); printf("\n enter the a value \n" ); scanf("%f",&a); printf("\n enter the epsilon value"); scanf("%f",&eps); b=fun(a); while(fabs((b-a)/b)>eps) { a=b; x=fun(a); i++; b=x; } printf("\n solution converges to a root \n"); printf("\n number of iterationo=%d\n",i); printf("%f\n",x); y=(w/(120*e*j*l))*(-x*x*x*x*x+2*l*l*x*x*x-l*l*l*l*x); printf("\n maximum deflection \n"); printf("%f\n",y); getch(); }
4.Newton Raphsons mthod
#include<stdio.h> #include<conio.h> #include<math.h> float l; float func(float x) { return(-5*x*x*x*x+6*l*l*x*x-l*l*l*l); } float func1(float x) { return(-20*x*x*x+12*l*l*x); } main() { float a,w,j,e,eps,x1,x2,y; int i=1; float func(float); float func1(float); printf("\n enter the intensity of Traingular load \n" ); scanf("%f",&w); printf("\n enter the moment of inertia \n" ); scanf("%f",&j); printf("\n enter the modulus of elsticty \n" ); scanf("%f",&e); printf("\n enter the length of the beam \n" ); scanf("%f",&l); printf("\n enter the initial value \n"); scanf("%f",&a); printf("\n enter the epsilon value \n"); scanf("%f",&eps); x1=a; x2=x1-(func(x1)/func1(x1)); while(((x2-x1)/x1)>eps) { x1=x2; x2=x1-(func(x1)/func1(x1)); i++; } printf("\n the root is %f converge is %d approximately",x2,i); y=(w/(120*e*j*l))*(-x2*x2*x2*x2*x2+2*l*l*x2*x2*x2-l*l*l*l*x2); printf("\n maximum deflection \n"); getch(); }