-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdc9081
commit f05b30c
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
f05b30c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numarical solution using scipy
f05b30c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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