Skip to content

Instantly share code, notes, and snippets.

@vuddameri
Created April 30, 2024 19:46
Show Gist options
  • Select an option

  • Save vuddameri/c4138836cc74bb30515597b3bfd015a7 to your computer and use it in GitHub Desktop.

Select an option

Save vuddameri/c4138836cc74bb30515597b3bfd015a7 to your computer and use it in GitHub Desktop.
Assignment4-Problem6.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/vuddameri/c4138836cc74bb30515597b3bfd015a7/assignment4-problem6.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"id": "0b489577",
"metadata": {
"id": "0b489577"
},
"source": [
"<h4> Assignment 4 Problem 6 - Problem Statement"
]
},
{
"cell_type": "markdown",
"id": "63e6a704",
"metadata": {
"id": "63e6a704"
},
"source": [
"Verify by substitution that $ y_c = c_1x + c_2 \\frac{1}{x}$ is the complementary solution of the following differential equation $x^2y\" + xy' - y = 72x^5$\n",
"\n",
"**Complementary Solution Corresponds to the Homogeneous Part of the ODE**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "1b58a35c",
"metadata": {
"id": "1b58a35c"
},
"outputs": [],
"source": [
"# Import libraries\n",
"import sympy as sp"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e0e56793",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 37
},
"id": "e0e56793",
"outputId": "4f711199-3440-4da5-fd66-8d7834422a7d"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"0"
],
"text/latex": "$\\displaystyle 0$"
},
"metadata": {},
"execution_count": 4
}
],
"source": [
"# define variables and equation\n",
"x = sp.symbols('x') # define independent variable x\n",
"c1 = sp.symbols('c1') # define constant c1\n",
"c2 = sp.symbols('c2') # define constant c2\n",
"yc = c1*x + c2*1/x # Write the complementary solution\n",
"ypc = yc.diff(x) # take the first derivative of yc\n",
"yppc = yc.diff(x,x) # take the second derivative of yc\n",
"ode = x*x*yppc + x*ypc - yc # substite the yc, yc' and yc'' terms into the ode\n",
"sp.simplify(ode) # simplify the expression to see if it results in a value of zero."
]
},
{
"cell_type": "markdown",
"id": "69cc0e3c",
"metadata": {
"id": "69cc0e3c"
},
"source": [
"As yc is the complementary solution, the substitution into the RHS of the ODE should lead to a value of zero. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51658250",
"metadata": {
"id": "51658250"
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
},
"colab": {
"provenance": [],
"include_colab_link": true
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment