Skip to content

Commit

Permalink
Q_9_A_BVP_Usingn scipy
Browse files Browse the repository at this point in the history
  • Loading branch information
subhasmannna875 committed Apr 23, 2024
1 parent cdc9081 commit f05b30c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Q_9_A_boundary_value_problm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import numpy as np
from scipy.integrate import solve_bvp
import matplotlib.pyplot as plt

def ode(x, y):
y1, y2 = y
dydx = [y2, -np.exp(-2*y1)]
return dydx

def bc(ya, yb):
return np.array([ya[0] - 0, yb[0] - np.log(2)])

# Initial guess for the solution
x = np.linspace(1, 2, 100)
y_guess = np.zeros((2, x.size))

# Solve the boundary value problem
sol = solve_bvp(ode, bc, x, y_guess)

# Plot the solution
plt.plot(sol.x, sol.y[0], label='y(x)')
'''
plt.plot(sol.x,sol.y[1],label="y' ")
'''
plt.xlabel('x')
plt.ylabel('y')
plt.title('Solution of y\'\' = -e^(-2y)')
plt.legend()
plt.grid()
plt.show()

2 comments on commit f05b30c

@subhasmannna875
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q_9_A
numarical solution using scipy

@subhasmannna875
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
solution get from mathematica

N.B: As differential equation is non linier so mathematica can not give exact analytical form but we get also a numarical solution and plot that ,
numarical solution get from mathematica exactly matched with the numarical solution get from python

Please sign in to comment.