Skip to content

Commit

Permalink
Q_9_BVP and its plot
Browse files Browse the repository at this point in the history
  • Loading branch information
subhasmannna875 committed Apr 24, 2024
1 parent 8006dbb commit 6c4d8c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Q_9_D_boundary_value_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def bc(ya, yb):

# Define the range of x values where we want to solve the ODE
x = np.linspace(0, np.pi, 100)
x_valus=x.copy()
# Exact solution that is given in the book
def exact(x):
return 2+np.sin(x)
y_exat=exact(x_valus)

# Initial guess for the solution
y_guess = np.zeros((2, x.size))
Expand All @@ -20,7 +25,8 @@ def bc(ya, yb):
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[0], label='numarical solution',linestyle="--")
plt.plot(x_valus,y_exat,label="exact analytical solution")
plt.xlabel('x')
plt.ylabel('y')
plt.title("Solution of y'' = 1/2 - (y')^2/2 - y*sin(x)/2")
Expand Down

2 comments on commit 6c4d8c3

@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.

9DD
python plot

@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
mathematica plot

Please sign in to comment.