Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ExDecaiEulerMin28-01-21
# Gráfico em 3 dimensões # Resolver a equação f(x,y)=(f1(x,y),f2(x,y))=(0,0). f1<-function(s,r){ x=s y=r f1=y*x^3+y^4+2*x*y+x+y+1 f1 } f2<-function(s,r){ x=s y=r f2=y*x^2+2*x*y+x+5 f2 } x <- seq(-5,2, by=0.05) y <- seq(-2,2,by=0.05) mf<-function(s,r){ x=s y=r f1(x,y)^2+f2(x,y)^2 # |f(x,y)|^2; auxiliar para gráfico } require(grDevices) # for trans3d z <- outer(x, y, mf) z[is.na(z)] <- 4 op <- par(bg = "white") persp(x, y, z, theta = 60, phi = 20, expand = 1) contour(x,y,z,levels=c(0.5,1,5,10)) # persp(x, y, z, theta = 60, phi = 20, expand = 1)->res # Método de Euler oara resolver a equação u'(t)=-grad f(u(t)), e(0)=(2,-2) gradmf<-function(u){ # gradiente de f(x,y) s=u[1] r=u[2] h=10^(-5) dnfx= mf(s+h,r)-mf(s-h,r) dnfy=mf(s,r+h)-mf(s,r-h) c(dnfx,dnfy)/(2*h) } t0=0 # tempo inicial tf=1 # t final e0=c(2,-2) # condição inicial mf(e0[1],e0[2]) # teste da escolha n=2000 h=(tf-t0)/n # Tamanho do passo tt=seq(t0,tf,by=h) Y=matrix(0,2,length(tt)) Y[,1]=e0 for ( i in 1:(length(tt)-1)){ Y[,i+1]=Y[,i]-h*gradmf(Y[,i]) } print("Aproximação para o ponto de máximo"); Y[,length(tt)] print("Aproximação para o valor máximo"); mf(Y[1,length(tt)],Y[2,length(tt)]) lines(trans3d(Y[1,],Y[2,],mf(Y[1,],Y[2,]), res), col = "blue", lwd = 2) # Inclui curvas plot(Y[1,],Y[2,],col="blue") plot(tt,mf(Y[1,],Y[2,]), col = "blue") #------------------------------ f<-function(s,r){ x=s y=r c(f1(x,y),f2(x,y)) } f(1,2) Jacf<-function(u){ # gradiente de f(x,y) s=u[1] r=u[2] h=10^(-5) dfx= f(s+h,r)-f(s-h,r) dfy=f(s,r+h)-f(s,r-h) A=matrix(0,2,2) A[1,]=dfx; A[2,]=dfy A/(2*h) } Jacf(c(1,2)) alpha<-function(u){min(eigen(t(Jacf(u))%*%Jacf(u))$values)} alpha0=0*tt for ( i in 1:length(tt)){ alpha0[i]=alpha(Y[,i])} alpha1=min(alpha0) points(tt,mf(Y[1,1],Y[2,1])*exp(-sqrt(alpha1)*tt), col = "red") plot(tt,sqrt(alpha0), col = "red")
run
|
edit
|
history
|
help
0
Sampling Distribution for the Wald-Wolfowitz 2-Sample Runs Test
Dendrogramm_Clusteranalyse_Länderflächen_euclid_average
time series
Permutations&Combinations
jcfatorial
subset_in_r
Ludy Thenor Research Methods I- Final Part 2
Compute & Plot (approx.) Solar Declination Function f(d)
Mathematical operations
Example R Code