Question
Help Needed! Please help me with Question 2! Language is python. Below is the question and code for question 2, as well as number one
Help Needed!
Please help me with Question 2! Language is python. Below is the question and code for question 2, as well as number one to reference. Any help is greatly appreciated! Thanks!
Question 2 Code to Copy;
# first solution
# choose the initial condition (where to start) u0 = 0 v0 = 1 w0 = 1.05 initial_conditions = [u0, v0, w0]
# all set! let's get the solution in one line! Lorenz_solution = odeint(Lorenz, initial_conditions, time, args = (sigma, beta, rho))
# unpack so that we can see what we got u = Lorenz_solution[:,0] v = Lorenz_solution[:,1] w = Lorenz_solution[:,2]
# let's visualization what we got fig = plt.figure(figsize=(20,10)) plt.plot(time, u, label='u') plt.plot(time, v, label='v') plt.plot(time, w, label='w')
# second solution - different initial condition
# choose the initial condition (where to start) u0 = 0 v0 = 1*.... ### w0 = 1.05*..... ### initial_conditions = [u0, v0, w0]
# all set! let's get the solution in one line! Lorenz_solution = odeint(Lorenz, initial_conditions, time, args = (sigma, beta, rho))
# unpack so that we can see what we got u = .... ### v = .... ### w = .... ###
# let's visualization what we got plt.plot(time, u, '--', label='du', zorder = 1, alpha = 0.7) plt.plot(time, v, '--',label='dv', zorder = 1, alpha = 0.7) plt.plot(time, w, '--',label='dw', zorder = 1, alpha = 0.7) plt.grid(alpha=0.2) plt.legend() plt.title('Solution of the Lorenz System: Two Different Initial Conditions') plt.xlabel('time') plt.ylabel('$u, v, w$')
QUESTION 1 CODE to COPY (if needed):
def Lorenz(current_values, t, sigma, beta, rho): """The famous chaotic Lorenz equations.""" # unpack the variables u, v, w = current_values ###
# form the derivative we neee to pass back dudt = sigma*(v - u) dvdt = rho*u - v - u*w dwdt = u*v-beta*w ###
# all done, let's gather our results and exit! return [dudt, dvdt, dwdt] ###
# 3 - choose the initial condition (where to start) u0 = 0 v0 = 1 w0 = 1.05 initial_conditions = np.array([u0, v0, w0]) ###
# 4 - choose time interval over which we want a solution time_max = 60 num_time_points = 4000 time = np.linspace(0, time_max, num_time_points) ###
# 5 - choose values for the parameters sigma = 10 beta = 2.667 rho = 26
# 6 - all set! let's get the solution in one line, and unpack it! Lorenz_solution = odeint(Lorenz, initial_conditions, time, args = (sigma, beta, rho))
# unpack so that we can see what we got, using Numpy slicing u_new = Lorenz_solution[:,0] v_new = Lorenz_solution[:,1] ### w_new = Lorenz_solution[:,2] ###
# 7 - let's visualize what we got fig = plt.figure(figsize=(20,10)) plt.plot(time, u_new, label='u') plt.plot(time, v_new, label='v') ### plt.plot(time, w_new, label='w') ### plt.grid(alpha=0.2) plt.legend() plt.title('Solution of the Lorenz System') plt.xlabel('time') plt.ylabel('$u, v, w$')
HELPFUL CODE TO COPY:
import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint from IPython.display import clear_output from time import sleep
THANK YOU
Question 2 (5 points) Modify the code above to plot the solution for two different initial conditions. Remember, this is what should reveal "chaotic behavior. Although you are strongly encouraged to play with your own choices for the initial conditions, start by multiplying the originals by a factor such as 1.01, which barely changes the original values. For example, try both 1.01 and 1.001 as factors mulitplying the original initial conditions. Make a plot with now six curves, where the old curves are solid lines and new curves are dashed lines. # first solution #choose the initial condition where to start) ue = 0 ve = 1 WO = 1.85 initial_conditions = [ue, vo, wo] # all set! Let's get the solution in one line! Lorenz_solution = odeint(Lorenz, initial_conditions, time, args = (sigma, beta, rho)) # unpack so that we can see what we got U = Lorenz_solution[:,] V = Lorenz_solution[:,1] W = Lorenz_solution[:,2] # Let's visualization what we got fig = plt. figure(figsize=(20,10)) plt.plot(time, u, label='') plt.plot(time, v, label='v') plt.plot(time, w, label='w') # second solution - different initial condition #choose the initial condition where to start) uo = 0 Vo = 1*....** WO = 1.85*..... ### initial_conditions = [ue, vo, Wo] # second solution - different initial condition # choose the initial condition (where to start) ue = @ Vo = 1*... *** WO = 1.85*..... ### initial_conditions = [ue, vo, WO] # all set! Let's get the solution in one Line! Lorenz_solution = odeint(Lorenz, initial_conditions, time, args = (sigma, beta, rho)) # unpack so that we can see what we got U ... # V = .... W .... # # Let's visualization what we got plt.plot(time, u, '--', label='du', zorder = 1, alpha = 0.7) plt.plot(time, v, '--', label='dv', zorder = 1, alpha = 0.7) plt.plot(time, w, '--',label='dw', zorder = 1, alpha = 0.7) plt.grid(alpha=0.2) plt.legend plt.title('Solution of the Lorenz System: TWO Different Initial Conditions) plt.xlabel('time) plt.ylabel('$u, v, w$') File "
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started