# fortran代写 | Homework assignment

这个作业是用fortran完成一些编程小练习

Homework assignment: structure of a program

1. Write FORTRAN90 code that converts temperature in Fahrenheit to Celsius. Plot

Fahrenheit vs. Celsius between -20C and +45C. On the graph note the average

temperatures for Phoenix metropolitan area between January and March (1), April – June

(2), July – September (3), and October – December (4).

2. Write FORTRAN90 code to generate data files with two columns. First column should

correspond to x and the second to y that satisfy the following equation

[called folium of Descartes]: . Generate three data files for a = 2, a = 3, and

a = 4. Plot all three curves in a single figure. Hint: you need to find parametric representation of

this curve [do online research].

3. Write FORTRAN90 code that calculates π using Gregory series:

Plot your result as a function of N to demonstrate numerical convergence. In the same

figure plot horizontal line corresponding to the exact value of π. Note that if you start

with huge values of N your result is most likely already converged. Begin with small N.

4. Write FORTRAN90 code that generates the following function

Note that in actual calculations you cannot use infinite number of terms in the series.

You thus need to ensure you have enough terms for each x. Plot this function for several

values of N to demonstrate numerical convergence. Also note that if you do plot this

3 3 x y axy + -××× 3 0 =

( ) 1

1

1

4 lim

2 1

n N

N n n

p

+

®¥ =

æ ö – = × ç ÷ ç ÷ × – è ø

å

( ) 2

1

sin

lim , 0 20

N

N n

x

n fx x

n

p ®¥ =

æ ö æ ö ç ÷ ç ÷ è ø = ç ÷ ££ × ç ÷ ç ÷ è ø

å

function for N = 10000 and N = 100000000 your results are most likely to show nearly

identical curves you thus need to experiment to see the minimum number of terms

needed and take a few N that are also smaller than that. Ultimately you want to show

how several lines begin to approach converged data.

5. Write FORTRAN90 code that calculates the product of two matrices. Check if the code is

properly written by calculating the following:

1

2

123 111

3 2 1, 1 2 3,

111 321

,

[, ] .

A B

C AB

C AB A B B A

æ öæ ö ç ÷ç ÷ = =

è øè ø

= ×

= ! ×-×