Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
26-08-2020AjusteCurvab
# Minimo para resolver equação f(x)=0. x=seq(-5,5,by=0.5) n=length(x) y=c(76.7717771, 66.3145240, 56.4127785, 47.2264003, 38.9028982, 31.3924261, 24.3614203, 17.8432769, 11.0583345, 3.7080725, -0.1512441, 4.0841671, 11.2307420, 17.5647328, 24.0860429, 31.2664318, 39.0262100, 47.3342189, 56.5095134, 66.1088441, 76.7198095) 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,1,2)) 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,1,2)) # Método de Euler ZeroEuler<-function(u0,t,n){ u=u0 h=t/n for (i in 1:n){u=u-h*gradg(u)} u } # Teste u0=c(1,1,2); t=20; m=20000 u=ZeroEuler(u0,t,m) ; u # Aproximadamente u(20) a=u[1]; b=u[2]; c=u[3] f<-function(s){20*s^2/log(a*s^4+b*s^2+c)} curve(f,-5,5) points(x,y,col="red") g(u)
run
|
edit
|
history
|
help
0
As1-1
此次次
Variance Gamma process
Carr Madan formula for Laplace distribution
Hello, world!
Gab1A
Chi Square Tests [Is the die fair?]
EulerEx3
лул
Ch. 4 Boxplot Skewed Left