numerical_methods.integration package

Submodules

numerical_methods.integration.euler_methods module

numerical_methods.integration.euler_methods.euler_method(f, x_end, x0, y0, h, n, f_exact)[source]

Solve a differential equation using the Euler method.

Parameters:
  • f (Callable) – The function f(x, y) representing dy/dx.

  • x_end (float) – The endpoint of the interval.

  • x0 (float) – The initial x value.

  • y0 (float) – The initial y value.

  • h (float) – Step size (will be recomputed from x0 to x_end and n).

  • n (int) – Number of steps.

  • f_exact (Callable) – The exact solution function for comparison.

Return type:

None

numerical_methods.integration.euler_methods.modified_euler(f, x_end, x0, y0, h, n, f_exact)[source]

Solve a differential equation using Modified Euler (RK2) method.

Parameters:
  • f (Callable) – Function f(x, y).

  • x_end (float) – End x value.

  • x0 (float) – Initial x.

  • y0 (float) – Initial y.

  • h (float) – Step size.

  • n (int) – Number of steps.

  • f_exact (Callable) – Exact solution.

Returns:

Final y value.

Return type:

float

numerical_methods.integration.midpoint_method module

numerical_methods.integration.midpoint_method.midpoint_method(f, x_end, x0, y0, h, n, f_exact)[source]

Solve a differential equation using Midpoint method (RK2).

Parameters:
  • f (Callable) – Function f(x, y).

  • x_end (float) – Final x value.

  • x0 (float) – Initial x value.

  • y0 (float) – Initial y value.

  • h (float) – Step size.

  • n (int) – Number of steps.

  • f_exact (Callable) – Exact solution.

Returns:

Final y value at x_end.

Return type:

float

numerical_methods.integration.runge_kutta_methods module

numerical_methods.integration.taylor_method module

numerical_methods.integration.taylor_method.taylor_method(f, x_end, x0, y0, h, n, df_dx, df_dy, f_exact)[source]

Solve a differential equation using Taylor method (2nd order).

Parameters:
  • f (Callable) – Function f(x, y).

  • x_end (float) – Endpoint of the integration interval.

  • x0 (float) – Initial x.

  • y0 (float) – Initial y.

  • h (float) – Step size (recalculated from interval).

  • n (int) – Number of steps.

  • df_dx (Callable) – Partial derivative of f with respect to x.

  • df_dy (Callable) – Partial derivative of f with respect to y.

  • f_exact (Callable) – Exact solution for comparison.

Return type:

None

Module contents