private void GetRungeKytSolves(Function func, InputData data, out List<double> x, out List<double> y) { double curX = data.X0; double curY = data.Y0; double h = data.H; x = new List<double>(); y = new List<double>(); while (Math.Round(curX, 10) <= data.RightLimit + h) { y.Add(curY); x.Add(curX); double K1 = h * func.GetSolve(curX, curY); double K2 = h * func.GetSolve(curX + h / 2, curY + K1 / 2); double K3 = h * func.GetSolve(curX + h / 2, curY + K2 / 2); double K4 = h * func.GetSolve(curX + h, curY + K3); curY = curY+1f/6f*(K1+2*K2+2*K3+K4); curX += data.H; } }
private void GetEulerMSolves(Function func, InputData data, out List<double> x, out List<double> y) { double curX = data.X0; double curY = data.Y0; x = new List<double>(); y = new List<double>(); while (Math.Round(curX, 10) <= data.RightLimit + data.H) { x.Add(curX); y.Add(curY); curY = curY + data.H * func.GetSolve(curX+data.H/2, curY+(data.H/2)*func.GetSolve(curX,curY)); curX += data.H; } }
private void GetEulerSolves(Function func, InputData data, out List<double> x, out List<double> y) { double curX = data.X0; double curY = data.Y0; x = new List<double>(); y = new List<double>(); while (Math.Round(curX, 10) <= data.RightLimit + data.H) { y.Add(curY); x.Add(curX); curY = y[y.Count - 1] + data.H * func.GetSolve(x[x.Count - 1], y[y.Count - 1]); curX += data.H; } }
private void GetAdamsSolves(Function func, InputData data, out List<double> x, out List<double> y) { double curX = data.X0; double curY = data.Y0; x = new List<double>(); y = new List<double>(); x.Add(curX); y.Add(curY); double curPrevY = curY; double curPrevX = curX; double h = Math.Pow(data.H,2); //Calculate next y and x double K1 = h * func.GetSolve(curX, curY); double K2 = h * func.GetSolve(curX + h / 2, curY + K1 / 2); double K3 = h * func.GetSolve(curX + h / 2, curY + K2 / 2); double K4 = h * func.GetSolve(curX + h, curY + K3); curY = curY + 1f / 6f * (K1 + 2 * K2 + 2 * K3 + K4); curX += h; //-------------------------------- h = data.H; while (Math.Round(curX, 10) <= data.RightLimit+h) { x.Add(curX); y.Add(curY); curY = curY + h * ((3f / 2) * func.GetSolve(curX, curY) - 0.5 * func.GetSolve(curPrevX, curPrevY)); curX += h; curPrevX = x[x.Count-1]; curPrevY = y[y.Count-1]; } }