{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df8f26f6-9181-47d3-9fca-1073a8b1f800",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d6abb25e-b1dd-42e4-b3fe-9a97fafff771",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pint; u=pint.UnitRegistry()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "cad37186-f45a-469b-96eb-ec027831a3a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "mn = 1.67495E-27 *u.kg    # kg\n",
    "c = 299792458.0*u.m/u.s      # m/s\n",
    "E = 2E6*u.eV         # neutron energy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "1ac05cae-40ee-47a1-b690-981e88481c99",
   "metadata": {},
   "outputs": [],
   "source": [
    "v1 = c*np.sqrt(1-(E/mn/c/c + 1)**-2)\n",
    "v2 = (2*E/mn)**0.5\n",
    "v2.ito(u.m/u.s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "a27bc67b-0893-4d4a-af5b-85c85dc02ccf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(19529530.11596374 <Unit('meter / second')>,\n",
       " 19560694.43931547 <Unit('meter / second')>)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "v1, v2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "136e6484-a1ec-4324-8f61-83c85f56d43e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "0.06514350042776505 dimensionless"
      ],
      "text/latex": [
       "$0.06514350042776505\\ dimensionless$"
      ],
      "text/plain": [
       "0.06514350042776505 <Unit('dimensionless')>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "v1/c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "89e5bb97-533e-4499-a048-798f499e3ea3",
   "metadata": {},
   "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.9.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
