Skip to main content

useful-math-functions for Optimization, Benchmarking, Visualizing, and more ...

Project description

DOI PyPI

useful-math-functions

useful-math-functions is a collection of useful mathematical functions with a focus on:

  1. ease of use - the functions are designed to be as easy to use as possible
  2. pure python - the functions are written in much python as possible and only use external libraries when necessary
  3. documentation - the functions are documented in code itself with:
    1. Examples
    2. Equations
    3. References
    4. Links to external resources

Installation

The package can be installed via pip:

pip install useful-math-functions

PyPI: useful-math-functions on PyPI

and for Visualizations:

# matplotlib
pip install useful-math-functions[matplotlib]

# plotly
pip install useful-math-functions[plotly]

# all visualizations
pip install useful-math-functions[all]

Usage

The package can be imported like any other python package:

from umf.core.create import OptBench
res = OptBench(["DeJongN5Function"], dim=3)
res.plot_type_3d = "plot_surface"
res.plot()
res.save_as_image()

_

To use the newly added functions:

from umf.functions.optimization.special import HimmelblauFunction
import numpy as np

x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)
Z = HimmelblauFunction(X, Y).__eval__

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
ax.plot_surface(X, Y, Z, cmap="viridis")
plt.savefig("HimmelblauFunction.png", dpi=300, transparent=True)
from umf.functions.optimization.valley_shaped import Rosenbrock2DFunction
import numpy as np

x = np.linspace(-2, 2, 100)
y = np.linspace(-1, 3, 100)
X, Y = np.meshgrid(x, y)
Z = RosenbrockFunction(X, Y).__eval__

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
ax.plot_surface(X, Y, Z, cmap="viridis")
plt.savefig("RosenbrockFunction.png", dpi=300, transparent=True)

Documentation

The documentation can be found here.

Contributing

Contributions are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

The project is licensed under the MIT license.

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

useful_math_functions-0.5.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

useful_math_functions-0.5.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file useful_math_functions-0.5.0.tar.gz.

File metadata

  • Download URL: useful_math_functions-0.5.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for useful_math_functions-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8101ec893b1a0b546f48c0d683def9e961a28eebec87fe2fc6624dba3bfa5c03
MD5 c29dab43ff9f091f31d7018c56d27c9d
BLAKE2b-256 aa3c3f2a5e599e6fa1b33cf3ed4cba6b0f4310f3c35e05eb218f0d4909e1d0f8

See more details on using hashes here.

File details

Details for the file useful_math_functions-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for useful_math_functions-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 415cb826665eab3e5f93c3998081936dacd1cd1c65c48de68eacd2295bdd8879
MD5 17f54868ece5e9acba5dba6d3d1ebd56
BLAKE2b-256 a5bc157413a7275cc38ba0b28374cc1308074df4994a87557788b48af3471f78

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