library(ggplot2)
Falls Sie den Graphen in R-Studio nachzeichnen möchten, können Sie
folgenden Code verwenden. Hinweis: Stellen Sie sicher, dass das
Paket ggplot2 installiert ist
(install.packages("ggplot2"), falls der Fehler weiterhin
besteht.
# 1. Paket laden
library(ggplot2)
# 2. Approximierte Funktion für f'(x) zur Visualisierung
# Dies ist eine Näherungsfunktion, die den gezeichneten Verlauf imitiert
f_prime <- function(x) {
ifelse(x < -1, (x + 2)^2 - 0.5,
ifelse(x < -0.5, -(x + 1)^2 + 0.2,
ifelse(x < 0, (x + 0.5)^2 - 0.1,
ifelse(x < sqrt(2), -(x - 0.5)^2 - 0.5,
(x - 2)^2 - 0.3
)
)
)
)
}
# 3. Daten für den Plot erstellen
x_vals <- seq(-3, 3, by = 0.01)
y_vals <- sapply(x_vals, f_prime)
data_plot <- data.frame(x = x_vals, y = y_vals)
# 4. Plot erstellen
ggplot(data_plot, aes(x = x, y = y)) +
geom_line(color = "blue", size = 1) +
geom_hline(yintercept = 0, linetype = "dashed", color = "gray") +
geom_vline(xintercept = c(0, 2, sqrt(2)), linetype = "dotted", color = "red") +
labs(title = "Graph der Ableitungsfunktion f'(x)",
x = "x", y = "f'(x)") +
theme_minimal()