Error propagation through a function

Calculates the error propagation through a function NEEDS : Symbolic Math Toolbox
20 Downloads
Updated 28 Oct 2022

View License

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
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.01

Changed slight error in the description

1.0