public BinaryTree CreateMcLaurinAn(string value, int n) { root = null; Node root1 = this.CreateBinaryTree(root, ref value); digits d = new digits(root1.Calculations(0).ToString()); _ fac = new _(new digits("0")); digits d1 = new digits(fac.Calculations(0).ToString()); division div = new division(d, d1); power pow = new power(new variables("x"), new digits("0")); multi m = new multi(div, pow); root = m; for (int i = 1; i <= n; i++) { root1 = root1.Derivative(); digits dd = new digits(root1.Calculations(0).ToString()); _ fac1 = new _(new digits($"{i}")); digits dd1 = new digits(fac1.Calculations(0).ToString()); division div1 = new division(dd, dd1); power pow1 = new power(new variables("x"), new digits($"{i}")); multi m1 = new multi(div1, pow1); plus p = new plus(root, m1); root = p; } return(this); }
public BinaryTree CreateMcLaurinPlotN(string v, int n) { double[] functions = new double[n + 1]; int power = 0; root = null; Node root1 = this.CreateBinaryTree(root, ref v); while (power <= n) { double result = 0; int[] coef = this.coef(power); int powerindex = power; for (int i = 0; i <= power; i++) { result = result + coef[i] * root1.Calculations(powerindex * this.almostzero); powerindex--; } if (power == 0) { functions[power] = result; digits d = new digits(result.ToString()); _ fac = new _(new digits("0")); digits d1 = new digits(fac.Calculations(0).ToString()); division div = new division(d, d1); power pow = new power(new variables("x"), new digits("0")); multi m = new multi(div, pow); root = m; } else { functions[power] = result / Math.Pow(this.almostzero, power); digits dd = new digits(Math.Round(functions[power], 2).ToString()); _ fac1 = new _(new digits($"{power}")); digits dd1 = new digits(fac1.Calculations(0).ToString()); division div1 = new division(dd, dd1); power pow1 = new power(new variables("x"), new digits($"{power}")); multi m1 = new multi(div1, pow1); plus p = new plus(root, m1); root = p; } power++; } //double d = root.Calculations(x + this.almostzero); //double d1 = root.Calculations(x); //double d2 = (d - d1); //double d3 = d2 / this.almostzero; return(this); }