Skip to content

v1.3.0

Latest
Compare
Choose a tag to compare
@MilesCranmer MilesCranmer released this 15 Dec 04:58
· 1 commit to master since this release
5c0f26a

What's Changed

  • Expanded support for differential operators via backend 1.5.0 by @MilesCranmer in #782

e.g., say we wish to integrate $\frac{1}{x^2 \sqrt{x^2 - 1}}$ for $x > 1$:

import numpy as np
from pysr import PySRRegressor, TemplateExpressionSpec

x = np.random.uniform(1, 10, (1000,))  # Integrand sampling points
y = 1 / (x**2 * np.sqrt(x**2 - 1))     # Evaluation of the integrand

expression_spec = TemplateExpressionSpec(
    ["f"], "((; f), (x,)) -> D(f, 1)(x)"
)

model = PySRRegressor(
    binary_operators=["+", "-", "*", "/"],
    unary_operators=["sqrt"],
    expression_spec=expression_spec,
    maxsize=20,
)
model.fit(x[:, np.newaxis], y)

which should correctly find $\frac{\sqrt{x^2 - 1}}{x}$.

Full Changelog: v1.2.0...v1.3.0