Zu jeder Funktion werden dargestellt:
f <- function(x) 4*x^4 - 6*x^2
f1 <- function(x) 16*x^3 - 12*x
f2 <- function(x) 48*x^2 - 12
f3 <- function(x) 96*x
x <- seq(-2, 2, length.out = 1000)
df <- data.frame(x = x)
xw <- c(-0.5, 0.5)
yw <- f(xw)
tan1 <- function(x) f1(xw[1])*(x - xw[1]) + f(xw[1])
tan2 <- function(x) f1(xw[2])*(x - xw[2]) + f(xw[2])
p1 <- ggplot(df, aes(x)) +
geom_line(aes(y = f(x)), color="blue") +
geom_point(data=data.frame(x=xw,y=yw), aes(x=x,y=y), color="red", size=3) +
geom_line(aes(y = tan1(x)), linetype="dashed") +
geom_line(aes(y = tan2(x)), linetype="dashed") +
ggtitle("f(x)")
p2 <- ggplot(df, aes(x)) +
geom_line(aes(y = f1(x)), color="darkgreen") +
ggtitle("f'(x)")
p3 <- ggplot(df, aes(x)) +
geom_line(aes(y = f2(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("f''(x)")
p4 <- ggplot(df, aes(x)) +
geom_line(aes(y = f3(x)), color="orange") +
ggtitle("f'''(x)")
grid.arrange(p1, p2, p3, p4, ncol=1)
f <- function(x) sin(x)
f1 <- function(x) cos(x)
f2 <- function(x) -sin(x)
f3 <- function(x) -cos(x)
x <- seq(-pi/2, 3*pi/2, length.out = 1000)
df <- data.frame(x = x)
xw <- c(0, pi)
yw <- f(xw)
tan1 <- function(x) f1(xw[1])*(x - xw[1]) + f(xw[1])
tan2 <- function(x) f1(xw[2])*(x - xw[2]) + f(xw[2])
p1 <- ggplot(df, aes(x)) +
geom_line(aes(y = f(x)), color="blue") +
geom_point(data=data.frame(x=xw,y=yw), aes(x=x,y=y), color="red", size=3) +
geom_line(aes(y = tan1(x)), linetype="dashed") +
geom_line(aes(y = tan2(x)), linetype="dashed") +
ggtitle("sin(x)")
p2 <- ggplot(df, aes(x)) +
geom_line(aes(y = f1(x)), color="darkgreen") +
ggtitle("cos(x)")
p3 <- ggplot(df, aes(x)) +
geom_line(aes(y = f2(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("-sin(x)")
p4 <- ggplot(df, aes(x)) +
geom_line(aes(y = f3(x)), color="orange") +
ggtitle("-cos(x)")
grid.arrange(p1, p2, p3, p4, ncol=1)
f <- function(x) 3*x^2 - x^3
f1 <- function(x) 6*x - 3*x^2
f2 <- function(x) 6 - 6*x
f3 <- function(x) -6
x <- seq(-1, 3, length.out = 1000)
df <- data.frame(x = x)
xw <- 1
yw <- f(xw)
tan <- function(x) f1(xw)*(x - xw) + f(xw)
p1 <- ggplot(df, aes(x)) +
geom_line(aes(y = f(x)), color="blue") +
geom_point(data=data.frame(x=xw,y=yw), aes(x=x,y=y), color="red", size=3) +
geom_line(aes(y = tan(x)), linetype="dashed") +
ggtitle("f(x)")
p2 <- ggplot(df, aes(x)) +
geom_line(aes(y = f1(x)), color="darkgreen") +
ggtitle("f'(x)")
p3 <- ggplot(df, aes(x)) +
geom_line(aes(y = f2(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("f''(x)")
p4 <- ggplot(df, aes(x)) +
geom_hline(yintercept = -6, color="orange") +
ggtitle("f'''(x)")
grid.arrange(p1, p2, p3, p4, ncol=1)
f <- function(x) 2*x^2 - (1/3)*x^4 + 3
f1 <- function(x) 4*x - (4/3)*x^3
f2 <- function(x) 4 - 4*x^2
f3 <- function(x) -8*x
x <- seq(-2, 2, length.out = 1000)
df <- data.frame(x = x)
xw <- c(-1, 1)
yw <- f(xw)
tan1 <- function(x) f1(xw[1])*(x - xw[1]) + f(xw[1])
tan2 <- function(x) f1(xw[2])*(x - xw[2]) + f(xw[2])
p1 <- ggplot(df, aes(x)) +
geom_line(aes(y = f(x)), color="blue") +
geom_point(data=data.frame(x=xw,y=yw), aes(x=x,y=y), color="red", size=3) +
geom_line(aes(y = tan1(x)), linetype="dashed") +
geom_line(aes(y = tan2(x)), linetype="dashed") +
ggtitle("f(x)")
p2 <- ggplot(df, aes(x)) +
geom_line(aes(y = f1(x)), color="darkgreen") +
ggtitle("f'(x)")
p3 <- ggplot(df, aes(x)) +
geom_line(aes(y = f2(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("f''(x)")
p4 <- ggplot(df, aes(x)) +
geom_line(aes(y = f3(x)), color="orange") +
ggtitle("f'''(x)")
grid.arrange(p1, p2, p3, p4, ncol=1)