0% found this document useful (0 votes)
36 views2 pages

Flipped Lecture 3 Discussion February 5th 2020

1. The document discusses analyzing the expression 1:4+exp(-2:2) and calculating various mathematical expressions and functions. 2. It defines several functions, including f(x) = kx exp(2x) for different values of k, a function to approximate the derivative of the log, and a "tent function". 3. Various conclusions are drawn from comparing vectors and evaluating functions, such as verifying numerically that the derivative of log x is 1/x.

Uploaded by

NikuBotnari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Flipped Lecture 3 Discussion February 5th 2020

1. The document discusses analyzing the expression 1:4+exp(-2:2) and calculating various mathematical expressions and functions. 2. It defines several functions, including f(x) = kx exp(2x) for different values of k, a function to approximate the derivative of the log, and a "tent function". 3. Various conclusions are drawn from comparing vectors and evaluating functions, such as verifying numerically that the derivative of log x is 1/x.

Uploaded by

NikuBotnari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Flipped Lecture 3

Discussion February 5th 2020

1. Analyze the expression 1:4+exp(-2:2) and figure out where R is work-


ing component-wise. Is recycling needed? Which is the number that is
recycled?

2. What would you type on the console to calculate:

(a) e3 + 1/42
(b) log2 (1000)
(c) Is 3π > 10?

3. Define the function f (x) = kx exp(2x), where k is a parameter, which


takes by the default the value 1. Compute the value of the function at
the points -5:5 when k = 1 and when k = 2.

4. Can you comfortably read the outcome of the previous question? How
many numbers are in the interval [0, 1]?

5. We want to numerically show that the derivative of log x is x1 .

(a) Define an approximation dlog of the derivative of the log. Use a


default step h = 0.0001.
(b) Compute dlog at the points 1:10 and call the resulting vector v.
Now define u <- 1/1:10 (explain why this is meaningful using
precedence rules).
(c) Now compare the vectors u and v. This can also be done looking
at v-u or typing summary(v-u).
(d) Which conclusion on the derivative can you draw?

6. Define a function sumfraction having as arguments r, s, t and such that


sumfraction(r,s,t) show the numerator and denominator of r + s/t.
For instance:

> sumfraction(1,2,3)

[1] 5 3

> sumfraction(2,1,0)

1
[1] "denominator is zero!"

7. Define the “tent function”:


(
2x if x < 0.5
2 − 2x if x > 0.5

Then type curve(tent(x),-2,2) to see its graph. [errors will be dis-


cussed in class...]

You might also like