Solution_via_Graphs_Codes
Solution_via_Graphs_Codes
1.0
0.5
0.0
x
Clearly, NO SOLUTION
## ------------------------------------------------------------------
## Ex: By plotting the graph, find the solution of 1+x^2=exp(x).
x <- seq(-1, 1, 0.01)
y1 <- 1+x*x
y2 <- exp(x)
plot(x, y1, type="l", col="blue", lwd=2, ylim=c(0,3))
lines(x, y2, type="l", col="red", lwd=2)
3.0
2.5
2.0
1.5
y1
1.0
0.5
0.0
Solution : x=0
## ------------------------------------------------------------------
## Ex: By plotting the graph, find the solution of 1-x^2=exp(x).
x <- seq(-1, 1, 0.01)
y1 <- 1-x*x
y2 <- exp(x)
plot(x, y1, type="l", col="blue", lwd=2, ylim=c(0,2))
lines(x, y2, type="l", col="red", lwd=2)
2.0
1.5
1.0
y1
0.5
0.0
2.0
1.5
1.0
0.5
y2
0.0
-0.5
-1.0
NO SOLUTION
## ------------------------------------------------------------------
## Ex: By plotting the graph, find the solution of x=cos(x).
x <- seq(0.0, 2*pi, length=100)
y1 <- cos(x)
y2 <- x
plot(x, y2, type="l", col="blue", lwd=2, ylim=c(-1,3))
lines(x, y1, type="l", col="red", lwd=2)
3
2
1
0
-1
0 1 2 3 4 5 6
x
SOLUTION x=0.74
## ------------------------------------------------------------------
## Ex: By plotting the graph, find the solution of x=sin(x).
x <- seq(0, 2*pi, length=100)
y1 <- sin(x)
y2 <- x
plot(x, y2, type="l", col="blue", lwd=2, ylim=c(-1,2))
lines(x, y1, type="l", col="red", lwd=2)
2.0
1.5
1.0
0.5
y2
0.0
-0.5
-1.0
0 1 2 3 4 5 6
SOLUTION x=0
## ------------------------------------------------------------------