public static void BaseCode() { double eps = 1.0E-12; StreamWriter sw = new StreamWriter("MAC_LabWork_1_5.txt"); MyTF T_Fx = new MyTF(0.0, 15.0, 500, Fx, "Fx"); T_Fx.Roots_correction(eps); sw.Write(T_Fx.Table_of_Roots("- Dichotomy -")); int K, M = T_Fx.Roots.Count; double xa, xb, xr = double.NaN; sw.WriteLine("\r\n Table of zeros, that counted by shema (1.5.1):"); for (int j = 0; j < M; j++) { xa = T_Fx.Roots[j].XL; xb = T_Fx.Roots[j].XR; xr = Eq.Tangent(Fx, D1F, D2F, xa, xb, eps, out K); sw.WriteLine($"{j,3}{xr,17:F12}{Math.Abs(Fx(xr)),10:E1}{K,3}"); } sw.WriteLine("\r\n Table of zeros, that counted by shema (1.5.2):"); for (int j = 0; j < M; j++) { xa = T_Fx.Roots[j].XL; xb = T_Fx.Roots[j].XR; xr = Eq.Tangent(Fx, xa, xb, eps, out K); sw.WriteLine($"{j,3}{xr,17:F12}{Math.Abs(Fx(xr)),10:E1}{K,3}"); } sw.Close(); }
static void Test_LW_14_1() { int k = 0; double root = CLE.Dichotomy(0.3, 0.6, 1.0E-12, Cos_pi_x, ref k); string res = $"x = {root,18:F15} err = {Cos_pi_x(root),7:E1} K = {k}"; Console.WriteLine(res); Console.WriteLine(res); }
public static void HomeCode(double x0, double xn, int n) { double eps = 1.0E-12; StreamWriter sw = new StreamWriter("MAC_LabWork_1_5_home.txt"); MyTF T_Fx = new MyTF(x0, xn, n, My_Fx, "Fx"); T_Fx.Roots_correction(eps); int K, M = T_Fx.Roots.Count; double xa, xb, xr = double.NaN; sw.WriteLine("\r\n Table of zeros, that counted by shema (1.5.1):"); for (int j = 0; j < M; j++) { xa = T_Fx.Roots[j].XL; xb = T_Fx.Roots[j].XR; xr = Eq.Tangent(My_Fx, My_D1F, My_D2F, xa, xb, eps, out K); sw.WriteLine($"{j,3}{xr,17:F10}{Math.Abs(Fx(xr)),10:E1}{K,3}{My_D1F(xr),17:F10}{My_D2F(xr),17:F10}"); } sw.Close(); }