1. Construct the function and do the followings: f(x)= x^2-x+1. Evaluate f(x) at x=2200. Graph the function using the command curve().
x=2200
((2200^2)- (2220) + 1)
## [1] 4837781
curve(x^2-x+1)
f(x) at x=2200 equals 4,837,781
2. First create an array of x=-10:10 with step size h=0.01. Create the sine and tangent curve. Label the graph with x axis, y axis and the title. Use the plot() function. #seq(-10,10, by = 0.01)
t=seq(0,10,0.1)
y=sin(t)
plot(t,y,type="l", xlab="time", ylab="Sine wave", main="Sine")
t=seq(0,10,0.1)
y=tan(t)
plot(t,y,type="l", xlab= "Time", ylab="Tan Wave", main="Tangent")
3. Define g(x)=sin(cos(x)e^(-x/2)). Draw this function with x=-10:10 and number of nodes=2001.
c<- function(x) sin(cos(x)* exp(-x/2))
plot(c, -10, 10, n=2001)
4. Create a very smooth, red colored cosine curve.
t=seq(0,10,0.1)
y=cos(t)
plot(t,y,type="l", xlab= "Time", ylab="Cos Wave", main="Cosine", col="red", lwd=2)
5. Generate a step/staircase function using plot() command for x epsilon [0,10)
x=seq(0:9)
y=seq(0:9)
plot(y, x, type = "s")
6. Create another step function. A. Using the function
h<- function(x) ifelse(x<3, x, x+1)
B. Now draw the function from 0 to 6 using the command. C.Add a solid red dot at the right place.
h<- function(x) ifelse(x<3, x, x+1)
curve(expr = h, from=0, to=6)
curve(expr = h, from=3, to=6, add=TRUE)
points(3, h(3), pch=21, bg="red")
7. Calculate the limits A.
library(Ryacas)
## Warning: package 'Ryacas' was built under R version 3.5.3
x <- Sym("x")
Limit(sin(x)/x, x, 0)
## expression(1)
B.
library(Ryacas)
x <- Sym("x")
Limit(sin(x)/sin(3*x), x, 0)
## expression(1/3)
C.
library(Ryacas)
x <- Sym("x")
Limit(1/(x^2), x, 0)
## expression(Inf)
8. Evaluate the followings: (a.)Greatest Integer Function and (b.) Least Integer Function at x=1.234
floor(1.234)
## [1] 1
ceiling(1.234)
## [1] 2
9. Find the derivative of the following functions:
f=expression(exp^(x^2+sin(x)))
D(f,'x')
## exp^(x^2 + sin(x)) * (log(exp) * (2 * x + cos(x)))
g=expression(log(x^2)+sin(2*x)+ tan(x^3))
D(g,'x')
## 2 * x/x^2 + cos(2 * x) * 2 + 3 * x^2/cos(x^3)^2
10. Integrate the following functions.
library(Ryacas)
x <- Sym("x")
Integrate({1/((x+1)*sqrt(x))}, x)
## expression(defint(integer_interval(1/((x + 1) * root(x, 2)),
## NaN), lambda(x, NaN)))
integrand2 <- function(x) {1/((x+1)*sqrt(x))}
integrate(integrand2, lower = 0, upper = Inf)
## 3.141593 with absolute error < 2.7e-05