% 単振り子の内部エネルギーの最小化

global len;
global mass;
global grav;
global torque;

len = 2.0;
mass = 0.01;
grav = 9.8;
torque = 0.01;

thetal = -pi; thetar = pi;
[thetamin, Imin] = fminbnd(@simple_pendulum_internal_energy, thetal, thetar);
fprintf("Imin = %f at theta = %f in [ %f, %f ]\n", Imin, thetamin, thetal, thetar);

thetal = -10*pi; thetar = 10*pi;
[thetamin, Imin] = fminbnd(@simple_pendulum_internal_energy, thetal, thetar);
fprintf("Imin = %f at theta = %f in [ %f, %f ]\n", Imin, thetamin, thetal, thetar);

thetal = -1000*pi; thetar = 1000*pi;
[thetamin, Imin] = fminbnd(@simple_pendulum_internal_energy, thetal, thetar);
fprintf("Imin = %f at theta = %f in [ %f, %f ]\n", Imin, thetamin, thetal, thetar);
