Need some help to solve first order differential equation with python

27 Views Asked by At

I am trying to solve the following first order non-linear differential equation by python using ODEINT. The equation I am doing Where mu and K are constant. I can not get solution for this equation.

This is the differential equation of the Barchistochrone problem, so I expecting to have a concave curve for the plot. That is what I done so far

mu = 0.5
C = 100

ax = plt.gca()
ax.xaxis.set_ticks_position('top')
ax.invert_yaxis()

def eqn(y, ydot, x, C=C, mu=mu):
    tobe = (1+mu*ydot)/np.sqrt((y-mu*x)*(1+ydot**2)) -C
    return tobe

y0 = 1
x = np.linspace(0,3,500)

solution = integrate.odeint(eqn, y0, x, args=(mu,))

plt.plot(x,solution)
plt.show()

I have a very strange output which does not meet my expectation. enter image description here What is wrong with my code and can someone solve this equation for me?

0

There are 0 best solutions below