Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
26-08-2020AjusteCurva
# Ajuste de curvas por mínimos quadrados x=seq(-5,5,by=0.25);x n=length(x) erro=runif(n, min = -0.25, max = 0.25) f<-function(s){20*s^2/(log(s^4+2*s^2+3))} curve(f,-5,5) y=f(x)+erro;y points(x,y,col="red") #---- Modo geral 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/log(a*x[i]^4+b*x[i]^2+c) )^2} p/2 } g(c(1,2,3)) gradg<-function(u){ a=u[1];b=u[2];c=u[3] p=c(0,0,0) for (i in 1:n){ p=p+( y[i]- 20*x[i]^2/log(a*x[i]^4+b*x[i]^2+c) )*( 20*x[i]^2/(log(a*x[i]^4+b*x[i]^2+c))^2 )*( 1/(a*x[i]^4+b*x[i]^2+c) )*c(x[i]^4,x[i]^2,1)} p } gradg(c(1,2,3)) # Método de Euler ZeroEuler<-function(u0,t,m){ w=u0 h=t/m for (i in 1:m){w=w-h*gradg(w)} w } # Teste u0=c(2,2,2); t=20; m=100000 g(u0) gradg(u0) u=ZeroEuler(u0,t,m) ; u # Aproximadamente u(t) g(u) fap<-function(s){20*s^2/(log(u[1]*s^4+u[2]*s^2+u[3]))} curve(fap,-5,5,ylim=c(0,78)) points(x,y,col="red")
run
|
edit
|
history
|
help
0
11-09-2020AproxArco
Rcode1
jcfatorial
Practica1
Prediction
5 # SUMMARY PART A
Delete True Values
factor
1
Practice series1(37)