%matplotlib inline

"""
Explanation: Andres Heredia, Esteban Martinez 
Introduction
Our experiment will help us model the relation between mass and static friction. We will see what is the maximum force that can be applied to an object before it moves on a flat surface and on an incline.
Procedure
In order to measure the static friction we hooked a spring scale to a box where we put weights. Then we hooked the scale up to the box and made sure that our scale was set to zero, after which we put varying weights in the box. Finally we pulled on the scale until the box moved and wrote down our findings. For the incline we lifted our surface to a 3° angle and measured the static friction again with the same tools as last time, after which we can formulate a model from our data by using the formula: 
$ f_s = f_{sp} - mgsin$θ
$ f_s $ = Static friction
$ f_{sp} $ = Spring scale force
$$Flat$$ $$surface$$
| mass (g)  | Force (N) |
|-----  |---    |
| 100   | .25   |
| 200   |   .70 |
| 300   |   1.0 |
| 400   | 1.35|
| 500   | 1.7   |
$$On$$  $$incline$$
| mass (g)  | Force (N) |
|-----  |---    |
| 100   | .698      |
| 200   |   .897    |
| 300   |   1.146   |
| 400   | 1.69|
| 500   | 1.943 |
End of explanation
"""


import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit

mass = [ 100, 200, 300, 400, 500]
force = [ .25, .7, 1.0, 1.35, 1.7]
xx = np.linspace(0,600,10)
def lin_model( x, a, b):
    return a*x + b
a,b = curve_fit(lin_model, mass, force)[0]
print(a,b)
plt.title('Static Friction on a Flat Surface VS an Incline')
plt.ylabel ('Friction (N)')
plt.xlabel ('Mass (g)')
plt.plot(xx, lin_model(xx, a, b))
plt.plot(mass,force,'go')


mass2 = [ 100, 200, 300, 400, 500]
force2 = [.698,.897,1.146,1.691, 1.943]
xx = np.linspace(0,600,10)
def lin_model( x, a, b):
    return a*x + b
a,b = curve_fit(lin_model, mass2, force2)[0]
print(a,b)
plt.plot(xx, lin_model(xx, a, b))
plt.plot(mass2,force2,'go')

"""
Explanation: Data Analysis
End of explanation
"""


