# Exemplo de método de reta tangente ou de Euler
F<-function(s,u){
1+u^2
}
b=-1.5
a=0
n=15
h=(b-a)/n
t=seq(a,b,by=h)
y=0*t;
y[1]=1 # Foi dado que y(0)=1
n=length(y)
for ( i in 1:(n-1)){
y[i+1]=y[i]+h*F(t[i],y[i])
}
# Sabemos que a solução exata é y(t)=tg(t+pi/4)
f<-function(s){tan(s+pi/4)}
curve(f,-1.5,0)
points(t,y,col="red")
plot(t,f(t)-y)
To embed this project on your website, copy the following code and paste it into your website's HTML: