{
    "cells": [
        {
            "cell_type": "markdown",
            "source": [
                "# Doing Homework\n",
                "\n",
                "The Jupyter Notebook is a good environment for working on your Physics homework\n",
                "(or [Statics](../statics/ipynb.html) \n",
                "or [Dynamics](../dynamics/ipynb/index.html) homework).\n",
                "\n",
                "Having a tool like this is even more helpful when\n",
                "your problems become more complicated,\n",
                "which is certain to happen in a science or engineering career.\n",
                "\n",
                "## Workflow\n",
                "\n",
                "Make a folder for your class on your computer\n",
                "(or on [OneDrive](https://libguides.madisoncollege.edu/technology/onedrive)\n",
                "if you're using the College computers).\n",
                "For each homework set, start a new Jupyter Notebook in that folder with a \n",
                "name such as `HW10`.\n",
                "\n",
                "For each problem, take a screenshot to display.\n",
                "Solve the problem on paper using symbols rather than numbers\n",
                "(see [Symbolic Problem Solving](../notes/symbolic_solving.html)).\n",
                "Scan or photograph your written work to link in the Notebook.\n",
                "Use your symbolic solution to write the final equations in Python\n",
                "to obtain a numerical result.\n",
                "\n",
                "By the end of the semester, you'll have a great resource you can \n",
                "use for review or future re-use.\n",
                "\n",
                "## Advantages\n",
                "\n",
                "Here are a few reasons to make the extra effort to use a coding environment.\n",
                "\n",
                "1. If you make a mistake, it's easy to tweak then re-run the calculations.\n",
                "   It's also easy to find the solution for different input parameters.\n",
                "1. You can share your work and results with other students or with the instructor \n",
                "   if you have questions.\n",
                "1. You can save your work for later review or re-use.\n",
                "1. You don't have to worry about keeping significant digits.\n",
                "   The computer maintains a very high precision.\n",
                "1. You can explore interesting ideas further. \n",
                "   Make a graph, or explore alternate scenarios.\n",
                "   This is the way to master the ideas you learn in class.\n",
                "1. You may be able to use advanced Python libraries like [SciPy](https://scipy.org/)\n",
                "   and [NumPy](https://numpy.org/) to help find the solution.\n",
                "1. You will get better at coding, which is a valuable skill.\n",
                "   The Jupyter Notebook is a powerful and widely used method for \n",
                "   sharing technical information.\n",
                "   You will be ready when you're not just solving homework problems,\n",
                "   but working with a team on a complex project.\n",
                "\n",
                "----------------------------------------------------\n"
            ],
            "metadata": {}
        },
        {
            "cell_type": "markdown",
            "source": [
                "## Example Problem\n",
                "\n",
                "![](images/doing_hw.svg)\n",
                "\n",
                "[my hand-written solution](images/doing_hw_solution.png)\n"
            ],
            "metadata": {}
        },
        {
            "cell_type": "code",
            "source": [
                "from numpy import *\n",
                "theta = 40*pi/180  # angle in radians\n",
                "h = 2              # height in m\n",
                "mu = 0.8           # friction coefficient\n",
                "g = 9.8            # m/s\u00b2\n",
                "v = sqrt( 2*g*h*(1- mu/tan(theta)) )\n",
                "print('v = ',v,' m/s')"
            ],
            "metadata": {},
            "execution_count": null,
            "outputs": []
        },
        {
            "cell_type": "markdown",
            "source": [
                "That's the answer, but \n",
                "I wonder what the graph of final speed vs ramp angle looks like.\n"
            ],
            "metadata": {}
        },
        {
            "cell_type": "code",
            "source": [
                "import matplotlib.pyplot as plt\n",
                "th = linspace(2,89) \n",
                "v = sqrt( 2*g*h*(1- mu/tan(th*pi/180)) )\n",
                "plt.plot( th, v )\n",
                "plt.grid()\n",
                "plt.xlabel('ramp angle, degrees')\n",
                "plt.ylabel('final speed, m/s');"
            ],
            "metadata": {},
            "execution_count": null,
            "outputs": []
        },
        {
            "cell_type": "markdown",
            "source": [
                "The `invalid value` warning is due to the failure of the equation\n",
                "when $\\theta \\lt 38.7^\\circ = \\tan^{-1} \\mu$.\n",
                "Then we have the square-root of a negative value.\n"
            ],
            "metadata": {}
        }
    ],
    "metadata": {},
    "nbformat": 4,
    "nbformat_minor": 5
}