How to resolve the algorithm Pathological floating point problems step by step in the 360 Assembly programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Pathological floating point problems step by step in the 360 Assembly programming language

Table of Contents

Problem Statement

Most programmers are familiar with the inexactness of floating point calculations in a binary processor. The classic example being: In many situations the amount of error in such calculations is very small and can be overlooked or eliminated with rounding. There are pathological problems however, where seemingly simple, straight-forward calculations are extremely sensitive to even tiny amounts of imprecision. This task's purpose is to show how your language deals with such classes of problems.

A sequence that seems to converge to a wrong limit. Consider the sequence:

As   n   grows larger, the series should converge to   6   but small amounts of error will cause it to approach   100.

Display the values of the sequence where   n =   3, 4, 5, 6, 7, 8, 20, 30, 50 & 100   to at least 16 decimal places.

The Chaotic Bank Society   is offering a new investment account to their customers. You first deposit   $e - 1   where   e   is   2.7182818...   the base of natural logarithms. After each year, your account balance will be multiplied by the number of years that have passed, and $1 in service charges will be removed. So ...

What will your balance be after   25   years?

Siegfried Rump's example.   Consider the following function, designed by Siegfried Rump in 1988.

Demonstrate how to solve at least one of the first two problems, or both, and the third if you're feeling particularly jaunty.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Pathological floating point problems step by step in the 360 Assembly programming language

Source code in the 360 programming language

*        Pathological floating point problems  03/05/2016
PATHOFP  CSECT
         USING  PATHOFP,R13 
SAVEAR   B      STM-SAVEAR(R15)
         DC     17F'0'
STM      STM    R14,R12,12(R13)
         ST     R13,4(R15)
         ST     R15,8(R13)
         LR     R13,R15
         LE     F0,=E'2'
         STE    F0,U             u(1)=2
         LE     F0,=E'-4'
         STE    F0,U+4           u(2)=-4
         LA     R6,3             n=3
         LA     R7,U+4           @u(n-1)
         LA     R8,U             @u(n-2)
         LA     R9,U+8           @u(n)
LOOPN    CH     R6,=H'100'       do n=3 to 100
         BH     ELOOPN
         LE     F4,0(R7)         u(n-1)
         LE     F2,=E'1130'      1130
         DER    F2,F4            1130/u(n-1)
         LE     F0,=E'111'       111
         SER    F0,F2            111-1130/u(n-1)
         LE     F2,0(R7)         u(n-1)
         LE     F4,0(R8)         u(n-2)
         MER    F2,F4            u(n-1)*u(n-2)
         LE     F6,=E'3000'      3000
         DER    F6,F2            3000/(u(n-1)*u(n-2))
         AER    F0,F6            111-1130/u(n-1)+3000/(u(n-1)*u(n-2))
         STE    F0,0(R9)         store into u(n)
         XDECO  R6,PG+0          n
         LE     F0,0(R9)         u(n)
         LA     R0,3             number of decimals
         BAL    R14,FORMATF      format(u(n),'F13.3')
         MVC    PG+12(13),0(R1)  put into buffer
         XPRNT  PG,80            print buffer
         LA     R6,1(R6)         n=n+1
         LA     R7,4(R7)         @u(n-1)
         LA     R8,4(R8)         @u(n-2)
         LA     R9,4(R9)         @u(n)
         B      LOOPN
ELOOPN   L      R13,4(0,R13)
         LM     R14,R12,12(R13)
         XR     R15,R15
         BR     R14
         COPY   FORMATF
         LTORG  
PG       DC     CL80' '          buffer
U        DS     100E
         YREGS
         YFPREGS 
         END    PATHOFP

  

You may also check:How to resolve the algorithm Globally replace text in several files step by step in the D programming language
You may also check:How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the Go programming language
You may also check:How to resolve the algorithm URL decoding step by step in the Racket programming language
You may also check:How to resolve the algorithm Statistics/Basic step by step in the Julia programming language
You may also check:How to resolve the algorithm Elementary cellular automaton step by step in the Ada programming language