Für jede Funktion werden dargestellt:
f_a <- function(x) 4*x^4 - 6*x^2
f1_a <- function(x) 16*x^3 - 12*x
f2_a <- function(x) 48*x^2 - 12
x_a <- seq(-2, 2, length.out = 1000)
df_a <- data.frame(x = x_a)
xw_a <- c(-0.5, 0.5)
yw_a <- f_a(xw_a)
tan_a1 <- function(x) f1_a(xw_a[1])*(x - xw_a[1]) + f_a(xw_a[1])
tan_a2 <- function(x) f1_a(xw_a[2])*(x - xw_a[2]) + f_a(xw_a[2])
p_a1 <- ggplot(df_a, aes(x)) +
geom_line(aes(y = f_a(x)), color="blue") +
geom_point(
data = data.frame(x = xw_a, y = yw_a),
aes(x = x, y = y),
color="red",
size=3
) +
geom_line(aes(y = tan_a1(x)), linetype="dashed") +
geom_line(aes(y = tan_a2(x)), linetype="dashed") +
ggtitle("Aufgabe a: f(x)")
p_a2 <- ggplot(df_a, aes(x)) +
geom_line(aes(y = f1_a(x)), color="darkgreen") +
ggtitle("f'(x)")
p_a3 <- ggplot(df_a, aes(x)) +
geom_line(aes(y = f2_a(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("f''(x)")
grid.arrange(p_a1, p_a2, p_a3, ncol=1)
f_b <- function(x) 0.25*x^4 - 6*x^2 + 3
f1_b <- function(x) x^3 - 12*x
f2_b <- function(x) 3*x^2 - 12
x_b <- seq(-4, 4, length.out = 1000)
df_b <- data.frame(x = x_b)
xw_b <- c(-2, 2)
yw_b <- f_b(xw_b)
tan_b1 <- function(x) f1_b(xw_b[1])*(x - xw_b[1]) + f_b(xw_b[1])
tan_b2 <- function(x) f1_b(xw_b[2])*(x - xw_b[2]) + f_b(xw_b[2])
p_b1 <- ggplot(df_b, aes(x)) +
geom_line(aes(y = f_b(x)), color="blue") +
geom_point(
data = data.frame(x = xw_b, y = yw_b),
aes(x = x, y = y),
color="red",
size=3
) +
geom_line(aes(y = tan_b1(x)), linetype="dashed") +
geom_line(aes(y = tan_b2(x)), linetype="dashed") +
ggtitle("Aufgabe b: f(x)")
p_b2 <- ggplot(df_b, aes(x)) +
geom_line(aes(y = f1_b(x)), color="darkgreen") +
ggtitle("f'(x)")
p_b3 <- ggplot(df_b, aes(x)) +
geom_line(aes(y = f2_b(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("f''(x)")
grid.arrange(p_b1, p_b2, p_b3, ncol=1)
f_d <- function(x) sin(x)
f1_d <- function(x) cos(x)
f2_d <- function(x) -sin(x)
x_d <- seq(-pi/2, 3*pi/2, length.out = 1000)
df_d <- data.frame(x = x_d)
xw_d <- c(0, pi)
yw_d <- f_d(xw_d)
tan_d1 <- function(x) f1_d(xw_d[1])*(x - xw_d[1]) + f_d(xw_d[1])
tan_d2 <- function(x) f1_d(xw_d[2])*(x - xw_d[2]) + f_d(xw_d[2])
p_d1 <- ggplot(df_d, aes(x)) +
geom_line(aes(y = f_d(x)), color="blue") +
geom_point(
data = data.frame(x = xw_d, y = yw_d),
aes(x = x, y = y),
color="red",
size=3
) +
geom_line(aes(y = tan_d1(x)), linetype="dashed") +
geom_line(aes(y = tan_d2(x)), linetype="dashed") +
ggtitle("sin(x)")
p_d2 <- ggplot(df_d, aes(x)) +
geom_line(aes(y = f1_d(x)), color="darkgreen") +
ggtitle("cos(x)")
p_d3 <- ggplot(df_d, aes(x)) +
geom_line(aes(y = f2_d(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("-sin(x)")
grid.arrange(p_d1, p_d2, p_d3, ncol=1)
f_e <- function(x) cos(x)
f1_e <- function(x) -sin(x)
f2_e <- function(x) -cos(x)
x_e <- seq(0, 2*pi, length.out = 1000)
df_e <- data.frame(x = x_e)
xw_e <- c(pi/2, 3*pi/2)
yw_e <- f_e(xw_e)
tan_e1 <- function(x) f1_e(xw_e[1])*(x - xw_e[1]) + f_e(xw_e[1])
tan_e2 <- function(x) f1_e(xw_e[2])*(x - xw_e[2]) + f_e(xw_e[2])
p_e1 <- ggplot(df_e, aes(x)) +
geom_line(aes(y = f_e(x)), color="blue") +
geom_point(
data = data.frame(x = xw_e, y = yw_e),
aes(x = x, y = y),
color="red",
size=3
) +
geom_line(aes(y = tan_e1(x)), linetype="dashed") +
geom_line(aes(y = tan_e2(x)), linetype="dashed") +
ggtitle("cos(x)")
p_e2 <- ggplot(df_e, aes(x)) +
geom_line(aes(y = f1_e(x)), color="darkgreen") +
ggtitle("-sin(x)")
p_e3 <- ggplot(df_e, aes(x)) +
geom_line(aes(y = f2_e(x)), color="purple") +
geom_hline(yintercept = 0, linetype="dotted") +
ggtitle("-cos(x)")
grid.arrange(p_e1, p_e2, p_e3, ncol=1)
x_v <- seq(-4, 4, length.out = 1000)
df_v <- data.frame(
x = x_v,
f_a = 4*x_v^4 - 6*x_v^2,
f_b = 0.25*x_v^4 - 6*x_v^2 + 3
)
ggplot(df_v, aes(x)) +
geom_line(aes(y = f_a), color="blue") +
geom_line(aes(y = f_b), color="red") +
ggtitle("Vergleich: Aufgabe a und b")