-
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
f05b30c
commit 8272687
Showing
1 changed file
with
29 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,29 @@ | ||
import numpy as np | ||
from scipy.integrate import solve_bvp | ||
import matplotlib.pyplot as plt | ||
|
||
def ode(x, y): | ||
y1, y2 = y #y1=y ,y2=y' | ||
dydx = [y2, y2 * np.cos(x) - y1 * np.log(y1)] #define derivitive | ||
return dydx | ||
# define boundary condition | ||
def bc(ya, yb): | ||
return np.array([ya[0] - 1, yb[0] - np.exp(1)]) | ||
|
||
# Define the range of x values where we want to solve the ODE | ||
This comment has been minimized.
Sorry, something went wrong. |
||
x = np.linspace(0, np.pi/2, 100) | ||
|
||
# Initial guess for the solution | ||
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.xlabel('x') | ||
plt.ylabel('y') | ||
plt.title('Solution of y\'\' = y\' * cos(x) - y * ln(y)') | ||
plt.legend() | ||
plt.grid() | ||
plt.show() |
2 comments
on commit 8272687
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.
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.
i uploded wrong code