public class SecondMethod { protected double a, b, epsilon, n_iteration, c, count = 1; protected Form2 form; protected Argument x_epresion; protected Expression e; string expression; public SecondMethod(string expression, Form2 form, double a, double b, double epsilon) { this.a = a; this.b = b; this.epsilon = epsilon; this.expression = expression; this.form = form; } public double f(double x) { x_epresion = new Argument("x",x); e = new Expression(expression, x_epresion); // this.form.textBox3.AppendText("UWAGA pochodna wynosi"+ directive(1)); return e.calculate(); } double directive(double f_value) { Argument x_epresion = new Argument("x", f_value); string a = "der(" + e.getExpressionString() + ", x)"; Function f = new Function("f(x) = " + a); e = new Expression("f(" + f_value.ToString() + ")", f); e = new Expression(a, x_epresion); return e.calculate(); } public virtual double search() { do { if (f(a) == f(b)) { return -1; } c = (a * f(b) - b * f(a)) / (f(b) - f(a)); this.form.textBox3.AppendText("pochodna wynosi " + f(c).ToString()); a = b; b = c; var napis = String.Format("Iteration {0} x={1}\n", count, c, 2); this.form.textBox2.AppendText(napis); count++; if (count == 100) { return c; } } while (Math.Abs(f(c)) > epsilon); return c; } }