Search code examples
differential-equationsscilab

Scilab to Find Roots of Differential Equation


How to determine the roots of differential function. I use ode to solve the function:

enter image description here

g=9.81//m/s^2
l=1.0//m
function phiprim=f(t,phi)
    phiprim(1)=phi(2)
    phiprim(2)=phi(1)*(-g/l)
endfunction
t0=0
tmax=%pi
step=0.05
t=t0:step:tmax
phi0=25/180*%pi // 25° in rad umgerechnet
phiprim0=0 // entspricht phi' bzw. Phi1'
phi=ode([phi0;phiprim0],t0,t,f)

enter image description here

So far, so good. But how can I determine the roots of φ(t) and φ'(t) in Scilab?
Using ode_root function is throwing an error "invalid index":

deff("[z]=gr(t,phi)","z=phi(1)") // should find the roots of phi function
ng=1
[phi,rd]=ode("root",phi0,t0,tmax,f,ng,gr)

Thanks!


Solution

  • Use ode with root finding parameter. Here is the online doc but you can find it with help ode_root

    https://help.scilab.org/docs/6.1.0/en_US/ode_root.html