National and Kapodistrian University of Athens

Department of Economics
Division of Mathematics and Informatics
MATH302 Dynamical Mathematics with Mathematica
T.A. PhD candidate Nick Poulios
Email: npoulios@econ.uoa.gr
http://users.uoa.gr/~npoulios/index.html
Solutions to Problem Set 2

Exercise 1

1.a.i)

lst=RandomInteger[5,10]

%!

1.a.ii)

lst^2

{1,4,9,16}

1.a.iii)

3^lst

1.a.iv)

lst^lst

lst^2+lst^3

Exercise 2

2.1)

lst3=RandomInteger[10,10]

lst4=RandomInteger[10,10]

squareQubeList=lst3^2+lst^3 (*or Plus[lst3^2,lst4^3]*)

2.2.a)

lst1=RandomInteger[100,5]

lst2=RandomInteger[100,5]

lst1+list2

2.2.b)

lst1 lst2

2.3)

Range[3,30,3]

2.4)

Table[x^2,{x,2,11}]

Length[%]

Table[y^3,{x,0,10,2},{y,0,x,2}]

2.5)

{{e,c,o},{n,o,m},{i,c,s}}

Dimensions[%]

Length[%%]

2.6)

lst5=Table[(x^(1/2)) (y^(1/2)),{x,4,5},{y,3,9}]

2.7)

f[x_,y_]=2 x^3-4 y+1;

Array[f,{4,3}]

2.7.1)

Array[f,{4,3},{2,2}]

2.8)

CharacterRange["k","t"]

Dimensions[%]

2.8.1)

First[%%]

Last[%%%]

2.8.2)

Take[%%%%,{6}]

2.8.3)

Take[%%%%%,{7,10}]

2.8.4)

Take[%%%%%%,{3,8}]

2.8.5)

g[a_,b_]=2 a^2-b;

Array[g,{3,3}]

2.8.5.a)

%[[2]]

Length[%]

2.8.5.b)

Out[168][[1]]

Out[168][[2]]

Out[168][[3]]

2.8.5.c)

Part[Out[167],{1,3}]

2.8.5.d)

Part[Part[Out[167],3],2]

Exercise 3

Clear[x]

cost=2000+3 x+0.01 x^2+0.002 x^3;

D[cost,x]

marginalCost=%

averageCost=cost/x

Plot[{marginalCost,averageCost},{x,0,500},ImageSize->600,PlotLabel->"Marginal and Average Cost", PlotLegends->{"MC","AC"}]

Exercise 4

4.a)

Directory[]

4.b)

(*change the directory path*)

data1a=Import["householdsPercentDeposit.txt","Table"];

data1b=Import["firmsPercentDeposit.txt","Table"];

4.c)

ListPlot[data1a]

ListPlot[data1b]

ListLinePlot[data1a]

ListLinePlot[data1b]

4.d)

First choice

Labeled[Show[{ListLinePlot[data1a,PlotStyle->Red,PlotLegends->"Automatic"],ListLinePlot[data1b,PlotStyle->Green,PlotLegends->"Firms"]}, PlotRange-> All],{"Deposit in Euros","per Month"},{Left,Top},RotateLabel->True]

Second choice

p1=ListLinePlot[data1a,PlotLegends->LineLegend[{Red},{Houshold}],PlotStyle->Red];

p2=ListLinePlot[data1b,PlotLegends->LineLegend[{Green},{Firms}],PlotStyle->Green];

Show[{p1,p2},AxesLabel->{"per Month","Deposit in Euros"},ImageSize-> 800]

4.e)

Export["deposits.jpeg",%]

Export["deposits.pdf",%%]