Challenge

Week 3 - Solving second order ODEs

Write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping

in the above equation

g = gravity in m/s2,

L = length of the pendulum in m,

m = mass of the ball in kg,

b=damping coefficient.

input values

L=1 metre,

m=1 kg,

b=0.05.

g=9.81 m/s2.

Simulate the motion between 0-20 sec, for angular displacement=0,angular velocity=3 rad/sec at time t=0.

Step 1

convert the 2nd degree ode into 1st degree ode

theta = theta1

d theta/dt = d theta1/dt = d theta2

d theta/dt + b*theta/m+g*sin theta1/L

Step 2

create the function of ODE

Step 3

create simple pendulum program by using ODE function

intial condition are provided - pi/2 is displacement and 0 is angular velocity

time interval 0 - 50 sec in 200 steps

solve ode equation by using ode45function

create plot and animation

google drive link for the animation video :- https://drive.google.com/file/d/18OW0WoXtNryU7Rf2Mn2FKsmoXEB3uFR6/view?usp=sharing

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.