(38G) Neighbour Function (Dedekind Cut)
09-28-2017, 10:11 AM
Post: #1
 Gerald H Senior Member Posts: 1,412 Joined: May 2014
(38G) Neighbour Function (Dedekind Cut)
The three programmes below together perform the Neighbour function & Dedekind cut.

For the development of the programmes please see:

The Neighbour function for a real number N finds the nearest number to N that the calculator can represent.

The Dedekind cut returns for real input N the upper & lower nearest numbers to N that the calculator can represent.

The first programme accepts a real number input on the Home screen & returns the upper nearest number in Ans.

NXTUP

Code:
Ans►N: IFTE(Ans,10^(XPON(Ans)),1.E-488)►T: N/T: T*(Ans+10^((Ans≠-1)-12)):

The next programme accepts a complex number as input on the Home screen, say

(x,P)

where you require the neighbour of x & P is either 1 or -1, 1 indicating the upper neighbour & -1 the lower, & returns the result in Ans.

NEIGHBOR

Code:
Ans►Z0: RE(Ans)►R: IM(Z0)►I: IF I==-1 THEN -R: RUN NXTUP: -Ans: ELSE R: RUN NXTUP: END:

Finally for real number input in the Home screen the programme DCUT returns a complex number in Ans, the real part being the upper & the imaginary part the lower neighbour.

DCUT

Code:
Ans►D: (D,1): RUN NEIGHBOR: Ans►U: (D,-1): RUN NEIGHBOR: (U,Ans):
 « Next Oldest | Next Newest »

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