Discussion notes, MAE 185. Friday May 12,2006

Nasser Abbasi

On HW3

We need to use Netwon's method for root finding. We need to count how many steps it takes to get close enough to a root depending from where we started the search. We need to do this in 2D instead of 1D.

The recursive step is MATH

Where $Z_{n+1}$ is the new 2D point (the point getting closer to the root, we hope) and $Z_{n}$ is the previous 2D point.

When to stop this iterative process?

We said in the discussion to stop when MATH

However, this is not really the correct approach. Instead we need to check that we have converged when

MATH

Then we will stop.

Since this assignment involves using complex numbers with Fortran, and some of you might not have done this before, I will show an example implementation and how to generate different plots from the result, using both Matlab and Mathematica. I will use the first function in the problem set as an illustration. The function is

MATH


compiling and generating the text file.

I used GNU fortran 95 compiler (g95). The program prints the output to stdout, so you need to pipe the output to a text file that will contain the data itself. Use the following commands:


command.png

display the data using Mathematica

Assume that your text file called "T2.TXT" is located in a folder called "C:\myfolder\". Now start Mathematica and issue the following commands: (These plots where generated using an $\varepsilon =0.01$, and $\Delta =0.04$ where $\Delta $ is the distance between one point and the next in the grid. See the source code for more details).


mma.png

display the data using Matlab

Start matlab and issue these commands (the plots can be rotated if needed so they align with the ones shown in the classroom).


matlab.png

Adding colors to the plots.

In Matlab you can use the contourf command (not the contour command) to fill the spaces between the contour lines with color shading, then one can use the options on the Matlab figure window itself to make more adjustments to the colors as needed. These are some results shown below. (I rotated some of these plots by hand to make them align to the same direction as the samples shown in the class, but this is not important to do).


matlab2.png


matlab3.png

Fortran source code


fig1.png

Quick review for Midterm

To convert an $n$ order ODE to $n$ first order ODE's

Example 1

MATH

Since we have a second order ODE, we need 2 state variables.

MATH

Take derivatives w.r.t. the independent variable $x$

MATH

Back substitute for all the derivatives of the dependent variable $y$, noting that MATH

MATH

Example 2

MATH

Since a 4th order ODE, need to create 4 new state variables

MATH

Take derivatives w.r.t. the independent variable $x$

MATH

back substitute, noting that MATH

MATH