Skip to main content
1-Visitor
February 18, 2014
Question

How do I define custom derivation rules for calculating error marigin in formula?

  • February 18, 2014
  • 2 replies
  • 4050 views

I am new to mathcad and I was searching for a function to calculate the amount of error (relative/absolute) in any formula.

At my physics study we need to be able to determine this for any formula, but sometimes it takes really large amounts of pages to write them and hours to double check them.

There are a few simple rules for creating formula's which determine the error:

1)When adding or substracting, the total error is the addition of the two absolute error, example:

Formula:

R_total = R_1 - R_2 + R_3

error formula:

total_error_in_R = error_in_R_1 + error_in_R_2 + error_in_R_3

2)When multiplying or dividing, you add the relative errors (error in value divided by the value itself)

Formula: U = I * R

Error formula: error_in_U / U = error_in_I/I + error_in_R/R

3) How to define additional rules? (powers, etc)

Is this even possible in Mathcad?

2 replies

12-Amethyst
February 18, 2014

Hi

there was a discussion aout this topic not too long ago:

http://communities.ptc.com/message/228086#228086

This might give you some ideas abotu what is possible & definitely what the pit falls can be.

regards

Andy

25-Diamond I
February 18, 2014

Rafal Grasman wrote:

Formula: U = I * R

Error formula: error_in_U / U = error_in_I/I + error_in_R/R

Hmmm!? Lets substitute tolerance for error and let R=(10 +/- 2) ohm, I=(2 +/- 1) A. Smallest result for U would be 8 V, largest result is 36 V. So we don' get a symmetric interval around the nominal 20V. According to the rule you provided for multiplication we would add 2/10 + 1/2 = 7/10. So according to this calculation the relative error for U should be 70%. So the lenght of the interval for U (6 to 34) is the same, but the absolute limits aren't.!!??

It is also not said that you just have to consider the minimum and the maximum value of a variable to get minimum and maximum of a calculation. Let x=(5 +/- 2), so we have a range from 3 to 7 (the examples use an unusal big tolerance to better show the point). The calculation we have to do is y=x*(12-x). We get the minimum for x=2 with y=27, but the maximum value is y=36 for x=6, which is neither end of the x-range.

Using you rule you would get that y has a tolerance of 80%, which would be a range for y from 7 to 63 around the nominal 35, while in real we have to expect the range from 27 to 36 for y.

Calculations with tolerances or errors can be very tricky and I think it would not be practical and worth the effort implementing appropriate routines for the most used operations or even functions like I did with +/- in the thread Andy pointed you to.

Considering all those points led me in trying a brute force approach to find the minumum and maximum value of any calculation using values with tolerances http://communities.ptc.com/message/199660#199660. Any variable is represented by a vector with selectable number of elelemnts and then all those values are combinated and the calculation done to find min and max at the end. A calculation which uses 5 variables and if each variable is represented by 100 values within its range has to do the calculation 100^5 times. So the drawback is clearly apparent - calculation time, possibly in prohibiting dimensions.

19-Tanzanite
February 18, 2014

The simple rules result from "differentiating" the functions, as in:

errors.PNG

(except that each term on the RHS needs to be replaced by its absolute value), so they are really only valid for "small" errors (that's why they are "simple" rules!).

In Mathcad therefore, one could calculate the error of any function by simply differentiating it wrt each of its variables and adding the (absolute values of) the resulting terms. For example:

error2.PNG

Alan

25-Diamond I
February 19, 2014

Thanks - cheers for the explanatons!

Was too much fixated on an exact calculation but I see now see the potential of those approximate error guessing. I see no practical way to automate this, though.

BTW, if I recall it correctly PSPICE is using kind of a Monte Carlo method to get the range of the result if components with tolerances are used.