MyNixOS website logo
Description

Functions Used in the Book "Computational Physics with R".

Provides a collection of functions described and used in the book Foadi (2026, ISBN:9780750326308) "Computational Physics with R". These include routines for numerical differentiation, integration, differential equations, eigenvalue problems, Monte Carlo methods, and other algorithms relevant to computational physics.

comphy is an R package accompanying the book This package accompanies the book
Computational Physics with R. It collects all the functions described and used throughout the book, providing ready-to-use implementations of numerical algorithms in computational physics.

The package includes routines for:

  • Numerical differentiation and integration

  • Solvers for ordinary differential equations

  • Sturm–Liouville eigenvalue problems

  • Monte Carlo methods

  • Other algorithms relevant to physics and applied mathematics

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("jfoadi/comphy")

Example

This is a simple example where a numerical derivative of sin(x) is computed using comphy:

library(comphy)

# Grid of known values
x <- seq(0,pi,length.out=11)

# Grid of values at which derivative must be calculated
# Same as x
x0 <- x

# Function known at tabulated points
f <- sin(x)+cos(x)

# Obtain a numerical derivative at those points
# using central differences (discard first and last value)
df <- deriv_reg(x0,x,f)

# Print derivative values
print(df)
#>  [1]         NA  0.6315304  0.2176105 -0.2176105 -0.6315304 -0.9836316
#>  [7] -1.2394482 -1.3739389 -1.3739389 -1.2394482         NA

The two NA’s are there because the derivative is calculated using a centred difference.

Documentation

All exported functions include documentation and usage examples. For a comprehensive discussion and context, see the book Computational Physics with R.

License

GPL (>= 2)

Metadata

Version

1.0.5

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows