{"id":4966,"library":"jacobi","title":"Jacobi: Numerical Derivatives","description":"Jacobi is a lightweight Python library designed for fast and robust computation of generalized Jacobi matrices (numerical derivatives) for arbitrary real analytic mappings. It supports functions with large round-off errors and offers significant speed improvements over other numerical differentiation tools. The current version is 0.9.2, and it typically releases updates as needed.","status":"active","version":"0.9.2","language":"python","source_language":"en","source_url":"https://github.com/HDembinski/jacobi","tags":["numerical derivatives","jacobian","error propagation","scientific computing","numpy"],"install":[{"cmd":"pip install jacobi","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for numerical operations and array manipulation.","package":"numpy","optional":false}],"imports":[{"symbol":"jacobi","correct":"from jacobi import jacobi"},{"note":"Used for statistical error propagation based on numerically computed Jacobians.","symbol":"propagate","correct":"from jacobi import propagate"}],"quickstart":{"code":"import numpy as np\nfrom jacobi import jacobi\n\ndef my_function(x):\n    return np.array([np.sin(x[0]) * x[1], np.exp(x[0] + x[1])])\n\n# Point at which to compute the Jacobian\nx0 = np.array([1.0, 2.0])\n\n# Compute the Jacobian matrix and its error estimate\njacobian_matrix, error_estimate = jacobi(my_function, x0)\n\nprint(f\"Function: f(x) = [sin(x[0]) * x[1], exp(x[0] + x[1])]\")\nprint(f\"Point x0: {x0}\")\nprint(f\"Computed Jacobian matrix:\\n{jacobian_matrix}\")\nprint(f\"Error estimate for Jacobian:\\n{error_estimate}\")\n\n# Example with a function returning a scalar and an auxiliary argument\ndef scalar_func(param, x):\n    return np.sin(x * param)\n\naux_param = 0.5\nx_scalar = np.array([np.pi / 2])\nscalar_derivative, scalar_error = jacobi(scalar_func, aux_param, x_scalar)\n\nprint(f\"\\nFunction: g(param, x) = sin(x * param) where param={aux_param}\")\nprint(f\"Point x_scalar: {x_scalar}\")\nprint(f\"Derivative w.r.t. param: {scalar_derivative}\")\nprint(f\"Error estimate: {scalar_error}\")","lang":"python","description":"This quickstart demonstrates how to compute the generalized Jacobi matrix for a vector-valued function and a scalar-valued function with an auxiliary argument using `jacobi.jacobi`. It returns both the derivative and its error estimate."},"warnings":[{"fix":"Verify the mathematical properties of the function being differentiated. For highly non-smooth functions, other techniques like automatic differentiation (if applicable) or specialized numerical methods might be more appropriate.","message":"The `jacobi` function is designed for real analytic mappings. While robust, its accuracy can be affected by highly non-smooth or non-analytic functions. Ensure the function you are differentiating is suitable for numerical differentiation methods.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For functions `f(x)` where `f[i]` only depends on `x[i]`, pass `diagonal=True` as an argument to `jacobi(f, x, diagonal=True)` to optimize performance.","message":"When differentiating a function that returns a 1D array where the Jacobian is known to be diagonal (e.g., an element-wise operation), passing `diagonal=True` to the `jacobi` function can significantly speed up computation. Omitting this for such cases will still yield correct results but might be less efficient.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Where possible, define the function to be differentiated using vectorized `numpy` operations to maximize performance.","message":"The `jacobi` library relies on `numpy` for its numerical operations. Performance can be influenced by how efficiently `numpy` handles the function being differentiated. Vectorized functions tend to perform better.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.9.2':50 'analyt':25 'arbitrari':23 'comput':15,64 'current':47 'deriv':3,21,59 'design':10 'differenti':44 'error':35,61 'fast':12 'function':29 'general':17 'improv':40 'jacobi':1,4,18 'jacobian':60 'larg':31 'librari':9 'lightweight':7 'map':26 'matric':19 'need':57 'numer':2,20,43,58 'numpi':65 'offer':37 'propag':62 'python':8 'real':24 'releas':54 'robust':14 'round':33 'round-off':32 'scientif':63 'signific':38 'speed':39 'support':28 'tool':45 'typic':53 'updat':55 'version':48","created_at":"2026-04-12T16:48:19.731463+00:00","updated_at":"2026-04-16T15:49:58.726225+00:00","problems":[{"fix":"Install the library using pip: `pip install jacobi`","cause":"The 'jacobi' library has not been installed in the Python environment, or the environment where it was installed is not active.","error":"ModuleNotFoundError: No module named 'jacobi'"},{"fix":"The main function for computing the Jacobian is often directly available after import, but if not, ensure the correct function name and import path is used, e.g., `from jacobi import jacobian` or if it's within a specific submodule, `from jacobi.api import jacobian` (adjusting 'api' to the actual submodule if necessary, but 'jacobian' is typically top-level for this library).","cause":"This error typically occurs if a user tries to access a function directly from the top-level 'jacobi' module that is actually nested within a submodule, or if the function name is misspelled.","error":"AttributeError: module 'jacobi' has no attribute 'jacobian'"},{"fix":"Ensure that function arguments are of the correct type and shape as expected by the `jacobi` function. For instance, if a scalar is expected for `x0`, pass `x0=1.0` instead of `x0=np.array([1.0])`.","cause":"This error often arises when a numerical function within 'jacobi' (or its underlying numpy operations) expects a scalar input (like `x0` or step size), but receives a NumPy array, or vice-versa, indicating a mismatch in expected input types for numerical operations.","error":"TypeError: 'numpy.ndarray' object cannot be interpreted as an integer"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.9.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/hdembinski/jacobi","docs":"https://hdembinski.github.io/jacobi/","changelog":null,"pypi":"https://pypi.org/project/jacobi/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}