[scilab-Users] Problem with division by zero
CRETE Denis
denis.crete at thalesgroup.com
Tue Jul 19 19:29:04 CEST 2011
Hello,
it may have to do with the (non-physical?) expression of the ODE.
Besides the fact that the last term is mathematically ill-defined (starting with "+/"), in the case K=0, the second derivative of X is positive for x<%pi/2: it may then reach the value %pi/2, which makes denominators be 0.
Physically, these denominators (%pi/2-X) look very strange as they may govern divergence of the force in the last term.
However, it appears also in the first term, where divergence is prevented because of (1-sin X): it may than be necessary to rewrite the function (1-sinX)/(%pi/2-X), with the addition of the case X=%pi/2, where the function goes to 0 by continuity.
HTH
Denis
De : arnaud dujeu [mailto:fangorn813 at hotmail.com]
Envoyé : mardi 19 juillet 2011 11:46
À : users at lists.scilab.org
Objet : [scilab-Users] Problem with division by zero
Hi,
I am using scilab to solve a differential equation and I have an error ("error 27") I don't understand.
When K=1 pr K>1 it's okay but as soon as K<1 there is the error.
This is my code :
function [Xprime]=VanDerPol(t, X)
Xprime(1) = X(2)
Xprime(2) = g/R*(1-sin(X(1)))/(%pi/2-X(1))-(mu*(K)*R^2*((X(2))^2)/2)+/(R^2*mu*(%pi/2-X(1)))
endfunction
t=linspace(0,4,3000); X0=[85*%pi/180;0];
[u]=ode(X0,0,t,VanDerPol);
plot(t,u(1,:)*180/%pi,'r')
plot(t,R*u(2,:))
And there is the Scilab message when K<1 :
-->exec('C:\Documents and Settings\ademollerat\My Documents\accelerometre\Ecoulement\VanDerPol-2.sci', -1)
Attention: redéfinition de la fonction: VanDerPol . Utilisez funcprot(0) pour éviter ce message
!--error 27
Division par zéro ...
at line 7 of function VanDerPol called by :
[u]=ode(X0,0,t,VanDerPol);
at line 35 of exec file called by :
exec('C:\Documents and Settings\ademollerat\My Documents\accelerometre\Ecoulement\VanDerPol-2.sci', -1)
Maybe I have made a mistake or maybe it is a bug.
Thank you for helping me.
Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110719/411990a2/attachment.htm>
More information about the users
mailing list