Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
26-08-2020Teste
# Minimo para resolver equação f(x)=0. x=seq(-5,5,by=0.5);x n=length(x) erro=runif(n, min = -0.25, max = 0.25) f<-function(s){20*s^2/(s^4+2*s+3)} curve(f,-5,5) y=f(x)+erro;y points(x,y,col="red") g<-function(u){ a=u[1];b=u[2];c=u[3] p=0 for (i in 1:n){ p=p+( y[i]- 20*x[i]^2/(a*x[i]^4+b*x[i]+c) )^2} p/2 } g(c(1,1,1)) gradng<-function(u){ h=0.00001 v=u; v[1]=u[1]+h dgx=(g(v)-g(u))/h v=u; v[2]=u[2]+h dgy=(g(v)-g(u))/h v=u; v[3]=u[3]+h dgz=(g(v)-g(u))/h c(dgx,dgy,dgz) } # Método de Euler ZeroEuler<-function(u0,t,n){ w=matrix(0,3,n+1) w[,1]=u0 h=t/n for (i in 1:n){w[,i+1]=w[,i]-h*gradng(w[,i])} w } # Teste u0=c(1,1,1); t=1; n=1000 g(u0) gradng(u0) u=ZeroEuler(u0,t,n) ; u [,n+1] # Aproximadamente u(100) g(u[,n+1])
run
|
edit
|
history
|
help
0
1.second
PUP LDA
Sierpinski curve
2q
Análise de Variâncias DIC e teste de Tukey 1
Comparison between Normal and Laplace models for option pricing
,k
taylorsen7
16-09-2020IntPoli
Chi-squared tests of independence [m musculoskeletal injuries treated]