From 96290ffa532ad22394cdc597a2fa744267eb4b24 Mon Sep 17 00:00:00 2001 From: Eduardo Junior <edujrrib@gmail.com> Date: Tue, 22 Mar 2016 00:32:13 -0300 Subject: [PATCH] Oculta mensagens de warning no animation newton-raphson MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- animation/animation.Rmd | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/animation/animation.Rmd b/animation/animation.Rmd index 0d68716..dfee356 100644 --- a/animation/animation.Rmd +++ b/animation/animation.Rmd @@ -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() }, -- GitLab