HomeProductsDownloadEducationSupportPartnersFind SciFace

MuPAD

Demonstration Tours - A Survey of MuPAD

Go Back:

About MuPAD

Demo Tours

A Survey

Previous Page Next Page Contents

Arithmetic with Numbers

MuPAD can be used as a pocket calculator to perform arithmetical computations. The input
>> 1 + 5/2;
is simplified to the rational number 7/2:
      7/2
As you can see MuPAD performs computations with integers and rationals exactly:
>> (1 + (5/2 * 3)) / (1/7 + 7/9)^2;
      67473/6728

Moreover, the system is able to efficiently handle computations with very large numbers. The length of a number is only restricted by the memory available on your computer. Let us compute the rd power of 1234:

>> 1234^123;
that is a number with 381 digits:
      17051580621272704287505972762062628265430231311106829047052\
      96193221839138348680074713663067170605985726415923145543459\
      00570589670671499709086102539904846514793135617305563669993\
      95010462203568202735575775507008323844414777839602638706704\
      26857004040032870424806396806968655878650166993838833888319\
      80459159942845372414601809429717726107628595243406801014418\
      529766279838067203562799104
We can ask MuPAD whether the number 2398232343243249984321312321 is prime or not. If number is prime if it is only divisible by 1 and itselves:
>> isprime( 2398232343243249984321312321 );
      FALSE
The answer FALSE means that the given number is not prime. If you want to see all factors of 2398232343243249984321312321 use the function Factor:
>> Factor( 2398232343243249984321312321 );
      72140687161773179 3 733 15117701
Do you believe the system? If not, you may check the result by multiplying the factors:
>> _mult( % );
      2398232343243249984321312321

As we have seen, all digits are calculated exactly. But what does ``exact'' computations really mean? What does the system return when, for instance, the input is an irrational number like sqrt(56)?

Exact Computations

We will try to answer this question by the following examples. As you might have expected, MuPAD is able to compute sqrt(4) exactly:

>> sqrt(4);
      2

Now, let us ask the system for the real number sqrt(56):

>> sqrt(56);
          1/2
      2 14
As you can see, MuPAD simplifies sqrt(56 to the exact value of 2*sqrt(14), where sqrt(14) is an expression that represents in MuPAD the positive solution sqrt(14) of the equation x2=14.

Another example may be given by calculating the limit limit( (1+1/n)n, n=infinity ):

>> limit( (1+1/n)^n, n=infinity );
      exp(1)
The value exp(1) represents in MuPAD the base of the natural logarithm, i.e. e = 2.71828....

Approximative versus Exact Computations

In contrast to exact arithmetic you may want to compute approximatively. For example, if you want to have an approximative value for you must use the function float:

>> float( sqrt(56) );
      7.483314773

The precision of the approximation depends on the value of the global variable DIGITS which has the default value of 10:

>> DIGITS; float( 67473/6728 );
      10
      
      1.002868608e1
DIGITS gives the number of significant digits when performing floating point arithmetic. You can change its value to any integer between 1 and 2^232-1:
>> DIGITS:= 100: float( 67473/6728 ); unassign( DIGITS ):
      10.02868608799048751486325802615933412604042806183115338882\
      
      282996432818073721759809750297265160523186
The statement unassign(DIGITS) reset the value of DIGITS to its default value.

The constants PI and E can be used for exact calculations in MuPAD:

>> cos( PI );
      -1
or
>> ln( E );
      1

It is also possible to compute a floating point approximation of these constants, if wanted. The following example computes PI on one thousand digits exactly in less than 1 second:

>> DIGITS:= 1000: float(PI); unassign( DIGITS ):
      3.141592653589793238462643383279502884197169399375105820974\
      
      94459230781640628620899862803482534211706798214808651328230\
      
      66470938446095505822317253594081284811174502841027019385211\
      
      05559644622948954930381964428810975665933446128475648233786\
      
      78316527120190914564856692346034861045432664821339360726024\
      
      91412737245870066063155881748815209209628292540917153643678\
      
      92590360011330530548820466521384146951941511609433057270365\
      
      75959195309218611738193261179310511854807446237996274956735\
      
      18857527248912279381830119491298336733624406566430860213949\
      
      46395224737190702179860943702770539217176293176752384674818\
      
      46766940513200056812714526356082778577134275778960917363717\
      
      87214684409012249534301465495853710507922796892589235420199\
      
      56112129021960864034418159813629774771309960518707211349999\
      
      99837297804995105973173281609631859502445945534690830264252\
      
      23082533446850352619311881710100031378387528865875332083814\
      
      20617177669147303598253490428755468731159562863882353787593\
      
         751957781857780532171226806613001927876611195909216420199
The output is rather long but impressive, isn't it?


Do you have questions or comments?

Copyright © SciFace Software GmbH & Co. KG 1998 - 2000