Question

In: Advanced Math

Let M be the integer corresponding to the first letter of your last name. For example,...

Let M be the integer corresponding to the first letter of your last name. For example, if your last name begins with "A", M=1 and if your last name begins with "Z", M=26.

Let k=1/M and consider the logistic equation dy/dt = k y (M - y).

Construct a single figure including

  1. Title "Logistic Equation Slope Field and Euler's Method solutions by FirstName LastName" with your actual first and last names, along the top
  2. Labels for the axes
  3. a slope field for -3 ≤ t ≤ 3, -M/2 ≤ y ≤ 3M/2
  4. Euler's method solutions for initial conditions   y(0)=5M/4, y(0)=M, y(0)=M/2, y(0)=0 and y(0)=-M/4, in each case for -3 ≤ t ≤ 3, h=0.1
  5. For each initial condition, a label "y(0) = (value)" but with the actual value, at an appropriate location
  6. For each solution curve, a label "y(3) ≈ (Euler's method value)" but with the actual value, or "y(3) = ?", at an appropriate location

Print on 8.5x11 paper in landscape format.

First letter of my last name is P.

Solutions

Expert Solution


%%Matlab code for ode solution and direction field
clear all
close all
%First letter of my last name is P
M=16;
k=1/M;

%function to be solved

f=@(t,y) (1/16).*y.*(16-y);
t_ini=-3;
t_end=3;

%Plotting Direction field
figure(1)
dirrfield(f,-3:0.2:3,-M/2:1:3*M/2)
hold on
%all initial condition
y0=[5*M/4 M M/2 0 -M/4];
%all time steps
tinit=0;tend=3; h=0.1;
%plot for different initial velocity
for i=1:length(y0)
  
   [ts,ys]=Euler(f,tinit,y0(i),tend,h);
   plot(ts,ys,'b','Linewidth',2)
   fprintf('\tUsing Euler methid For y(0)=%f , y(%2.2f) is %f\n',y0(i),ts(end),ys(end))

end

hold off
title('phase potrait plot')
xlabel('time in sec.')
ylabel('Concentration ')


%%Matlab function for direction filed
function dirrfield(f,tval,yval)
% dirfield(f, t1:dt:t2, y1:dy:y2)
%
%   plot direction field for first order ODE y' = f(t,y)
%   using t-values from t1 to t2 with spacing of dt
%   using y-values from y1 to t2 with spacing of dy
%
%   f is an @ function, or an inline function,
%     or the name of an m-file with quotes.
%
% Example: y' = -y^2 + t
%   Show direction field for t in [-1,3], y in [-2,2], use
%   spacing of .2 for both t and y:
%
%   f = @(t,y) -y^2+t
%   dirfield(f, -1:.2:3, -2:.2:2)

[tm,ym]=meshgrid(tval,yval);
dt = tval(2) - tval(1);
dy = yval(2) - yval(1);
fv = vectorize(f);
if isa(f,'function_handle')
fv = eval(fv);
end
yp=feval(fv,tm,ym);
s = 1./max(1/dt,abs(yp)./dy)*0.75;
h = ishold;
quiver(tval,yval,s,s.*yp,0,'r'); hold on;
%quiver(tval,yval,-s,-s.*yp,0,'r');
if h
hold on
else
hold off
end
axis([tval(1)-dt/2,tval(end)+dt/2,yval(1)-dy/2,yval(end)+dy/2])
end

function [t_euler,y_euler]=Euler(f,tinit,yinit,tend,h)
    %Euler method
    % h amount of intervals
    t=tinit;         % initial t
    y=yinit;         % initial y
    t_eval=tend;     % at what point we have to evaluate
    n=(t_eval-t)/h; % Number of steps
    t_euler(1)=t;
    y_euler(1)=y;
    for i=1:n
        %Eular Steps
        m=double(f(t,y));
        t=t+h;
        y=y+h*m;
        t_euler(i+1)=t;
        y_euler(i+1)=y;
    end
  
end

%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%


Related Solutions

Let M be the integer corresponding to the first letter of your last name. For example,...
Let M be the integer corresponding to the first letter of your last name. For example, if your last name begins with "A", M=1 and if your last name begins with "Z", M=26. Let k=1/M and consider the logistic equation dy/dt = k y (M - y). Construct a single figure including Title "Logistic Equation Slope Field and Euler's Method solutions by FirstName LastName" with your actual first and last names, along the top Labels for the axes a slope...
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
Select a Fortune 500 company whose name starts with the first letter in your last name...
Select a Fortune 500 company whose name starts with the first letter in your last name and obtain the company’s most recent 10-K report. (You may use the same company that you used previously.) Be sure that the company has a complex capital structure. Attach the equity section of the balance sheet and the notes relevant to answering the following questions: (a) Does the company have preferred stock and common stock (or different classes of common stock)? Do its stocks...
Based on the letter of your last name in ASAP will be how you are assigned...
Based on the letter of your last name in ASAP will be how you are assigned your state: a. Last Name starts with the letter A-D, you choose from one of these states i. Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware Introduction Portion (10%) a. Discuss where and how the Coronavirus originated. b. Explain why you chose the state from the given list above; in other words, reasoning based on area, peaked at the better stats first, etc. c....
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name, that does the following: Create two arrays that will hold related information. You can choose any information to store, but here are some examples: an array that holds a person's name and an array that hold's their phone number an array that holds a pet's name and an array that holds what type of animal that pet is an array that holds a student's...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name, that does the following: Declare an array reference variable called myFavoriteSnacks for an array of String type. Create the array so that it is able to hold 10 elements - no more, no less. Fill the array by having each array element contain a string stating one of your favorite foods/snacks. Note: Only write the name of the snack, NO numbers (i.e. Do not...
Part 1: Create a character array and save your first and last name in it
PROGRAMMING IN C:Part 1:Create a character array and save your first and last name in itNote: You can assign the name directly or you can use the scanf function.Display your name on the screen.Display the address (memory location) in hexadecimal notation of the array. (hint: use %p)Use a for loop to display each letter of your name on a separate line.Part 2:Create a one dimensional array and initialize it with 10 integers of your choice.Create a function and pass the...
Name your file “DMx1_Your last name_Your first name.” You can use MS Word to complete the...
Name your file “DMx1_Your last name_Your first name.” You can use MS Word to complete the matrices (go to Insert, Table, Insert table, fill the table). Save the file as a PDF file. If you draw the matrices on paper, take pictures. Make sure the pictures are clear and readable. Insert the pictures in MS Word document and save it as a PDF file. 1. Align using dot matrix: horizontal sequence – AGGCTCCC, vertical sequence – GCGCTCCG. Trace and explain...
Write the pseudocode that prompts the user for their first and last name. Display the first...
Write the pseudocode that prompts the user for their first and last name. Display the first initial of their first name and their last name to the user. Ask the user to input a phone number. The program checks which part of Colorado a phone number is from using the values below. If the second digit of the phone number is one of the below digits, print the phone number and which part of Colorado it is from. If none...
SQL statmen: List the first name, the last name, the address, the city, the state, the...
SQL statmen: List the first name, the last name, the address, the city, the state, the branchNo, and the email of agents working in the branch B005 and having email addresses ending with extensions different from .com.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT