|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 5, |
| 6 | + "id": "90a55051", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [ |
| 9 | + { |
| 10 | + "name": "stdout", |
| 11 | + "output_type": "stream", |
| 12 | + "text": [ |
| 13 | + "[0.0000000e+00 1.0000000e+00 1.2246468e-16]\n", |
| 14 | + "[ 1.000000e+00 6.123234e-17 -1.000000e+00]\n", |
| 15 | + "[ 0.00000000e+00 1.63312394e+16 -1.22464680e-16]\n" |
| 16 | + ] |
| 17 | + } |
| 18 | + ], |
| 19 | + "source": [ |
| 20 | + "#trigonometric functions\n", |
| 21 | + "#array of angles\n", |
| 22 | + "import numpy as np\n", |
| 23 | + "theta = np.linspace(0, np.pi, 3)\n", |
| 24 | + "print(np.sin(theta))\n", |
| 25 | + "print(np.cos(theta))\n", |
| 26 | + "print(np.tan(theta))" |
| 27 | + ] |
| 28 | + }, |
| 29 | + { |
| 30 | + "cell_type": "code", |
| 31 | + "execution_count": 6, |
| 32 | + "id": "f71d4ef4", |
| 33 | + "metadata": {}, |
| 34 | + "outputs": [ |
| 35 | + { |
| 36 | + "name": "stdout", |
| 37 | + "output_type": "stream", |
| 38 | + "text": [ |
| 39 | + "[-1.57079633 0. 1.57079633]\n", |
| 40 | + "[3.14159265 1.57079633 0. ]\n", |
| 41 | + "[-0.78539816 0. 0.78539816]\n" |
| 42 | + ] |
| 43 | + } |
| 44 | + ], |
| 45 | + "source": [ |
| 46 | + "#inverse trigonometry\n", |
| 47 | + "x = [-1, 0, 1]\n", |
| 48 | + "print(np.arcsin(x))\n", |
| 49 | + "print(np.arccos(x))\n", |
| 50 | + "print(np.arctan(x))" |
| 51 | + ] |
| 52 | + }, |
| 53 | + { |
| 54 | + "cell_type": "code", |
| 55 | + "execution_count": 7, |
| 56 | + "id": "f179e021", |
| 57 | + "metadata": {}, |
| 58 | + "outputs": [ |
| 59 | + { |
| 60 | + "name": "stdout", |
| 61 | + "output_type": "stream", |
| 62 | + "text": [ |
| 63 | + "[ 2.71828183 7.3890561 20.08553692]\n", |
| 64 | + "[2. 4. 8.]\n", |
| 65 | + "[ 3 9 27]\n" |
| 66 | + ] |
| 67 | + } |
| 68 | + ], |
| 69 | + "source": [ |
| 70 | + "#exponentials\n", |
| 71 | + "x = [1, 2, 3]\n", |
| 72 | + "print(np.exp(x))\n", |
| 73 | + "print(np.exp2(x))\n", |
| 74 | + "print(np.power(3, x))" |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + "cell_type": "code", |
| 79 | + "execution_count": 8, |
| 80 | + "id": "3780ac89", |
| 81 | + "metadata": {}, |
| 82 | + "outputs": [ |
| 83 | + { |
| 84 | + "name": "stdout", |
| 85 | + "output_type": "stream", |
| 86 | + "text": [ |
| 87 | + "[0. 0.69314718 1.38629436 2.30258509]\n", |
| 88 | + "[0. 1. 2. 3.32192809]\n", |
| 89 | + "[0. 0.30103 0.60205999 1. ]\n" |
| 90 | + ] |
| 91 | + } |
| 92 | + ], |
| 93 | + "source": [ |
| 94 | + "#logarithms\n", |
| 95 | + "x = [1, 2, 4, 10]\n", |
| 96 | + "print(np.log(x))\n", |
| 97 | + "print(np.log2(x))\n", |
| 98 | + "print(np.log10(x))" |
| 99 | + ] |
| 100 | + }, |
| 101 | + { |
| 102 | + "cell_type": "code", |
| 103 | + "execution_count": 9, |
| 104 | + "id": "516d9e69", |
| 105 | + "metadata": {}, |
| 106 | + "outputs": [ |
| 107 | + { |
| 108 | + "ename": "ModuleNotFoundError", |
| 109 | + "evalue": "No module named 'scipy'", |
| 110 | + "output_type": "error", |
| 111 | + "traceback": [ |
| 112 | + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
| 113 | + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", |
| 114 | + "Input \u001b[1;32mIn [9]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m#special ufuncs\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mscipy\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m special\n\u001b[0;32m 3\u001b[0m x \u001b[38;5;241m=\u001b[39m [\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m5\u001b[39m, \u001b[38;5;241m10\u001b[39m]\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(special\u001b[38;5;241m.\u001b[39mgamma(x))\n", |
| 115 | + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'scipy'" |
| 116 | + ] |
| 117 | + } |
| 118 | + ], |
| 119 | + "source": [ |
| 120 | + "#special ufuncs\n", |
| 121 | + "from scipy import special\n", |
| 122 | + "x = [1, 5, 10]\n", |
| 123 | + "print(special.gamma(x))\n", |
| 124 | + "print(special.gammaln(x))\n", |
| 125 | + "print(special.beta(x, 2))" |
| 126 | + ] |
| 127 | + } |
| 128 | + ], |
| 129 | + "metadata": { |
| 130 | + "kernelspec": { |
| 131 | + "display_name": "Python 3 (ipykernel)", |
| 132 | + "language": "python", |
| 133 | + "name": "python3" |
| 134 | + }, |
| 135 | + "language_info": { |
| 136 | + "codemirror_mode": { |
| 137 | + "name": "ipython", |
| 138 | + "version": 3 |
| 139 | + }, |
| 140 | + "file_extension": ".py", |
| 141 | + "mimetype": "text/x-python", |
| 142 | + "name": "python", |
| 143 | + "nbconvert_exporter": "python", |
| 144 | + "pygments_lexer": "ipython3", |
| 145 | + "version": "3.9.5" |
| 146 | + } |
| 147 | + }, |
| 148 | + "nbformat": 4, |
| 149 | + "nbformat_minor": 5 |
| 150 | +} |
0 commit comments