The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Interval Arithmetic
12-24-2022, 07:43 PM
Post: #1
Interval Arithmetic
The arithmetic functions for intervals are defined as:

[a, b] + [c, d] = [a + c, b + d]
[a, b] - [c, d] = [a - d, b - c]
[a, b] × [c, d] = [min(a × c, a × d, b × c, b × d), max(a × c, a × d, b × c, b × d)]
[a, b] ÷ [c, d] = [min(a/c, a/d, b/c, b/d), max(a/c, a/d, b/c, b/d)]


INTERVALHELP: help screen for interval arithmetic functions
INTERVALADD: adding two intervals
INTERVALSUB: subtracting two intervals
INTERVALMUL: multiply two intervals
INTERVALDIV: divide two intervals

In the Home mode, use the curly brackets (used for lists { }), to type the intervals. For example, the interval [ 81.8, 82.2 ] would be typed {81.8,82.2}.

Code:
EXPORT INTERVALHELP()
BEGIN
// 2022-12-22 EWS
PRINT();
PRINT("Interval Arithmetic");
PRINT("Use curly brackets {}");
PRINT("");
PRINT("INTERVALADD({a,b},{c,d})");
PRINT("add intervals");
PRINT("");
PRINT("INTERVALSUB({a,b},{c,d}");
PRINT("subtract intervals");
PRINT("");
PRINT("INTERVALMUL({a,b},{c,d})");
PRINT("multiply intervals");
PRINT("");
PRINT("INTERVALDIV({a,b},{c,d})");
PRINT("divide intervals");
END;

Code:
EXPORT INTERVALADD(v1,v2)
BEGIN
RETURN v1+v2;
END;

Code:
EXPORT INTERVALSUB(v1,v2)
BEGIN
RETURN v1-REVERSE(v2);
END;

Code:
EXPORT INTERVALMUL(v1,v2)
BEGIN
LOCAL v3;
v3:=CONCAT(v1*v2,v1*REVERSE(v2));
RETURN {MIN(v3),MAX(v3)};
END;

Code:
EXPORT INTERVALDIV(v1,v2)
BEGIN
INTERVALMUL(v1,1/REVERSE(v2));
END;

Example

Interval 1 = {13, 29}
Interval 2 = {10, 14}

Add: {23, 43}
Subtract: {-1, 19}
Multiply: {130, 406}
Divide: {0.928571428572, 2.9}

Source

Moore, Ramon E. Mathematical Elements of Scientific Computing Holt, Rinehart, and Winston, Inc: New York. 1975. ISBN 0-03-088125-0

Download a zip file here:
https://drive.google.com/file/d/1L8mmnm3...share_link
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Interval Arithmetic - Eddie W. Shore - 12-24-2022 07:43 PM



User(s) browsing this thread: 1 Guest(s)