Code:
tempFn <- function(xVec){
f = integer(length(xVec))
for (i in seq(1, length(xVec))) {
if(xVec[i] < 0){
f[i] <- xVec[i]*xVec[i] + 2*xVec[i] + 3
}
else if(xVec[i] >= 0 && xVec[i] <2){
f[i] <- xVec[i] + 3
}
else if(xVec[i] >= 2)
{
f[i] <- xVec[i]*xVec[i] + 4*xVec[i] - 7}
}
return(f)
}
xVec <- seq(-3, 3)
y <- tempFn(xVec)
print("f(x) = ")
print(y)
plot(xVec, y, 'o-')
Output of above Code:
![[1] f(x) 6 3 2 3 45 14 [1] 14 CO 3 2 1 0 -1 -2 3 xVec tol](http://img.homeworklib.com/images/ecb385e6-f13f-4596-a962-f637183b03c3.png?x-oss-process=image/resize,w_560)
R programming Consider the continuous function r22r+3 ifr < 0 f(r)=r+3 12 +4 7 if 2...
I am getting an error in R and am unsure how to correct it. I am
getting an error from the r2 line, "Error in xc[1:(n - 2)] : only
0's may be mixed with negative subscripts."
tmpFn <- function(xVec)
{
xc <- xVec - mean(xVec)
denom <- sum(xc^2)
n <- length(x)
r1 <- sum( xc[2:n] * xc[1:(n-1)] )/denom
r2 <- sum( xc[3:n] * xc[1:(n-2)] )/denom
list(r1 = r1, r2 = r2)
}
tmpFn(seq(2, 56, 3))
10. (a) Given a...
*PLEASE DO IN MATHEMATICA*
{:1, ifr+ 13. Consider the function f(x)- nction,f(x)-e-r/rifx#0 a. Plot the graph of this function using Mathematica. b. Use the limit definition of the derivative and LHopital's Rule to show that every higher-order derivative of f at r 0 vanishes. c. Find the MacLaurin series for f. Does the series converge to f?
{:1, ifr+ 13. Consider the function f(x)- nction,f(x)-e-r/rifx#0 a. Plot the graph of this function using Mathematica. b. Use the limit definition of...
2. Rolle's theorem states that if F : [a, b] → R is a continuous function, differentiable on Ja, bl, and F(a) = F(b) then there exists a cela, b[ such that F"(c) = 0. (a) Suppose g : [a, b] → R is a continuous function, differentiable on ja, bl, with the property that (c) +0 for all cela, b[. Using Rolle's theorem, show that g(a) + g(b). [6 Marks] (b) Now, with g still as in part (a),...
this is Topology
3) Ifa functionf(R,T.)-(R,T) įs continuous, then f(R,Ts)-(R, т)is continuous. 4) If a function EIR, ті )-(R,%) is continuous, then e (R, T)-cR,n) is continuous. 5) If a function f: (R )-(R, Tİ) İS continuous, then f(R,7, ) → (RM) t8 continuous. 6) If a function f:(R雨)-(RM) is continuous, then f (RM )-(RM) is continuous. 7) Any two discrete topological spaces are homeomorphic. 8) Any one-to-one, onto function between two discrete topological spaces is a homeomorphism
3. Suppose f : [0,) + R is a continuous function and that L limf(x) exists is a real number). Prove that f is uniformly continuous on (0,.). Suggestion: Let e > 0. Write out what the condition L = lim,+ f(t) means for this e: there erists M > 0 such that... Also write out what you are trying to prove about this e in this problem. Note that f is uniformly continuous on (0.M +1] because this is...
Real analysis
2. Consider the following three definitions: A function f : R-+R is lax-continuous at a E R provided for all e > 0 there is a 6 > 0 such that for all r E R, if x - al6 then |f(x)- f (a)e A function f : R - R is e-continuous at a E R provided for all e >0 there is a 6 > 0 such that for all r E R, if |a- a...
3. Consider the function f(x,y) = 4 + 2x - 3y - x2 + 2y2 - 3xy. a) (5 pts.) Calculate the partial derivative functions, and use them to calculate the gradient vector evaluated at c = b) (5 pts.) Write down the affine approximation to at the e given in a) /(x) = f(c)+ Vf(e)'(x - c) . Use it to calculate (1.1, 1.1). (Hint: it should be close to f(1.1, 1.1))
x2 +7x+12 1. Consider the function: f(x)= x +3 a. Is this function continuous at x = -3? b. Does this function have a limit at x = -3? dito c. Is this function differentiable at x = -3? d. Sketch a graph of the function in the space below. Be sure to include all pertinent features.
(1) Consider the following continuous-time signal: (1) 2ua(-t+t)ua(t), where its energy is 20 milli Joules (2 x 103Joules). The signal ra(t) is sampled at a rate of 500 samples/sec to yield its discrete-time counter part (n) (a) Find ti, and hence sketch ra(t). (b) From part (a), plot r(n) and finds its energy (c) Derive an expression for the Fourier transform of a(n), namely X(ew). (d) Plot the magnitude spectrum (1X(e)) and phase spectrum 2(X(e). (e) Consider the signal y(n)...
1. Consider the function -F5 sin(r) for r f(x) =2 for 1< 3 2-25 for 3 x2 -9x + 20 Evaluate the following limits You do not have to cite limit laws, but you must show how you arrived at your answer If a limit Does Not Exist, explain why. You should use oo or -oo where applicable Calculating the limit using L'Hopital's Rule will receive NO CREDIT. (a) lim f(x) r-+0 (b) lim f(x)= z-1 (e) lim f(z) (d)...