Skip to content
Snippets Groups Projects
Commit 96290ffa authored by Eduardo E. R. Junior's avatar Eduardo E. R. Junior
Browse files

Oculta mensagens de warning no animation newton-raphson

A função arrows retorna warnings quando se chega próximo ao ponto
objetivo, nestas iterações finais a função não consegue traçar as
flechas devido a pequena diferença entre valores.
parent ddcbaa22
No related branches found
No related tags found
1 merge request!15Issue#14
......@@ -170,13 +170,16 @@ while(i<100 & dif>tol){
## Demostração do algoritmo Newton-Raphson para otimização de função
saveHTML({
for(j in 2:i){
curve(fx0, -10, 10, main=paste("passo ", j-1, ", (x = ",
round(x[j],2), ")", sep=""))
abline(h=0, lty=2)
arrows(x[j-1], fx0(x[j-1]), x[j], fx0(x[j]), length=0.1, col=3, lwd=2)
abline(v=x[j], h=fx0(x[j]), lty=3, col=2)
}
for(j in 2:i){
suppressWarnings({
curve(fx0, -10, 10, main=paste("passo ", j-1, ", (x = ",
round(x[j],2), ")", sep=""))
abline(h=0, lty=2)
arrows(x[j-1], fx0(x[j-1]), x[j], fx0(x[j]),
length=0.1, col=3, lwd=2)
abline(v=x[j], h=fx0(x[j]), lty=3, col=2)
})
}
abline(v=x[i], h=fx0(x[i]), col=2, lwd=2)
text(0, -3, label="CONVERGIU!", cex=2)
ani.pause() },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment