<jupyter_start><jupyter_text>Pelota que caeLas ecuaciones de Newton son:$m \frac{d^2\vec r}{dt^2} = -g\hat k +\vec f_{friccion} + \vec f_{ext} $<jupyter_code>from pylab import*
from scipy.integrate import*
%matplotlib inline
def fuerza(v_r,t, gamma=0, viento=[0,0], m=1.,g=9.8):
    # v_r = [r, rz, vy, vz]
    dvz = -g/m -gamma/m*v_r[3] +viento[1]
    dvy = 0 -gamma/m*v_r[2]+viento[0]
    drz = v_r[3]
    dry = v_r[2]
    return [dry, drz, dvy, dvz]
tiempo=linspace(0,1)
sol_0 =odeint(fuerza,[0,0,1,5],tiempo)
y0,z0 = sol_0[:,0],sol_0[:,1]
sol_1 =odeint(fuerza,[0,0,1,5],tiempo,args=(0.5,))
y1,z1 = sol_1[:,0], sol_1[:,1]
sol_2 =odeint(fuerza,[0,0,1,5],tiempo,args=(0.5,[-.5,0]))
y2,z2 = sol_2[:,0], sol_2[:,1]
#xlim([-1,1.1]),ylim([0,1.4]),grid(True)
plot(y0,z0, y1,z1, y2,z2)
show()
def delta_tray(r0, dt=0.1, param=[0, [0,0], 1, 9.8]):
    tiempo = array([0,dt])
    sol = odeint(fuerza, r0, tiempo, args=(param[0],param[1],param[2],param[3]))
    return sol
def rebote(pto, dt, param):
    error = 1e-5
    dt = dt/2
    sol =odeint(fuerza, pto, [0,dt], args=(param[0],param[1],param[2],param[3],))
    while abs(sol[:,1][0]-sol[:,1][1]) > error:
        if sol[:,1][0]*sol[:,1][1] < 0:
            pto = sol[0]
        else:
            pto = sol[1]
        dt = dt/2
        sol =odeint(fuerza, pto, [0,dt], args=(param[0],param[1],param[2],param[3],))
        #print sol[0]
    return [sol[0][0],sol[0][1],sol[0][2],-sol[0][3]]
rebote([0.6, 0.036, 1., -2.88], 0.05, [0,[0,0],1, 9.8])
def trayec(r0, tf, param=[0, [0,0], 1, 9.8]):
    t_tot, dt =[0], .01
    y = [r0[0]]
    z = [r0[1]]
    t_actual = 0.
    while t_actual <= tf :
        t_actual = t_actual + dt
        sol =odeint(fuerza, r0, [0,dt], args=(param[0],param[1],param[2],param[3],))
        if sol[:,1][0]*sol[:,1][1] < 0.:
            sol1=rebote(sol[0],dt,param)
            y.append(sol1[0])
            z.append(sol1[1])
            r0=sol1
        else:
            y.append(sol[:,0][1])
            z.append(sol[:,1][1])
            r0 = sol[1]
        #print y,z
    return y,z
yv, zv = trayec([0,0,1,5],2., [.5,[-3.5,0],1, 9.8])
yf, zf = trayec([0,0,1,5],2., [.5,[0,0],1, 9.8])
yideal, zideal = trayec([0,0,1,5],2.)
plot(yv,zv,'*', yideal, zideal, yf,zf,'o')
show()<jupyter_output><empty_output><jupyter_text>simular el rebote<jupyter_code>def func1(x,y,otra_fun):
    x=out = otra_fun(x)+y
    return out

def func2(x):
    out = x**2
    return out
def func3(x):
    out = x**3
    return out
func1(4,8,func2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.24554455445544554, 'fraction_numerical': 0.08435643564356436, 'mean_word_length': 3.2813559322033896, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '563810', 'license': 'Apache-2.0', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1251, 'n_words': 209, 'path': 'data/notebooks/nb_956146.ipynb', 'repo_name': 'DavidRV00/notebook-analysis', 'size': '2525'}