private void startBis() { foreach (double[] limit in limits) { double val1 = 0; double val2 = 0; double c = 0; int counter = 0; do { val1 = eq.Calculate(limit[0]); val2 = eq.Calculate(limit[1]); c = eq.Calculate((limit[1] + limit[0]) / 2); if (MoreThenZero(c) != MoreThenZero(val1)) { limit[1] = (limit[1] + limit[0]) / 2; } else { limit[0] = (limit[1] + limit[0]) / 2; } counter++; } while (Math.Abs(limit[1] - limit[0]) >= e); xVal.Add((limit[1] + limit[0]) / 2); xVal.Add(counter); } Print.print_x(xVal, "Bisection"); }
public void start() { double x0 = 0; double xi = 0; int counter = 0; foreach (double[] limit in eq.limits) { counter = 0; xi = findX(limit[0], limit[1]); if (x0 != -9999) { do { x0 = xi; xi = x0 - (eq.Calculate(x0)) / eq.FirstPr(x0); counter++; } while (Math.Abs((eq.Calculate(x0)) / eq.FirstPr(x0)) >= eq.e); eq.xVal.Add(xi); eq.xVal.Add(counter); } } Print.print_x(eq.xVal, "Newtone"); }
private bool Mult(double val) { double f = eq.Calculate(val); double p = eq.SecondPr(val); if (f * p < 0) { return(false); } else { return(true); } }