Estratto del documento

Exercise number one

First version

Consider the numbers n1 and n2. Then say whether both numbers are small and the first is larger than the second.

Conditions:

  • n1 < 1
  • n2 < 1
  • n1 > n2

If the result is TRUE: 1.00 FALSE: 0.00

Second version

Consider the numbers n1 and n2. Then say whether both numbers are large and n1 is larger than n2.

Conditions:

  • n1 > 1
  • n2 > 1
  • n1 > n2

If the result is TRUE: 1.00 FALSE: 0.00

Exercise number two

Draw the line and the parabola y = f1, y = f2 over the interval [n1, n2] and find the ordinate of the lowest point belonging to the graphs.

  • f <- function(x) f write first the parabola
  • g <- function(x) f than the line
  • curve(f, n1, n2)
  • curve(g, n1, n2, add = T, col = 2)

Analyse the graph, there can be two alternatives:

  • First case: The lowest point coincides with the minimum of the parabola between point a and b.
  • Second case: The lowest point coincides with the minimum of the line between point a and b.
  • Third case: From the graph, the lowest y corresponds to x = ...

optimize(f, c(a, b))
optimize(g, c(a, b))

Ordinate of the lowest point: $objective

Exercise number three

Consider the expression a + b. Which of the following statements holds?

  • The last recycled number was ... or The first recycled number was ...
  • There was no need to recycle any argument

Recycling: When vectors have different lengths, in an operation some arguments are replicated to perform the computation

  • a <- vector a
  • b <- vector b
  • a + b (shows the results)
  • a (shows the numbers in a)
  • b (shows the numbers in b)

Check which was the last or first recycled number:

  • ! 1 - 11!

Exercise number four

Let x <- and y <-. Consider the functions g(x) = and h(x) =. Plot both the exponential function and the line functions and the points defined by x and y on the interval [a, b]. Which of the following sentence is true?

  • The curve is mostly below the line and ... points are below the graph of the exponential.
  • The curve is mostly above the line and ... points are below the graph of the exponential.
  • x <- point
  • y <- function
  • g <- function(x) exp(...)
  • h <- function(x) line
  • curve(g, a, b)
  • curve(h, a, b, add = T, col = 2)
  • analyse the graph
  • points(x, y)

Exercise number five

First version: vector

Type and press enter. Then immediately store in a vector normal pseudo-random numbers with mean and standard deviation. Compute the sum of components of the vector, starting from position a.

  • set.seed(...) v <- rnorm(100, m, sd)
  • sum(v[a:((a+b)-1)])
  • generates a vector: rnorm(...)

Second version: matrix

Type and press enter. Then immediately create a matrix, filled by columns with (standard) random uniform numbers. Let be the product of the matrix times the vector (n1, n2, n3). Finally, provide the sum of the components of u.

  • set.seed(...) Z <- matrix(runif(r*c), r, c, byrow = F)
  • v <- c(n1, n2, n3)
  • u <- Z %*% v
  • sum(u) → answer
  • To create a matrix by rows instead of by columns, use the argument byrow = T
  • generates random uniform numbers runif(...)

Exercise number six

First version: maximize

Maximize, if possible, the following function over the interval [a, b]: f1(x) =. Write the objective function at the optimum or -999 if there is no solution.

  • f <- function(x) func
  • curve(f, a, b)
  • maxlooking at the graph you can see x = ... point can be found in an interval
  • f(...) optimize(f, c(a, b), maximum = T)

Second version: minimize

Minimize, if possible, the following function over the interval [a, b]: f1(x) =. Write the objective function at the optimum or -999 if there is no solution.

  • f <- function(x) func
  • curve(f, a, b)
  • looking at the graph you can see x = ... min point can be found in an interval
  • f(...) optimize(f, c(a, b))
  • ! 2 - 11! or: value of min and max on the x-axis | value on the y-axis $minimum $maximum $objective

Exercise number seven

Adds lines to a previously drawn plot: abline

First version

First case

In the smartphone market, the number of customers (in billions) of Samsung and Apple can be modeled by the functions:

  • f(x) = x/100 + 0.17e0.079x
  • g(x) = 0.32 + 0.024x

Where x > 0 denotes year 2000 + x.

· When is Samsung reaching one billion customers for the first time?

  • f <- function(x) x/100 + 0.17 * exp(0.079 * x)
  • h <- function(x) f(x) - 1
  • x refers to years; we must consider only positive values
  • curve(h(x), 0, 100)
  • since...
  • curve(h(x), 0, 50)
  • curve(h(x), 0, ...)
  • abline(h = 0, col = 2)
  • grid(col = 3)
  • shown in graph
  • uniroot(h, c(0, ...)) interval
  • → $root correct result

Second case

In the smartphone market, the number of customers (in billions) of Motorola and Apple can be modeled by the functions:

  • f(x) = 0.21e0.088x
  • g(x) = 0.3 + 0.024x

Where x denotes year 2000 + x.

· When are the two competitors going to have the same number of customers?

  • f <- function(x) 0.21 * exp(0.088 * x)
  • g <- function(x) 0.3 + 0.024 * x
  • h <- function(x) f(x) - g(x)
  • curve(h, 0, 50)
  • curve(h, 0, ...)
  • abline(h = 0, col = 2)
  • uniroot(h, c(10, 15))
  • → $root correct result

Second version:

First case: Find the rightmost root of...

Anteprima
Vedrai una selezione di 4 pagine su 11
Computational Tools for Economics and Management Pag. 1 Computational Tools for Economics and Management Pag. 2
Anteprima di 4 pagg. su 11.
Scarica il documento per vederlo tutto.
Computational Tools for Economics and Management Pag. 6
Anteprima di 4 pagg. su 11.
Scarica il documento per vederlo tutto.
Computational Tools for Economics and Management Pag. 11
1 su 11
D/illustrazione/soddisfatti o rimborsati
Acquista con carta o PayPal
Scarica i documenti tutte le volte che vuoi
Dettagli
SSD
Scienze economiche e statistiche SECS-P/08 Economia e gestione delle imprese

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher EMMAMNRT di informazioni apprese con la frequenza delle lezioni di Computational Tools for Economics and Management e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Università degli studi Ca' Foscari di Venezia o del prof Fasano Giovanni.
Appunti correlati Invia appunti e guadagna

Domande e risposte

Hai bisogno di aiuto?
Chiedi alla community