//
// pendulum.sci
//
// Scilab vector field functions for: pendulum
//
// This file was generated by the program VFGEN, version: 2.5.0-dev
// Generated on 14-May-2014 at 21:04
//

//
// pendulum_vf
//
// The vector field 
//
function vf_ = pendulum_vf(t,x_,p_)
    Pi = %pi;
    theta      = x_(1);
    v          = x_(2);
    g          = p_(1);
    b          = p_(2);
    L          = p_(3);
    m          = p_(4);
    vf_ = zeros(2,1);
    vf_(1) = v;
    vf_(2) = -L^(-1)*g*sin(theta)-L^(-2)*v*m^(-1)*b;
endfunction

//
// pendulum_jac
//
// The Jacobian of the vector field
//
function jac_ = pendulum_jac(t,x_,p_)
    Pi = %pi;
    theta      = x_(1);
    v          = x_(2);
    g          = p_(1);
    b          = p_(2);
    L          = p_(3);
    m          = p_(4);
    jac_ = zeros(2,2);
    jac_(1,2) = 1;
    jac_(2,1) = -L^(-1)*g*cos(theta);
    jac_(2,2) = -L^(-2)*m^(-1)*b;
endfunction

//
// pendulum_energy
//
// This function implements the user-defined function "energy"
//
function r_ = pendulum_energy(t,x_,p_)
    Pi = %pi;
    theta      = x_(1);
    v          = x_(2);
    g          = p_(1);
    b          = p_(2);
    L          = p_(3);
    m          = p_(4);
    r_ = 1/2*L^2*v^2*m-L*m*g*cos(theta);
endfunction
