def c6p21(): # Trajectory def y(theta, x, v0, y0, g=9.8): return np.tan(theta) * x - (g * x**2) / (2 * v0**2 * np.cos(theta)**2) + y0 # Constants v0, x, y0, y1 = 30., 90, 1.8, 1. deg = (180. / np.pi) # Args for solution f = lambda theta: y(theta, x, v0, y0) - y1 return { 'newton_raphson th1': deg * num.newton_raphson(f, 0.4), 'newton_raphson th2': deg * num.newton_raphson(f, 0.9), 'secant_method th1': deg * num.secant_method(f, 0.4, 0.45), 'secant_method th2': deg * num.secant_method(f, 0.9, 0.95) }
def c6p19(): # Impedance def z(r, c, l, w): return np.sqrt( r**(-2) + ( w * c - (w * l)**(-1) )**2 )**(-1) # Constants r, c, l, z_desired = 225., 0.6 * 10**(-6), 0.5, 100. # Args for solution f = lambda w: z(r, c, l, w) - z_desired x0, x1, dx = 210, 215, 10**(-4) return {'newton_raphson': num.newton_raphson( f,x0 ), 'secant_method': num.secant_method( f, x0, x1 ), 'modified_secant': num.modified_secant( f,x1,dx) }
def c6p19(): # Impedance def z(r, c, l, w): return np.sqrt(r**(-2) + (w * c - (w * l)**(-1))**2)**(-1) # Constants r, c, l, z_desired = 225., 0.6 * 10**(-6), 0.5, 100. # Args for solution f = lambda w: z(r, c, l, w) - z_desired x0, x1, dx = 210, 215, 10**(-4) return { 'newton_raphson': num.newton_raphson(f, x0), 'secant_method': num.secant_method(f, x0, x1), 'modified_secant': num.modified_secant(f, x1, dx) }
def c6p21(): # Trajectory def y(theta, x, v0, y0, g=9.8 ): return np.tan( theta ) * x - (g * x**2) /( 2 * v0**2 * np.cos( theta )**2 ) + y0 # Constants v0, x, y0, y1 = 30., 90, 1.8, 1. deg = ( 180. / np.pi ) # Args for solution f = lambda theta: y( theta, x, v0, y0 ) - y1 return { 'newton_raphson th1': deg * num.newton_raphson( f,0.4 ), 'newton_raphson th2': deg * num.newton_raphson( f, 0.9 ) ,'secant_method th1': deg * num.secant_method(f,0.4, 0.45 ), 'secant_method th2':deg * num.secant_method( f,0.9,0.95 ) }