using System; using System.Linq; using System.Collections.Generic; using System.Data; using System.Text; namespace Bisection_method { public static class Program { public static void Main() { //declaring an initial guesses double Xu = 1000; double Xl = 0; double error = 1; //naming the header of the functions Console.WriteLine("{0,25}{1,25}{2,25}{3,25}{4,25}{5,25}{6,25}{7,25}", "iter", "Xu", "Xl", "Xr", "F_Xu", "F_Xl", "F_Xr", "Error"); int i= 0; while (error>0.000000000000001) { double Xr = (Xu + Xl)/2; //taking old variable to another variable double Xr_old = Xr; double Xu_old = Xu; double Xl_old = Xl; //input the functions double F_Xu = ((2.5)/((120UL)*(50000)*(30000)*(600)))*((-5*(Xu*Xu*Xu*Xu)+6*(600*600)*(Xu*Xu))-(600UL*600*600*600)); double F_Xl = ((2.5)/((120UL)*(50000)*(30000)*(600)))*((-5*(Xl*Xl*Xl*Xl)+6*(600*600)*(Xl*Xl))-(600UL*600*600*600)); double F_Xr = ((2.5)/((120UL)*(50000)*(30000)*(600)))*((-5*(Xr*Xr*Xr*Xr)+6*(600*600)*(Xr*Xr))-(600UL*600*600*600)); //displaying the values Console.WriteLine("{0,25}{1,25}{2,25}{3,25}{4,25}{5,25}{6,25}{7,25}", i.ToString(), Xu.ToString(), Xl.ToString(), Xr.ToString(), F_Xu.ToString(), F_Xl.ToString(), F_Xr.ToString(), error.ToString()); //deciding a new Xu and Xl] if ((F_Xl*F_Xr)>0) {Xu = Xu_old; Xl = Xr;}; if ((F_Xl*F_Xr)<0) {Xu = Xr; Xl = Xl_old;}; //computing the new Xr Xr = (Xu + Xl)/2; //computing the error error = (Xr-Xr_old)/Xr; i++; } Console.WriteLine("the point of maximum deflection is " + Xl.ToString() + " with relative error of " + error.ToString()); } } }