Nhiệm vụ 3:Bài 10.4
1) y’=
>library(deSolve)
> ham <- function (x, y,parms) {list(c((2*x)/(1+x^2)*y))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 0)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
2) y’+ y = 4x
> library(deSolve)
> ham <- function (x, y,parms) {list(c(-y+4*x))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times =164:174, parms = 0)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
3) y’ + 2xy = x
> library(deSolve)
> ham <- function (x, y,parms) {list(c(-2*x*y + x*exp(-1)^(x^2)))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times =164:174, parms = 0)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
>
4) y’ – ysinx = sinxcosx
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y*sin(x)+ sin(x)*cos(x)))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times =164:174, parms = 0)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
>
5) y’+ = arcsinx +x
> library(deSolve)
> ham <- function (x, y,parms) {list(c(-x*y/(1-x^2)+ asin(x)+ x))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 0)
There were 14 warnings (use warnings() to see them)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
>
6) y’ = 2x (+y)
> library(deSolve)
> ham <- function (x, y,parms) {list(c(2*x*(x^2+y)))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 0)
DINTDY- T (=R1) illegal
In above message, R1 = 167
T not in interval TCUR - HU (= R1) to TCUR (=R2)
In above message, R1 = 166.102, R2 = 166.102
DINTDY- T (=R1) illegal
In above message, R1 = 168
T not in interval TCUR - HU (= R1) to TCUR (=R2)
In above message, R1 = 166.102, R2 = 166.102
DLSODA- Trouble in DINTDY. ITASK = I1, TOUT = R1
In above message, I1 = 1
In above message, R1 = 168
Error in lsoda(y, times, func, parms, ...) :
illegal input detected before taking any integration steps - see written message
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
>
7) xy’ – 2y = 2
> library(deSolve)
> ham <- function (x, y,parms) {list(c((2*y+2*x^4)/x))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 0)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
8) y’ + y = arcsin x
> library(deSolve)
> ham <- function (x, y,parms) {list(c((-y + asin(x))/ sqrt(1-x^2)))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 0)
There were 28 warnings (use warnings() to see them)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
>
9) y’ - = x lnx
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y/(x*log(x))+ x*log(x)))}
> dieukien <- c(y = 2)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 0)
> plot(nghiem, type = "l", which = "y",lwd = 2, xlab = "Truc x", ylab = "Truc y",main =
"PTVP")
>
Nhiệm vụ 4:Bài 10.7
1) y” – 2y’ – y = 0
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y[2], 2 * y[2] + y[1]))}
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
> plot(nghiem, type = "l", which = "y1",lwd = 2, ylab = "Truc y",main = "PTVP cấp 2")
1.0e+10
5.0e+09
0.0e+00
Truc y
1.5e+10
2.0e+10
PTVP cấp 2
164
166
168
170
time
172
174
2) y” – 9y = cosx
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y[2], 9 * y[1] + exp(3)^x cos(x)))}
Error: unexpected symbol in "ham <- function (x, y,parms) {list(c(y[2], 9 * y[1] +
exp(3)^x cos"
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-119
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-119
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-115
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-115
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-115
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-114
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-114
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-114
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-114
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 2.59823e-113
DLSODA- Above warning has been issued I1 times.
It will not be issued again for this problem.
In above message, I1 = 10
> plot(nghiem, type = "l", which = "y1",lwd = 2, ylab = "Truc y",main = "PTVP cấp 2")
>
3) 4y” – 20y’ + 25y = 0
> library(deSolve)
> ham <- function (x, y,parms) {list(c(4*y[2], 20 * y[2] - 25* y[1]))}
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
> plot(nghiem, type = "l", which = "y1",lwd = 2, ylab = "Truc y",main = "PTVP cấp 2")
>
4) y” – 4y’= -12 – 6x - 4
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y[2], 4 * y[2] - 12*x - 6*x - 4 ))}
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
> plot(nghiem, type = "l", which = "y1",lwd = 2, ylab = "Truc y",main = "PTVP cấp 2")
>
5) y” – 2y’ – 3y =
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y[2], 2 * y[2] + 3 * y[1] + exp(4)^x))}
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 0
DINTDY- T (=R1) illegal
In above message, R1 = 165
T not in interval TCUR - HU (= R1) to TCUR (=R2)
In above message, R1 = 164, R2 = 164
DINTDY- T (=R1) illegal
In above message, R1 = 166
T not in interval TCUR - HU (= R1) to TCUR (=R2)
In above message, R1 = 164, R2 = 164
DLSODA- Trouble in DINTDY. ITASK = I1, TOUT = R1
In above message, I1 = 1
In above message, R1 = 166
Error in lsoda(y, times, func, parms, ...) :
illegal input detected before taking any integration steps - see written message
> plot(nghiem, type = "l", which = "y1",lwd = 2, ylab = "Truc y",main = "PTVP cấp 2")
>
6) y” – 5y’ + 4y = 4
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y[2], 5 * y[2] - 4 * y[1] + 4 * x^2 * exp(1)^x))}
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-79
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-79
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-75
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-75
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-75
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-74
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-74
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-74
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-74
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.10914e-73
DLSODA- Above warning has been issued I1 times.
It will not be issued again for this problem.
In above message, I1 = 10
> plot(nghiem, type = "l", which = "y1",lwd = 2, ylab = "Truc y",main = "PTVP cấp 2")
>
7) y” – y = 2 sin x – 4 cos x
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y[2], y[1] + 2 * sin(x) - 4 * cos(x)))}
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
> plot(nghiem, type = "l", which = "y1",lwd = 2, ylab = "Truc y",main = "PTVP cấp 2")
>
8) y” – 4y =
> library(deSolve)
> ham <- function (x, y,parms) {list(c(y[2], 4*y[1] + exp(1)^x*((-4*x +4)*cos(x)- (2*x +
6)*sin(x))))}
> dieukien <- c(y1 = 2, y2 = 1)
> nghiem <- ode(y = dieukien, func = ham,times = 164:174, parms = 1)
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-77
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-77
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-73
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-73
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-73
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-72
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-72
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-72
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-72
DLSODA- Warning..Internal T (=R1) and H (=R2) are
such that in the machine, T + H = T on the next step
(H = step size). Solver will continue anyway.
In above message, R1 = 164, R2 = 1.65096e-71
DLSODA- Above warning has been issued I1 times.
It will not be issued again for this problem.