title: Scilab to Find Roots of Differential Equation
body: <p>How to determine the roots of differential function. I use <code>ode</code> to solve the function:</p>
  <p><a href="https://i.stack.imgur.com/cTC2n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cTC2n.png" alt="enter image description here" /></a></p>
  <pre><code>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)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/TDu5Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TDu5Y.png" alt="enter image description here" /></a></p>
  <p>So far, so good. But how can I determine the roots of <code>φ(t)</code> and <code>φ'(t)</code> in Scilab? <br/>Using <code>ode_root</code> function is throwing an error &quot;invalid index&quot;:</p>
  <pre><code>deff(&quot;[z]=gr(t,phi)&quot;,&quot;z=phi(1)&quot;) // should find the roots of phi function
  ng=1
  [phi,rd]=ode(&quot;root&quot;,phi0,t0,tmax,f,ng,gr)
  </code></pre>
  <p>Thanks!</p>