mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 03:53:41 +02:00
roots docstring reworked
This commit is contained in:
parent
509b7bb73f
commit
9bd438fa06
1 changed files with 19 additions and 8 deletions
|
@ -1,20 +1,31 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# coding: utf-8
|
|
||||||
|
|
||||||
import scipy.optimize
|
import scipy.optimize
|
||||||
from autograd import jacobian
|
from autograd import jacobian
|
||||||
from .obs import derived_observable, pseudo_Obs
|
from .obs import derived_observable, pseudo_Obs
|
||||||
|
|
||||||
|
|
||||||
def find_root(d, func, guess=1.0, **kwargs):
|
def find_root(d, func, guess=1.0, **kwargs):
|
||||||
"""Finds the root of the function func(x, d) where d is an Obs.
|
r'''Finds the root of the function func(x, d) where d is an `Obs`.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
-----------------
|
-----------------
|
||||||
d -- Obs passed to the function.
|
d : Obs
|
||||||
func -- Function to be minimized. Any numpy functions have to use the autograd.numpy wrapper
|
Obs passed to the function.
|
||||||
guess -- Initial guess for the minimization.
|
func : object
|
||||||
"""
|
Function to be minimized. Any numpy functions have to use the autograd.numpy wrapper.
|
||||||
|
Example:
|
||||||
|
```python
|
||||||
|
import autograd.numpy as anp
|
||||||
|
def root_func(x, d):
|
||||||
|
return anp.exp(-x ** 2) - d
|
||||||
|
```
|
||||||
|
guess : float
|
||||||
|
Initial guess for the minimization.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
Obs
|
||||||
|
`Obs` valued root of the function.
|
||||||
|
'''
|
||||||
root = scipy.optimize.fsolve(func, guess, d.value)
|
root = scipy.optimize.fsolve(func, guess, d.value)
|
||||||
|
|
||||||
# Error propagation as detailed in arXiv:1809.01289
|
# Error propagation as detailed in arXiv:1809.01289
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue