Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
restrepo
GitHub Repository: restrepo/ComputationalMethods
Path: blob/master/exams/Examen_2020_1_01_solucion.ipynb
934 views
Kernel: Python 3 (ipykernel)

Open In Colab

Primer Examen 15%

Ejercicio 1

Encuentre las raices positivas de: x24xsinx+(2sinx)2=0x^{2}-4 x \sin x+(2 \sin x)^{2}=0

Ejercicio 2

La rapidez vv de un cohete en un vuelo vertical cerca a la superficie de la tierra puede ser aproximada por v=ulnM0M0m˙tgt v=u \ln \frac{M_{0}}{M_{0}-\dot{m} t}-g t donde

  • uu en m/s\mathrm{m} / \mathrm{s}, es la velocidad de expulsión del combustible relativa al cohete.

  • M0M_{0} en kg\mathrm{kg} es la masa del cohete al tiempo de despegue.

  • m˙\dot{m} en kg/s\mathrm{kg} / \mathrm{s} es la tasa consumo de combustible

  • g=9.8m/s2g=9.8 \mathrm{m} / \mathrm{s}^{2} es la aceleración gravitacional

  • tt en ss, tiempo medido desde el despegue

Para los datos en: https://raw.githubusercontent.com/restrepo/ComputationalMethods/master/data/rocket.json

  1. Lea los datos en un DataFrame de pandas y verifique que m˙\dot{m} (mdot) es la única columna que está cambiando.

  2. Agregue una columna al DataFrame con el tiempo que tarda el cohete para alcanzar la velocidad del sonido (335m/s)(335 \mathrm{m} / \mathrm{s}) para cada valor de m˙\dot{m}

  3. Gráfique dicho tiempo en función de m˙\dot{m} rotulando apropiadamente los ejes

%pylab inline
Populating the interactive namespace from numpy and matplotlib
import pandas as pd
df=pd.read_json('https://raw.githubusercontent.com/restrepo/ComputationalMethods/master/data/rocket.json')
df

Evitar el uso de ciclos de Python

import numpy as np from scipy import optimize
vs=335. df['t']=df.apply(lambda row: #dictionary with the DataFrame row → requires axis='columns' at the end optimize.newton( lambda t: row.u * np.log(row.M0 / (row.M0 - row.mdot * t)) - row.g * t - vs, #Function x0=150 ), #initial guess axis='columns' )
df
plt.plot(df.t,df.mdot) plt.xlabel('$t$ [s]',size=15) plt.ylabel(r'$\dot{m}$ [Kg/s]',size=15) plt.grid()
Image in a Jupyter notebook