polykin.math.derivatives¤
jacobian ¤
jacobian(
f: Callable[[FloatVector], FloatVector],
x: FloatVector,
fx: FloatVector | None = None,
sx: FloatVector | None = None,
) -> FloatMatrix
Calculate the numerical Jacobian of a vector function \(\mathbf{f}(\mathbf{x})\) using the forward finite-difference scheme.
PARAMETER | DESCRIPTION |
---|---|
f
|
Function to be diferentiated.
TYPE:
|
x
|
Differentiation point.
TYPE:
|
fx
|
Function values at
TYPE:
|
sx
|
Scaling factors for
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
FloatMatrix
|
Jacobian matrix. |
Examples:
Evaluate the numerical jacobian of f(x)=(x1**2)*(x2**3) at (2.0, -2.0).
>>> from polykin.math import jacobian
>>> import numpy as np
>>> def fnc(x): return x[0]**2 * x[1]**3
>>> jacobian(fnc, np.array([2.0, -2.0]))
array([[-32.00000024, 47.99999928]])
Source code in src/polykin/math/derivatives/ndiff.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|