Skip to content
Snippets Groups Projects
Commit 6e34862f authored by Miguel Stiven Ascanio Quinchia's avatar Miguel Stiven Ascanio Quinchia
Browse files

Upload New File

parent 548d52b9
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:7d1a8c2e-29fd-42eb-b928-76b61cb517c7 tags:
## Proyecto "Pendulo"
%% Cell type:markdown id:5ac9fc79-8c97-4a49-a2a3-a0f64e0399a2 tags:
Vamos hacer un pendulo el cual vamos dejar oscilar 4 veces (ida y vuelta). De esas oscilasciones vamos a sacar los tiempos (t1, t2, t3, t4) de los cuales vamos a sacar el promedio (todos los tiempos divididos entre el numero de tiempos, o mean) y el margen de error (std).
Esto lo vamos a hacer un total de 8 veces con longitudes de cuerda distintas, por ejemplo: 10 cm, 12 cm, 14 cm, 16 cm, 18 cm, 20 cm, 22 cm, 24 cm. Para estas longitudes vamos a hacer lo mismo, dejarlos oscilar 4 veces, por lo que en total tendriamos 32 tiempos, 4 para cada longitud, a los cuales tambien vamos a sacar el promedio y el margen de error.
Vamos a usar la fórmula del período de un péndulo simple "T=2π√(L/g)"
%% Cell type:markdown id:0393b97c-d33a-4c0b-9087-3e5556ea59b1 tags:
## Polyfit
%% Cell type:code id:912b9360-e364-41b4-87c8-49ee08096cfe tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
```
%% Cell type:markdown id:d969ec5b-0138-4202-9009-87e2d9049416 tags:
Vamos a crear unos datos ficticios para ejemplificar como funciona poplyt a partir de T=BL^(alpha)
%% Cell type:code id:74f138ad-a645-474c-b731-935fdecfc946 tags:
``` python
np.random.rand(10) #Esto es para generar numeros aleatorios si no le pongo mas cosas, lo hace entre 0 y 1
```
%% Output
array([0.20344161, 0.03912441, 0.36305887, 0.58182966, 0.00168751,
0.71719898, 0.03621497, 0.6338115 , 0.61341108, 0.38180788])
%% Cell type:code id:b535818b-3ee5-44be-af2e-f809d630eba7 tags:
``` python
L = np.arange(10, 32, 2) #la longitud de la cuerda
dL = np.random.rand(len(L)) #esto es para simular datos experimentales
B= 0.5 # es esto ((2π)/√g)
alpha = 0.6 # expomemte
T0 = B*L**alpha #estos son los datos sin error
T = B*(L+dL)**alpha #estos son los datos con error (generaods aleatoriamente con np.random.rand(len(L)))
```
%% Cell type:code id:912d9cd4-09fe-4965-b496-0f1fc3d50310 tags:
``` python
plt.figure()
plt.plot(L, T0, 'b.', label='Datos sin error')
plt.plot(L, T, 'r.', label='Datos con error')
plt.xlabel('Longitud')
plt.ylabel('Periodo')
plt.title('Longitud vs periodo', fontweight='bold')
plt.legend()
plt.show()
```
%% Output
%% Cell type:code id:e1e40903-f657-4170-9e49-4e8351165c73 tags:
``` python
X = np.log(L) #logaritmo natural de L
Y = np.log(T) #logaritmo natural de T
plt.figure()
plt.plot(X, Y, 'b.', label='Datos sin error')
plt.xlabel('Longitud')
plt.ylabel('Periodo')
plt.title('Longitud vs periodo con logaritmo', fontweight='bold')
plt.legend()
plt.show()
```
%% Output
%% Cell type:markdown id:5410018a-573b-4f37-a81c-6545b70b6398 tags:
## Ajuste lineal
%% Cell type:code id:8dae9bda-2169-42ed-bc38-ceeed8bd47ee tags:
``` python
alpha_exp, C_exp = np.polyfit (X, Y, 1)
print(alpha_exp, C_exp)
```
%% Output
0.5862378504559297 -0.6345564074959843
%% Cell type:code id:baa381b3-f2d9-462f-90bb-c5c1664bf4b4 tags:
``` python
np.exp(C_exp)
```
%% Output
0.5301706158743533
%% Cell type:code id:bee80810-84c4-4783-bfdb-3779dd18188e tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment