Universidade Federal da Paraíba
Programa de Pós-Graduação em Economia do Setor Público
# Criar sequências de 100 números ordenadas entre -3 e 3
options(OutDec=",")
x <- seq(-3,3,length=100)
# Definir função constante: f(x) = 3
y1 <- function(x1) {rep(3,length(x1))}
# Definir função linear: f(x) = 2 + 3*x
y2 <- function(x1) {2 + 3*x1}
# Definir função quadrática: f(x) = 1 + x - 2x^2
y3 <- function(x1) {1 + x1 - 2*x1^2}
# Definir função cúbica: f(x) = 1 + x + 3*x^2 - 2*x^3
y4 <- function(x1) {1 + x1 + 3*x1^2 - 2*x1^3}
# Desenhar gráficos
par(mfrow=c(2,2))
plot(x,y1(x),type="l",bty="l",cex.lab=0.8,cex.axis=0.8,col="blue",lwd=2,las=1,
main=expression(f(x) == 3),ylab=expression(f(x)))
grid(col=grey(0.80))
plot(x,y2(x),type="l",bty="l",cex.lab=0.8,cex.axis=0.8,col="blue",lwd=2,las=1,
main=expression(f(x) == 2 + 3*x),ylab=expression(f(x)))
grid(col=grey(0.80))
plot(x,y3(x),type="l",bty="l",cex.lab=0.8,cex.axis=0.8,col="blue",lwd=2,las=1,
main=expression(f(x) == 1 + x - 2*x^2),ylab=expression(f(x)))
grid(col=grey(0.80))
plot(x,y4(x),type="l",bty="l",cex.lab=0.8,cex.axis=0.8,col="blue",lwd=2,las=1,
main=expression(f(x) == 1 + x + 3*x^2 - 2*x^3),ylab=expression(f(x)))
grid(col=grey(0.80))