## CS2 Computational Thinking for Scientists - Lab 06In this lab, we will experiment with C++, Python and Mathematica programs involving numerical and algebraic computations. As usual, create a folder on your desktop to save the Python code you will be working with and writing. Run the following commands in order to make the IDLE know about the folder:import os os.chdir("/Users/koc/Desktop/abc")Change the file path from above to the one you will be using. Also, import the math and random modules: import math, randomsince we will be using them as well. ## Single-Precision Arithmetic in C/C++The first experiment will involve the datapath width of the computer you are using. We also need to make a quick study of the integer data types:-
`short int` -
`int` -
`long int` -
`long long int`
## Multi-Precision Arithmetic in PythonPython does not define short or long integer types. It has only integer type, which has unlimited precision. Run IDLE and experiment with the operations:+, -, *, //, %, **Question: Is there a limit on the size of the number you will obtain? Answer this question by computing recursively the powers of 2 powers of, using 2**2 2**(2**2) 2**(2**(2**2)) 2**(2**(2**(2**2))) ..Try to see how far you can go, and what happens as higher powers are computed: ## Mathematical Functions in PythonThe Python modulesmath and random provide many
mathematical and random functions we can use. We will experiment
with the following:
- ceil, floor
- pow
- factorial
- gamma
- randint
- choice
- shuffle
## Multi-Precision Arithmetic in MathematicaMathematica also has built-in multi-precision integer arithmetic. The arithmetic operation symbols are:+, -, *, /, Mod[], ^Perform a similar experiment with Mathematica about the size of numbers you can compute: 2^2 2^(2^2) 2^(2^(2^2)) 2^(2^(2^(2^2))) ... ## Number Theory with MathematicaMathematica is much more powerful, has myriad of functions that are built in. We would like experiment with the following:PrimeQ[ .. ] FactorInteger[ .. ] Binomial[n,k] Sum[k^2, {k,1,100}] Sum[k^2, {k,1,n}] .. ## Algebraic Computations with MathematicaThere are other functions available in Mathematica. For example, we can perform computations with polynomials. We will experiment with the following:- InterpolatingPolynomial
- Expand
- Factor
- Derivative
- Solve
- MatrixForm
- Det
- DSolve
- RSolve
- Chebyshev
- Bessel
- ...
The lab report (if required) is due 5pm, Friday Feb 27. |