```python
import math as ma  # import math library
ma.frexp(0.2) #find the mantissa and the exponent
```




    (0.8, -2)




```python
1. + 1.e-15 == 1 # machine accuracy below 10^-15
```




    False




```python
1. + 1.e-16 == 1. # machine accuracy above 10^-16
```




    True




```python
x=1.e-7
a=(1-x*x)**(0.5)
a
```




    0.999999999999995




```python
b=((1-x)/(1+x))**0.5
b+b*x
```




    0.9999999999999949




```python
import matplotlib.pyplot as plt # get matplotlib to plot 
```


```python
t, h, n = 0.0, 0.1, 20          # init time, step size, number of ticks
```


```python
v0 = float(input("enter initial velocity:"))
```

    enter initial velocity:1.0



```python
ta, xa = [], []                 # time and position arrays for plotting
```


```python
for i in range(n):              # loop for n steps
    ta.append(t)                # record time
    xa.append(v0*t)             # update position
    t = t + h                   # update time 
```


```python
plt.figure()                    # start a figure;
plt.plot(ta, xa, '-o')          # plot data, '-o' means blue
plt.xlabel('t (s)')             # add labels
plt.ylabel('x (m)')
plt.show()                      # show figure
```


```python
from pylab import *
x = linspace(-10.,10.,100)
plot(x,sin(x)/x)
```


```python
from sympy import *
x = symbols('x')
plot(sin(x)/x)
```


```python
import numpy as np
```


```python
help(np.array)
```

    Help on built-in function array in module numpy:
    
    array(...)
        array(object, dtype=None, *, copy=True, order='K', subok=False, ndmin=0,
              like=None)
        
        Create an array.
        
        Parameters
        ----------
        object : array_like
            An array, any object exposing the array interface, an object whose
            __array__ method returns an array, or any (nested) sequence.
        dtype : data-type, optional
            The desired data-type for the array.  If not given, then the type will
            be determined as the minimum type required to hold the objects in the
            sequence.
        copy : bool, optional
            If true (default), then the object is copied.  Otherwise, a copy will
            only be made if __array__ returns a copy, if obj is a nested sequence,
            or if a copy is needed to satisfy any of the other requirements
            (`dtype`, `order`, etc.).
        order : {'K', 'A', 'C', 'F'}, optional
            Specify the memory layout of the array. If object is not an array, the
            newly created array will be in C order (row major) unless 'F' is
            specified, in which case it will be in Fortran order (column major).
            If object is an array the following holds.
        
            ===== ========= ===================================================
            order  no copy                     copy=True
            ===== ========= ===================================================
            'K'   unchanged F & C order preserved, otherwise most similar order
            'A'   unchanged F order if input is F and not C, otherwise C order
            'C'   C order   C order
            'F'   F order   F order
            ===== ========= ===================================================
        
            When ``copy=False`` and a copy is made for other reasons, the result is
            the same as if ``copy=True``, with some exceptions for `A`, see the
            Notes section. The default order is 'K'.
        subok : bool, optional
            If True, then sub-classes will be passed-through, otherwise
            the returned array will be forced to be a base-class array (default).
        ndmin : int, optional
            Specifies the minimum number of dimensions that the resulting
            array should have.  Ones will be pre-pended to the shape as
            needed to meet this requirement.
        like : array_like
            Reference object to allow the creation of arrays which are not
            NumPy arrays. If an array-like passed in as ``like`` supports
            the ``__array_function__`` protocol, the result will be defined
            by it. In this case, it ensures the creation of an array object
            compatible with that passed in via this argument.
        
            .. note::
                The ``like`` keyword is an experimental feature pending on
                acceptance of :ref:`NEP 35 <NEP35>`.
        
            .. versionadded:: 1.20.0
        
        Returns
        -------
        out : ndarray
            An array object satisfying the specified requirements.
        
        See Also
        --------
        empty_like : Return an empty array with shape and type of input.
        ones_like : Return an array of ones with shape and type of input.
        zeros_like : Return an array of zeros with shape and type of input.
        full_like : Return a new array with shape of input filled with value.
        empty : Return a new uninitialized array.
        ones : Return a new array setting values to one.
        zeros : Return a new array setting values to zero.
        full : Return a new array of given shape filled with value.
        
        
        Notes
        -----
        When order is 'A' and `object` is an array in neither 'C' nor 'F' order,
        and a copy is forced by a change in dtype, then the order of the result is
        not necessarily 'C' as expected. This is likely a bug.
        
        Examples
        --------
        >>> np.array([1, 2, 3])
        array([1, 2, 3])
        
        Upcasting:
        
        >>> np.array([1, 2, 3.0])
        array([ 1.,  2.,  3.])
        
        More than one dimension:
        
        >>> np.array([[1, 2], [3, 4]])
        array([[1, 2],
               [3, 4]])
        
        Minimum dimensions 2:
        
        >>> np.array([1, 2, 3], ndmin=2)
        array([[1, 2, 3]])
        
        Type provided:
        
        >>> np.array([1, 2, 3], dtype=complex)
        array([ 1.+0.j,  2.+0.j,  3.+0.j])
        
        Data-type consisting of more than one element:
        
        >>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')])
        >>> x['a']
        array([1, 3])
        
        Creating an array from sub-classes:
        
        >>> np.array(np.mat('1 2; 3 4'))
        array([[1, 2],
               [3, 4]])
        
        >>> np.array(np.mat('1 2; 3 4'), subok=True)
        matrix([[1, 2],
                [3, 4]])
    



```python
np.array([1.,2.,3.])
```




    array([1., 2., 3.])




```python
a=np.arange(5)
a
```




    array([0, 1, 2, 3, 4])




```python
a[2]
```




    2




```python
a[-2]
```




    3




```python
a[1:3] #slicing an array
```




    array([1, 2])




```python
a[::-1]
```




    array([4, 3, 2, 1, 0])




```python
np.insert(a,1,9)
```




    array([0, 9, 1, 2, 3, 4])




```python
np.delete(a,2)
```




    array([0, 1, 3, 4])




```python
2*a
```




    array([0, 2, 4, 6, 8])




```python
a+3
```




    array([3, 4, 5, 6, 7])




```python
a[1:3]=[-1,-2]
a
```




    array([ 0, -1, -2,  3,  4])




```python
b=np.copy(a[1:3])
b
```




    array([-1, -2])




```python
d=np.array([[11,12,13],[21,22,23],[31,32,33]]) #multidimensional array
```


```python
d
```




    array([[11, 12, 13],
           [21, 22, 23],
           [31, 32, 33]])




```python
d.shape
```




    (3, 3)




```python
d[0] 
```




    array([11, 12, 13])




```python
d[1,2]
```




    23



39c0e8d033759df9fd48c69b62a15decee543d93
ipynb
Jupyter Notebook
Playground/Sandbox_Maria.ipynb
mbabiuc/computationalphysicsmu
facbcdbfd0a7f193755db8e35653b69b548d8a65
CC0-1.0
Playground/Sandbox_Maria.ipynb
mbabiuc/computationalphysicsmu
facbcdbfd0a7f193755db8e35653b69b548d8a65
CC0-1.0
Playground/Sandbox_Maria.ipynb
mbabiuc/computationalphysicsmu
facbcdbfd0a7f193755db8e35653b69b548d8a65
CC0-1.0
Qwen/Qwen-72B
1. YES
2. YES