Question

1. Consider the function y f(x) defined by Supposing that you are given x, write an R expression for y using if state- ments Add your expression for y to the following program, then run it to plot the function f. # input x,values <-seq(-2, 2, by 0.1) # for each x calculate y n <- length(x.values) y.values <- rep(0, n) for (i in 1 :n) x <- x. values[i] # your expression for y goes here y.values ij <- y # output plot(x.values, y.values, type1) Your plot should look like Figure 3.2. Do you think f has a derivative at 1? What about at 0? We remark that it is possible to vectorise the program above, using the ifelse function.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

R-code:

Console Terminal x. values-seq-2,2,by-0.1) > n-length(X. values) > y. values rep (0,n) > y=0 > for (i in 1:n) x=x. values [i] +if (x<-0) +else if { y.values [i]-y (x<-1) y=XA2 else y=sqrt (x) > piot (x.values.y.values,type=1 , mai n=function of x)

Output:

function of X 12 一寸 髦3 -2 0 x.values

i) No, f is not derived at x = 1 since f(x) is not continuous at x = 1

ii) Yes, f is derived at x = 0 since f(x) is continuous at x = 0

Add a comment
Know the answer?
Add Answer to:
1. Consider the function y f(x) defined by Supposing that you are given x, write an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT