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;
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}