Dataplot Vol 2 Vol 1

# RELDIF

Name:
RELDIF (LET)
Type:
Library Function
Purpose:
Return the relative difference of two numbers.
Description:
The definition of the relative difference between X1 and X2 used by Dataplot is:

$$\mbox{Relative Difference} = \frac{|X1 - X2|} {\mbox{MAX}(|X1|,|X2|}$$

Dataplot also supports the alternative formula

$$\mbox{Relative Difference} = \frac{|X1 - X2|} {(X1 + X2)/2}$$
Syntax 1:
LET <y> = RELDIF(<y1>,<y2>)             <SUBSET/EXCEPT/FOR qualification>
where <y1> is a variable or a parameter;
<y2> is a variable or a parameter;
<y> is a variable or a parameter (depending on what <y1> and <y2> are) where the computed relative difference values are stored;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.

This syntax implements the first formula given above (the denominator is the maximum of the two values).

Syntax 2:
LET <y> = RELDIF2(<y1>,<y2>)             <SUBSET/EXCEPT/FOR qualification>
where <y1> is a variable or a parameter;
<y2> is a variable or a parameter;
<y> is a variable or a parameter (depending on what <y1> and <y2> are) where the computed relative difference values are stored;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.

This syntax implements the second formula given above (the denominator is the average of the two values).

Examples:
LET A = RELDIF(14,10)
LET A = RELDIF(A1,A2)
LET X2 = RELDIF(X1,X4)
LET X2 = RELDIF(X1-4,X2+6)
Default:
None
Synonyms:
None
Related Commands:
 RELERR = Compute the relative error of two numbers. PERCDIF = Compute the percent difference of two numbers. PERCERR = Compute the percent error of two numbers. MIN = Compute the minimum of two numbers. MAX = Compute the maximum of two numbers. ABS = Compute the absolute value of a number.
Applications:
Data Management
Implementation Date:
2010/12
Program:

LET X = SEQUENCE 0.1  0.1  3
LET Y1 = X**2
LET Y2 = X**(1/2)
LET Y3 = RELDIF(Y1,Y2)
SET WRITE DECIMALS 5
PRINT Y1 Y2 Y3

The following output is generated:
---------------------------------------------
Y1             Y2             Y3
---------------------------------------------
0.01000        0.31622        0.96837
0.04000        0.44721        0.91055
0.09000        0.54772        0.83568
0.16000        0.63245        0.74701
0.25000        0.70710        0.64644
0.36000        0.77459        0.53524
0.49000        0.83666        0.41433
0.64000        0.89442        0.28445
0.81000        0.94868        0.14618
1.00000        1.00000        0.00000
1.21000        1.04880        0.13321
1.44000        1.09544        0.23927
1.69000        1.14017        0.32533
1.96000        1.18321        0.39631
2.25000        1.22474        0.45566
2.56000        1.26491        0.50589
2.89000        1.30384        0.54884
3.24000        1.34164        0.58591
3.61000        1.37840        0.61817
4.00000        1.41421        0.64644
4.41000        1.44913        0.67139
4.84000        1.48323        0.69354
5.29000        1.51657        0.71331
5.76000        1.54919        0.73104
6.25000        1.58113        0.74701
6.76000        1.61245        0.76147
7.29000        1.64316        0.77459
7.84000        1.67332        0.78656
8.41000        1.70293        0.79751


NIST is an agency of the U.S. Commerce Department.

Date created: 01/06/2011
Last updated: 03/10/2017