public double Calculate() { double x1; double Xp = dane.GetXp(); double Xk = dane.GetXk(); double Precision = dane.GetPrecision(); do { x1 = (Xp + Xk) / 2; if (dane.getFunctionInPointX(x1) == 0) { return(x1); } if (dane.getFunctionInPointX(x1) * dane.getFunctionInPointX(Xp) < 0) { Xk = x1; } else if (dane.getFunctionInPointX(x1) * dane.getFunctionInPointX(Xk) < 0) { Xp = x1; } } while (Math.Abs(Xp - Xk) > Precision); return(Math.Round((Xp + Xk) / 2, Precision.ToString().Length - 2)); }
public double Calculate() { double wynik = 0.0; double h = (dane.GetXk() - dane.GetXp()) / dane.GetN(); for (double i = dane.GetXp(); i < dane.GetXk(); i += 2 * h) { wynik += (dane.getFunctionInPointX(i) + 4 * dane.getFunctionInPointX(i + h) + dane.getFunctionInPointX(i + 2 * h)) * (h / 3); } return(wynik); }
public double Calculate() { double wynik = 0; double Xk = dane.GetXk(); double Xp = dane.GetXp(); double dx = (Xk - Xp) / dane.GetN(); for (double i = Xp; i < Xk; i += dx) { wynik += (dane.getFunctionInPointX(i) + dane.getFunctionInPointX(i + dx)) * dx / 2.0; } return(wynik); }
public double Calculate() { double x1 = -1; double x2 = 1; double Precision = dane.GetPrecision(); do { x1 = x2; x2 = x1 - dane.getFunctionInPointX(x1) / dane.getDerivativeInPoint(x1); if (Math.Abs(x2 - x1) <= Precision) { break; } if (Math.Abs(dane.getFunctionInPointX(x1)) <= Precision) { break; } } while (true); return(Math.Round(x2, 0)); }
public double Calculate() { double wynik = 0; double Xk = dane.GetXk(); double Xp = dane.GetXp(); double dx = (Xk - Xp) / dane.GetN(); for (double i = (Xp + dx); i <= Xk; i += dx) { wynik += dane.getFunctionInPointX(i); } return(dx * wynik); }
public double Calculate() { Random rnd = new Random(); double fSrednie = 0.0; double Xp = dane.GetXp(); double Xk = dane.GetXk(); double N = dane.GetN(); for (int i = 0; i < N; i++) { double wylosowano = rnd.NextDouble() * (Xk - Xp) + Xp; fSrednie += dane.getFunctionInPointX(wylosowano) / N; } return(fSrednie * Math.Abs(Xk - Xp)); }