cds2.calculus
Numerical differentiation - derivatives, complex-step gradients, Jacobians and Hessians.
Numerical differentiation: derivatives, Jacobians, Hessians, uncertainty.
ErrorPropagationResult
dataclass
First-order propagated output mean and covariance.
Source code in src/cds2/calculus.py
22 23 24 25 26 27 | |
propagate_error(f, x, cov, step=None)
Linearized (first-order) uncertainty propagation via the Jacobian.
For f: R^n -> R^m with input covariance cov (n x n), returns the
output mean f(x) and covariance J cov J^T.
Source code in src/cds2/calculus.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
derivative(f, x, method='central', step=None)
First derivative of a scalar function at x.
Methods: central (default, second-order accurate), forward,
backward.
Source code in src/cds2/calculus.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
complex_step_gradient(f, x)
Gradient via the complex-step trick - accurate to machine precision.
Requires f to propagate complex arithmetic (plain NumPy formulas do).
Source code in src/cds2/calculus.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
jacobian(f, x, step=None)
Finite-difference Jacobian of f: R^n -> R^m evaluated at x.
Source code in src/cds2/calculus.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
hessian(f, x, step=None)
Central-difference Hessian of a scalar field f: R^n -> R.
Source code in src/cds2/calculus.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |