Apr 9, 2013 ... http://www.math.drexel.edu/~jb3455/MATH-262-ST13/HW/ ... modified. It is a
script to call all the other matlab functions you have implemented.
Advanced matlab operations Jean-Luc Bouchot
[email protected] April 9, 2013
Introductory remark This homework is splitted in two completely independent parts. Start with the lab section and do the theoretical part only once you are done with the programming part.
1
Theoretical aspects
Apply one of the method from the course to solve the following first order ordinary differential equations. Try to justify as much as you can. dy = −t2 y dt dy −y dt dy dt dy dt dy dt
= cos(3t) − 3 sin(2t) t y y = t =
=−
(1) (2) (3) (4)
t y
(5)
Graph some solutions to the second differential equation. Precise which initial value problem they fulfil.
2
Matlab works
Download the working package at http://www.math.drexel.edu/~jb3455/MATH-262-ST13/HW/homework1b.zip and unpack it in a working directory of your choice. Open Matlab in this directory and open the file asgn1b.m. Follow the instruction and modify the code accordingly. The file asgn1b.m should not be modified. It is a script to call all the other matlab functions you have implemented. This programming exercise will have nothing to do with differential equations but is intended as a help for a better understanding of matlab programming. Most of the exercises here will be independent of each others. Do not hesitate (and it is actually highly recommended) to read the file asgn1b.m to understand how everything works. If you modify it, please indicate the reasons for this modification in a separate file. Exercise 1. Complete the function numberprimes.m that counts the number of prime numbers until a certain value. It has one input: n the number we need to reach and one output: m the number of prime numbers less or equal to n. Hint: Check the function isprime.m. 1
MATH-262-ST13
HW 1b: Matlab 2
J.-L. Bouchot
Exercise 2. Complete the function primedistribution.m returns the repartition of prime numbers. It has one input: n the highest number we want to reach and a single output. It should be used to display a graph similar to that:
Exercise 3. Modify the function graphsines.m such that it displays up to n (an input) sine waves with frequency 2π/1, 2π/2, · · · 2π/n. It should create such a graph:
Exercise 4 (Optional exercise:). The way we graph the distribution of prime numbers is not efficient. Create a new function that returns the distribution of prime numbers in linear time (i.e. if we plot the time needed to calculate the distribution depending on the highest number we want to reach, it should be a straight line)
3
Deliverables
By Monday, 15th of April, you should submit: 2
MATH-262-ST13
HW 1b: Matlab 2
• Your solution to the analytical exercises above • All your codes in a single package entitled LastName-262-asgn1b.zip. • Provide the different graphs you generated (can be added in the package) • Answer the inline questions.
3
J.-L. Bouchot