Skip to main content

A small package for solving PDEs using numerical methods

Project description

Numerical PDE Solver

Overview

This package provides numerical solutions to Partial Differential Equations (PDEs) using Euler and Milstein methods, tailored for use in financial mathematics and other fields requiring the numerical solution of stochastic differential equations.

Installation

Install this package by running:

pip install numerical-pde-solver

##  Usage 

from numerical_pde_solver.euler import euler_method

# Define your drift and diffusion functions
def f(x, t):
    # Drift coefficient function
    return -x

def g(x, t):
    # Diffusion coefficient function
    return 0.1

# Initial condition, start time, end time, and step size
x0, t0, T, dt = 0, 0, 1, 0.01

# Solve the SDE
t, x = euler_method(f, g, x0, t0, T, dt)

# Now `t` holds the time points, and `x` holds the solution at those points
from numerical_pde_solver.milstein import milstein_method

# Define your drift and diffusion functions for the SDE
def f(x, t):
    # Drift coefficient function as a placeholder example
    return 0.05 * x

def g(x, t):
    # Diffusion coefficient function as a placeholder example
    return 0.2 * x

# Define the partial derivative of the diffusion function with respect to x
def dg(x, t):
    # For the diffusion term g(x, t) = 0.2 * x, the derivative with respect to x is 0.2
    return 0.2

# Initial condition, start time, end time, and step size
x0, t0, T, dt = 1, 0, 1, 0.01

# Solve the SDE using the Milstein method
t, x = milstein_method(f, g, dg, x0, t0, T, dt)

# t holds the array of time points, and x holds the array of solution values at those points

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numerical-pde-solver-0.1.4.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numerical_pde_solver-0.1.4-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file numerical-pde-solver-0.1.4.tar.gz.

File metadata

  • Download URL: numerical-pde-solver-0.1.4.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for numerical-pde-solver-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9422100df090aefc1a6b8f5cc9a33a7642a933005be67960ac5e8cabd6cb4075
MD5 cf525ab453d3dc7234d61174f04e9b8c
BLAKE2b-256 ecae2fb730b957e8fc0a81c2c438158151109d4117814396168ff613c192cc54

See more details on using hashes here.

File details

Details for the file numerical_pde_solver-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for numerical_pde_solver-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 52df0c97ee05a83d2a9b5dccd54cdec91d6e084bf4eb07ed2df1d119d3a4eea4
MD5 1886a232ab3a85971d8508e2917c5c6f
BLAKE2b-256 1e7ffe3f6dd8b66cb8d8132a1c6e81730a6053f270843a3d00eb4584a4196e5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page