## Error propagation through a function

Version 1.01 (8.29 KB) by
Calculates the error propagation through a function NEEDS : Symbolic Math Toolbox
Updated 28 Oct 2022

The function takes 4 entries :
1) The function f written with symbolic variables
2) A 1*n matrix of the symbolic variables of the function
3) A 1*n matrix of the values of the variables to evaluate the function at (IMPORTANT : must be in the same order as the variables in 2))
4) A 1*n matrix of the values of the errors of the variables at the point given in 3) (IMPORTANT : must be in the same order as the variables in 2))
It then returns a 1*3 matrix containing the value of the function at this point in the first cell, the absolute error in the second cell and the relative error in the third one (in percentage!!)
See an example below :
syms A B C % We define the symbolic variables
f = 3*A*exp(B-C^2); % We define the function we are looking to propagate the error through
varlist = [A B C]; % The list of variables
vals = [2 4 0.1]; % The list of the values of the variables to evaluate the function at
errs = [0.2 0.1 0.001]; % The errors of the variables at this point
F_and_errors = propagErreur(f, varlist, vals, errs); % Calls the function to evaluate the function at the given point and propagate the error

### Cite As

Adam Avedissian (2024). Error propagation through a function (https://www.mathworks.com/matlabcentral/fileexchange/119653-error-propagation-through-a-function), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2022a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux