2025-09-28
library(shiny)
ui <- fluidPage(
titlePanel("Variación de funciones polinómicas - Rectas"),
sidebarLayout(
sidebarPanel(
sliderInput("m", "Pendiente (m):", min = -5, max = 5, value = 1),
sliderInput("b", "Ordenada en el origen (b):", min = -10, max = 10, value = 0)
),
mainPanel(
plotOutput("rectaPlot")
)
)
)
server <- function(input, output) {
output$rectaPlot <- renderPlot({
x <- seq(-10, 10, length.out = 200)
y <- input$m * x + input$b
plot(x, y, type = "l", col = "blue", lwd = 2,
main = "Recta: y = mx + b", xlab = "x", ylab = "y")
abline(h = 0, v = 0, col = "green", lty = 2)
grid()
})
}
shinyApp(ui = ui, server = server)
library(shiny)
ui <- fluidPage(
titlePanel("Variación de funciones polinómicas - Parábolas"),
sidebarLayout(
sidebarPanel(
sliderInput("a", "Coeficiente cuadrático (a):", min = -5, max = 5, value = 1),
sliderInput("b", "Coeficiente lineal (b):", min = -10, max = 10, value = 0),
sliderInput("c", "Término independiente (c):", min = -10, max = 10, value = 0)
),
mainPanel(
plotOutput("parabolaPlot")
)
)
)
server <- function(input, output) {
output$parabolaPlot <- renderPlot({
x <- seq(-10, 10, length.out = 200)
y <- input$a * x^2 + input$b * x + input$c
plot(x, y, type = "l", col = "purple", lwd = 2,
main = "Parábola: y = ax² + bx + c", xlab = "x", ylab = "y")
abline(h = 0, v = 0, col = "green", lty = 2)
grid()
})
}
shinyApp(ui = ui, server = server)
library(shiny)
ui <- fluidPage(
titlePanel("Variación de funciones polinómicas - Grado 3 y 4"),
tabsetPanel(
tabPanel("Polinomio grado 3",
sidebarLayout(
sidebarPanel(
sliderInput("a3", "Coeficiente x³ (a):", min = -2, max = 2, value = 1, step = 0.05),
sliderInput("b3", "Coeficiente x² (b):", min = -5, max = 5, value = 0),
sliderInput("c3", "Coeficiente x (c):", min = -5, max = 5, value = 0),
sliderInput("d3", "Constante (d):", min = -5, max = 5, value = 0)
),
mainPanel(
plotOutput("cubicoPlot")
)
)
),
tabPanel("Polinomio grado 4",
sidebarLayout(
sidebarPanel(
sliderInput("a4", "Coeficiente x⁴ (a):", min = -1, max = 1, value = 1, step = 0.01),
sliderInput("b4", "Coeficiente x³ (b):", min = -2, max = 2, value = 0),
sliderInput("c4", "Coeficiente x² (c):", min = -5, max = 5, value = 0),
sliderInput("d4", "Coeficiente x (d):", min = -5, max = 5, value = 0),
sliderInput("e4", "Constante (e):", min = -5, max = 5, value = 0)
),
mainPanel(
plotOutput("cuarticoPlot")
)
)
)
)
)
server <- function(input, output) {
output$cubicoPlot <- renderPlot({
x <- seq(-10, 10, length.out = 200)
y <- input$a3 * x^3 + input$b3 * x^2 + input$c3 * x + input$d3
plot(x, y, type = "l", col = "green", lwd = 2,
main = "Polinomio grado 3: y = ax³ + bx² + cx + d",
xlab = "x", ylab = "y")
abline(h = 0, v = 0, col = "green", lty = 2)
grid()
})
output$cuarticoPlot <- renderPlot({
x <- seq(-10, 10, length.out = 200)
y <- input$a4 * x^4 + input$b4 * x^3 + input$c4 * x^2 + input$d4 * x + input$e4
plot(x, y, type = "l", col = "red", lwd = 2,
main = "Polinomio grado 4: y = ax⁴ + bx³ + cx² + dx + e",
xlab = "x", ylab = "y")
abline(h = 0, v = 0, col = "green", lty = 2)
grid()
})
}
shinyApp(ui = ui, server = server)