aboutsummaryrefslogtreecommitdiff
path: root/Semestr 3/anm/pracownia1/prog/program.ipynb
diff options
context:
space:
mode:
authorFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
committerFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
commitc5fcf7179a83ef65c86c6a4a390029149e518649 (patch)
treed29ffc5b86a0d257453cedcf87d91a13d8bf3b0d /Semestr 3/anm/pracownia1/prog/program.ipynb
parentf8a88b6a4aba1f66d04711a9330eaba49a50c463 (diff)
Duzy commit ze smieciami
Diffstat (limited to 'Semestr 3/anm/pracownia1/prog/program.ipynb')
-rw-r--r--Semestr 3/anm/pracownia1/prog/program.ipynb2042
1 files changed, 0 insertions, 2042 deletions
diff --git a/Semestr 3/anm/pracownia1/prog/program.ipynb b/Semestr 3/anm/pracownia1/prog/program.ipynb
deleted file mode 100644
index e5d7c6a..0000000
--- a/Semestr 3/anm/pracownia1/prog/program.ipynb
+++ /dev/null
@@ -1,2042 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 89,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "set_cordic_iterations (generic function with 1 method)"
- ]
- },
- "execution_count": 89,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "include(\"program.jl\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 90,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "Plots.PlotlyBackend()"
- ]
- },
- "execution_count": 90,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "using Plots\n",
- "using Random\n",
- "using Distributions\n",
- "\n",
- "plotly()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 91,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Zadanie 10, Franiszek malinka, Kacper Solecki\n",
- "\n",
- "# instrukcja:\n",
- "# Nasz program udostępnia funkcje \n",
- "\n",
- "# -> taylor_sin(a, b) - sinus liczby a+bi liczony za pomocą szeregu Taylora\n",
- "# -> taylor_cos(a, b) - cosinus liczby a+bi liczony za pomocą szeregu Taylora\n",
- "# -> taylor_sinh(x) - sinus hiperboliczny liczby x liczony za pomocą szeregu Taylora\n",
- "# -> taylor_cosh(x) - cosinus hiperboliczny liczby x liczony za pomocą szeregu Taylora\n",
- "# -> cordic_sin(x) - sinus (rzeczywistej) liczby x liczony za pomocą algorytmu Cordic\n",
- "# -> cordic_cos(x) - cosinus (rzeczywistej) liczby x liczony za pomocą algorytmu Cordic"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 92,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "0.9092974268256817"
- ]
- },
- "execution_count": 92,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# porównianie na sin(2), cos(2)\n",
- "sin(2.0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 93,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "(0.9092974268256817, -0.0)"
- ]
- },
- "execution_count": 93,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "taylor_sin(2.0, 0.0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 94,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "0.9092974280938506"
- ]
- },
- "execution_count": 94,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "cordic_sin(2.0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 95,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "-0.4161468365471424"
- ]
- },
- "execution_count": 95,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "cos(2)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 96,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "(-0.41614683654714246, -0.0)"
- ]
- },
- "execution_count": 96,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "taylor_cos(2.0, 0.0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 97,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "-0.4161468353122473"
- ]
- },
- "execution_count": 97,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "cordic_cos(2.0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 98,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "-5991.431207677988 - 9240.89014825243im"
- ]
- },
- "execution_count": 98,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# porównianie na sin(10 + 10i)\n",
- "sin(10 + 10im)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 99,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "(-5991.431207678, -9240.890148252452)"
- ]
- },
- "execution_count": 99,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "taylor_sin(10, 10)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 73,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "rel_error (generic function with 1 method)"
- ]
- },
- "execution_count": 73,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# w ten sposób liczony jest błąd względny zarówno dla liczb rzeczywistych jak i zespolonych\n",
- "function rel_error(x, y)\n",
- " if x == 0\n",
- " return 0\n",
- " end\n",
- " return abs((x-y)/x)\n",
- "end"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 100,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "taylor_error_of_iterations (generic function with 1 method)"
- ]
- },
- "execution_count": 100,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function taylor_error_of_iterations(x)\n",
- " set_taylor_iterations(x)\n",
- " return rel_error(sin(100+100im), taylor_sin(100, 100)[1] + taylor_sin(100, 100)[2]*im)\n",
- "end"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 101,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "cordic_error_of_iterations (generic function with 1 method)"
- ]
- },
- "execution_count": 101,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function cordic_error_of_iterations(x)\n",
- " set_cordic_iterations(x)\n",
- " return rel_error(sin(100), cordic_sin(100.0))\n",
- "end"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 111,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "taylor_error_of_iterations2 (generic function with 1 method)"
- ]
- },
- "execution_count": 111,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function taylor_error_of_iterations2(x)\n",
- " set_taylor_iterations(x)\n",
- " return rel_error(sin(100), taylor_sin(100.0, 0.0)[1])\n",
- "end"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 112,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "1:20"
- ]
- },
- "execution_count": 112,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "X = 1:20"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Przykładowe błędy w zależności od liczby iteracji:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 113,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "data": [
- {
- "colorbar": {
- "title": ""
- },
- "legendgroup": "y1",
- "line": {
- "color": "rgba(0, 154, 250, 1.000)",
- "dash": "solid",
- "shape": "linear",
- "width": 1
- },
- "mode": "lines",
- "name": "y1",
- "showlegend": true,
- "type": "scatter",
- "x": [
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 16,
- 17,
- 18,
- 19,
- 20
- ],
- "xaxis": "x",
- "y": [
- 0.9999999999947897,
- 0.6604336394521374,
- 0.02055234411557763,
- 0.00022080130144359062,
- 1.4713452359772989e-06,
- 6.728428696183563e-09,
- 2.238852117625799e-11,
- 7.408349671662484e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14,
- 2.066101872553143e-14
- ],
- "yaxis": "y",
- "zmax": null,
- "zmin": null
- }
- ],
- "layout": {
- "annotations": [
- {
- "font": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 20
- },
- "rotation": 0,
- "showarrow": false,
- "text": "Taylor relative error calculating sin(100+100i)",
- "x": 0.5423611111111111,
- "xanchor": "center",
- "xref": "paper",
- "y": 1,
- "yanchor": "top",
- "yref": "paper"
- }
- ],
- "height": 400,
- "legend": {
- "bgcolor": "rgba(255, 255, 255, 1.000)",
- "bordercolor": "rgba(0, 0, 0, 1.000)",
- "borderwidth": 1,
- "font": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tracegroupgap": 0,
- "traceorder": "normal",
- "x": 1,
- "xanchor": "auto",
- "y": 1,
- "yanchor": "auto"
- },
- "margin": {
- "b": 20,
- "l": 0,
- "r": 0,
- "t": 20
- },
- "paper_bgcolor": "rgba(255, 255, 255, 1.000)",
- "plot_bgcolor": "rgba(255, 255, 255, 1.000)",
- "showlegend": true,
- "width": 600,
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0.09128390201224845,
- 0.9934383202099738
- ],
- "gridcolor": "rgba(0, 0, 0, 0.100)",
- "gridwidth": 0.5,
- "linecolor": "rgba(0, 0, 0, 1.000)",
- "mirror": false,
- "range": [
- 0.43000000000000005,
- 20.57
- ],
- "showgrid": true,
- "showline": true,
- "showticklabels": true,
- "tickangle": 0,
- "tickcolor": "rgb(0, 0, 0)",
- "tickfont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tickmode": "array",
- "ticks": "inside",
- "ticktext": [
- "5",
- "10",
- "15",
- "20"
- ],
- "tickvals": [
- 5,
- 10,
- 15,
- 20
- ],
- "title": "iterations",
- "titlefont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 15
- },
- "type": "-",
- "visible": true,
- "zeroline": false,
- "zerolinecolor": "rgba(0, 0, 0, 1.000)"
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0.07581474190726165,
- 0.9415463692038496
- ],
- "gridcolor": "rgba(0, 0, 0, 0.100)",
- "gridwidth": 0.5,
- "linecolor": "rgba(0, 0, 0, 1.000)",
- "mirror": false,
- "range": [
- -0.029999999999822412,
- 1.0299999999946328
- ],
- "showgrid": true,
- "showline": true,
- "showticklabels": true,
- "tickangle": 0,
- "tickcolor": "rgb(0, 0, 0)",
- "tickfont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tickmode": "array",
- "ticks": "inside",
- "ticktext": [
- "0.00",
- "0.25",
- "0.50",
- "0.75",
- "1.00"
- ],
- "tickvals": [
- 0,
- 0.25,
- 0.5,
- 0.75,
- 1
- ],
- "title": "relative error",
- "titlefont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 15
- },
- "type": "-",
- "visible": true,
- "zeroline": false,
- "zerolinecolor": "rgba(0, 0, 0, 1.000)"
- }
- }
- },
- "text/html": [
- "<!DOCTYPE html>\n",
- "<html>\n",
- " <head>\n",
- " <title>Plots.jl</title>\n",
- " <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n",
- " <script src=\"https://cdn.plot.ly/plotly-1.54.2.min.js\"></script>\n",
- " </head>\n",
- " <body>\n",
- " <div id=\"d4821a64-261f-457a-b538-caec6961cc5e\" style=\"width:600px;height:400px;\"></div>\n",
- " <script>\n",
- " PLOT = document.getElementById('d4821a64-261f-457a-b538-caec6961cc5e');\n",
- " Plotly.plot(PLOT, [\n",
- " {\n",
- " \"xaxis\": \"x\",\n",
- " \"colorbar\": {\n",
- " \"title\": \"\"\n",
- " },\n",
- " \"yaxis\": \"y\",\n",
- " \"x\": [\n",
- " 1,\n",
- " 2,\n",
- " 3,\n",
- " 4,\n",
- " 5,\n",
- " 6,\n",
- " 7,\n",
- " 8,\n",
- " 9,\n",
- " 10,\n",
- " 11,\n",
- " 12,\n",
- " 13,\n",
- " 14,\n",
- " 15,\n",
- " 16,\n",
- " 17,\n",
- " 18,\n",
- " 19,\n",
- " 20\n",
- " ],\n",
- " \"showlegend\": true,\n",
- " \"mode\": \"lines\",\n",
- " \"name\": \"y1\",\n",
- " \"zmin\": null,\n",
- " \"legendgroup\": \"y1\",\n",
- " \"zmax\": null,\n",
- " \"line\": {\n",
- " \"color\": \"rgba(0, 154, 250, 1.000)\",\n",
- " \"shape\": \"linear\",\n",
- " \"dash\": \"solid\",\n",
- " \"width\": 1\n",
- " },\n",
- " \"y\": [\n",
- " 0.9999999999947897,\n",
- " 0.6604336394521374,\n",
- " 0.02055234411557763,\n",
- " 0.00022080130144359062,\n",
- " 1.4713452359772989e-6,\n",
- " 6.728428696183563e-9,\n",
- " 2.238852117625799e-11,\n",
- " 7.408349671662484e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14,\n",
- " 2.066101872553143e-14\n",
- " ],\n",
- " \"type\": \"scatter\"\n",
- " }\n",
- "]\n",
- ", {\n",
- " \"showlegend\": true,\n",
- " \"xaxis\": {\n",
- " \"showticklabels\": true,\n",
- " \"gridwidth\": 0.5,\n",
- " \"tickvals\": [\n",
- " 5.0,\n",
- " 10.0,\n",
- " 15.0,\n",
- " 20.0\n",
- " ],\n",
- " \"visible\": true,\n",
- " \"ticks\": \"inside\",\n",
- " \"range\": [\n",
- " 0.43000000000000005,\n",
- " 20.57\n",
- " ],\n",
- " \"domain\": [\n",
- " 0.09128390201224845,\n",
- " 0.9934383202099738\n",
- " ],\n",
- " \"tickmode\": \"array\",\n",
- " \"linecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"showgrid\": true,\n",
- " \"title\": \"iterations\",\n",
- " \"mirror\": false,\n",
- " \"tickangle\": 0,\n",
- " \"showline\": true,\n",
- " \"gridcolor\": \"rgba(0, 0, 0, 0.100)\",\n",
- " \"titlefont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 15\n",
- " },\n",
- " \"tickcolor\": \"rgb(0, 0, 0)\",\n",
- " \"ticktext\": [\n",
- " \"5\",\n",
- " \"10\",\n",
- " \"15\",\n",
- " \"20\"\n",
- " ],\n",
- " \"zeroline\": false,\n",
- " \"type\": \"-\",\n",
- " \"tickfont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"zerolinecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"anchor\": \"y\"\n",
- " },\n",
- " \"paper_bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"annotations\": [\n",
- " {\n",
- " \"yanchor\": \"top\",\n",
- " \"xanchor\": \"center\",\n",
- " \"rotation\": -0.0,\n",
- " \"y\": 1.0,\n",
- " \"font\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 20\n",
- " },\n",
- " \"yref\": \"paper\",\n",
- " \"showarrow\": false,\n",
- " \"text\": \"Taylor relative error calculating sin(100+100i)\",\n",
- " \"xref\": \"paper\",\n",
- " \"x\": 0.5423611111111111\n",
- " }\n",
- " ],\n",
- " \"height\": 400,\n",
- " \"margin\": {\n",
- " \"l\": 0,\n",
- " \"b\": 20,\n",
- " \"r\": 0,\n",
- " \"t\": 20\n",
- " },\n",
- " \"plot_bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"yaxis\": {\n",
- " \"showticklabels\": true,\n",
- " \"gridwidth\": 0.5,\n",
- " \"tickvals\": [\n",
- " 0.0,\n",
- " 0.25,\n",
- " 0.5,\n",
- " 0.75,\n",
- " 1.0\n",
- " ],\n",
- " \"visible\": true,\n",
- " \"ticks\": \"inside\",\n",
- " \"range\": [\n",
- " -0.029999999999822412,\n",
- " 1.0299999999946328\n",
- " ],\n",
- " \"domain\": [\n",
- " 0.07581474190726165,\n",
- " 0.9415463692038496\n",
- " ],\n",
- " \"tickmode\": \"array\",\n",
- " \"linecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"showgrid\": true,\n",
- " \"title\": \"relative error\",\n",
- " \"mirror\": false,\n",
- " \"tickangle\": 0,\n",
- " \"showline\": true,\n",
- " \"gridcolor\": \"rgba(0, 0, 0, 0.100)\",\n",
- " \"titlefont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 15\n",
- " },\n",
- " \"tickcolor\": \"rgb(0, 0, 0)\",\n",
- " \"ticktext\": [\n",
- " \"0.00\",\n",
- " \"0.25\",\n",
- " \"0.50\",\n",
- " \"0.75\",\n",
- " \"1.00\"\n",
- " ],\n",
- " \"zeroline\": false,\n",
- " \"type\": \"-\",\n",
- " \"tickfont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"zerolinecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"anchor\": \"x\"\n",
- " },\n",
- " \"legend\": {\n",
- " \"yanchor\": \"auto\",\n",
- " \"xanchor\": \"auto\",\n",
- " \"bordercolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"font\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"tracegroupgap\": 0,\n",
- " \"y\": 1.0,\n",
- " \"borderwidth\": 1,\n",
- " \"traceorder\": \"normal\",\n",
- " \"x\": 1.0\n",
- " },\n",
- " \"width\": 600\n",
- "}\n",
- ");\n",
- " </script>\n",
- "\n",
- " </body>\n",
- "</html>\n"
- ]
- },
- "execution_count": 113,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "\n",
- "plot(taylor_error_of_iterations, X, title=\"Taylor relative error calculating sin(100+100i)\", xguide = \"iterations\", yguide = \"relative error\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 114,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "data": [
- {
- "colorbar": {
- "title": ""
- },
- "legendgroup": "y1",
- "line": {
- "color": "rgba(0, 154, 250, 1.000)",
- "dash": "solid",
- "shape": "linear",
- "width": 1
- },
- "mode": "lines",
- "name": "y1",
- "showlegend": true,
- "type": "scatter",
- "x": [
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 16,
- 17,
- 18,
- 19,
- 20
- ],
- "xaxis": "x",
- "y": [
- 0.04858006105965706,
- 0.0006898745020126097,
- 4.643725178799385e-06,
- 1.8207599251359285e-08,
- 4.6699841760941685e-11,
- 8.485100007739351e-14,
- 2.1925323017414343e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16,
- 4.3850646034828687e-16
- ],
- "yaxis": "y",
- "zmax": null,
- "zmin": null
- }
- ],
- "layout": {
- "annotations": [
- {
- "font": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 20
- },
- "rotation": 0,
- "showarrow": false,
- "text": "Taylor relative error calculating sin(100)",
- "x": 0.5423611111111111,
- "xanchor": "center",
- "xref": "paper",
- "y": 1,
- "yanchor": "top",
- "yref": "paper"
- }
- ],
- "height": 400,
- "legend": {
- "bgcolor": "rgba(255, 255, 255, 1.000)",
- "bordercolor": "rgba(0, 0, 0, 1.000)",
- "borderwidth": 1,
- "font": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tracegroupgap": 0,
- "traceorder": "normal",
- "x": 1,
- "xanchor": "auto",
- "y": 1,
- "yanchor": "auto"
- },
- "margin": {
- "b": 20,
- "l": 0,
- "r": 0,
- "t": 20
- },
- "paper_bgcolor": "rgba(255, 255, 255, 1.000)",
- "plot_bgcolor": "rgba(255, 255, 255, 1.000)",
- "showlegend": true,
- "width": 600,
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0.09128390201224845,
- 0.9934383202099738
- ],
- "gridcolor": "rgba(0, 0, 0, 0.100)",
- "gridwidth": 0.5,
- "linecolor": "rgba(0, 0, 0, 1.000)",
- "mirror": false,
- "range": [
- 0.43000000000000005,
- 20.57
- ],
- "showgrid": true,
- "showline": true,
- "showticklabels": true,
- "tickangle": 0,
- "tickcolor": "rgb(0, 0, 0)",
- "tickfont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tickmode": "array",
- "ticks": "inside",
- "ticktext": [
- "5",
- "10",
- "15",
- "20"
- ],
- "tickvals": [
- 5,
- 10,
- 15,
- 20
- ],
- "title": "iterations",
- "titlefont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 15
- },
- "type": "-",
- "visible": true,
- "zeroline": false,
- "zerolinecolor": "rgba(0, 0, 0, 1.000)"
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0.07581474190726165,
- 0.9415463692038496
- ],
- "gridcolor": "rgba(0, 0, 0, 0.100)",
- "gridwidth": 0.5,
- "linecolor": "rgba(0, 0, 0, 1.000)",
- "mirror": false,
- "range": [
- -0.0014574018317894857,
- 0.05003746289144676
- ],
- "showgrid": true,
- "showline": true,
- "showticklabels": true,
- "tickangle": 0,
- "tickcolor": "rgb(0, 0, 0)",
- "tickfont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tickmode": "array",
- "ticks": "inside",
- "ticktext": [
- "0.00",
- "0.01",
- "0.02",
- "0.03",
- "0.04",
- "0.05"
- ],
- "tickvals": [
- 0,
- 0.01,
- 0.02,
- 0.03,
- 0.04,
- 0.05
- ],
- "title": "relative error",
- "titlefont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 15
- },
- "type": "-",
- "visible": true,
- "zeroline": false,
- "zerolinecolor": "rgba(0, 0, 0, 1.000)"
- }
- }
- },
- "text/html": [
- "<!DOCTYPE html>\n",
- "<html>\n",
- " <head>\n",
- " <title>Plots.jl</title>\n",
- " <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n",
- " <script src=\"https://cdn.plot.ly/plotly-1.54.2.min.js\"></script>\n",
- " </head>\n",
- " <body>\n",
- " <div id=\"444c3307-5eb6-4e94-8b48-a477ec5fabff\" style=\"width:600px;height:400px;\"></div>\n",
- " <script>\n",
- " PLOT = document.getElementById('444c3307-5eb6-4e94-8b48-a477ec5fabff');\n",
- " Plotly.plot(PLOT, [\n",
- " {\n",
- " \"xaxis\": \"x\",\n",
- " \"colorbar\": {\n",
- " \"title\": \"\"\n",
- " },\n",
- " \"yaxis\": \"y\",\n",
- " \"x\": [\n",
- " 1,\n",
- " 2,\n",
- " 3,\n",
- " 4,\n",
- " 5,\n",
- " 6,\n",
- " 7,\n",
- " 8,\n",
- " 9,\n",
- " 10,\n",
- " 11,\n",
- " 12,\n",
- " 13,\n",
- " 14,\n",
- " 15,\n",
- " 16,\n",
- " 17,\n",
- " 18,\n",
- " 19,\n",
- " 20\n",
- " ],\n",
- " \"showlegend\": true,\n",
- " \"mode\": \"lines\",\n",
- " \"name\": \"y1\",\n",
- " \"zmin\": null,\n",
- " \"legendgroup\": \"y1\",\n",
- " \"zmax\": null,\n",
- " \"line\": {\n",
- " \"color\": \"rgba(0, 154, 250, 1.000)\",\n",
- " \"shape\": \"linear\",\n",
- " \"dash\": \"solid\",\n",
- " \"width\": 1\n",
- " },\n",
- " \"y\": [\n",
- " 0.04858006105965706,\n",
- " 0.0006898745020126097,\n",
- " 4.643725178799385e-6,\n",
- " 1.8207599251359285e-8,\n",
- " 4.6699841760941685e-11,\n",
- " 8.485100007739351e-14,\n",
- " 2.1925323017414343e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16,\n",
- " 4.3850646034828687e-16\n",
- " ],\n",
- " \"type\": \"scatter\"\n",
- " }\n",
- "]\n",
- ", {\n",
- " \"showlegend\": true,\n",
- " \"xaxis\": {\n",
- " \"showticklabels\": true,\n",
- " \"gridwidth\": 0.5,\n",
- " \"tickvals\": [\n",
- " 5.0,\n",
- " 10.0,\n",
- " 15.0,\n",
- " 20.0\n",
- " ],\n",
- " \"visible\": true,\n",
- " \"ticks\": \"inside\",\n",
- " \"range\": [\n",
- " 0.43000000000000005,\n",
- " 20.57\n",
- " ],\n",
- " \"domain\": [\n",
- " 0.09128390201224845,\n",
- " 0.9934383202099738\n",
- " ],\n",
- " \"tickmode\": \"array\",\n",
- " \"linecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"showgrid\": true,\n",
- " \"title\": \"iterations\",\n",
- " \"mirror\": false,\n",
- " \"tickangle\": 0,\n",
- " \"showline\": true,\n",
- " \"gridcolor\": \"rgba(0, 0, 0, 0.100)\",\n",
- " \"titlefont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 15\n",
- " },\n",
- " \"tickcolor\": \"rgb(0, 0, 0)\",\n",
- " \"ticktext\": [\n",
- " \"5\",\n",
- " \"10\",\n",
- " \"15\",\n",
- " \"20\"\n",
- " ],\n",
- " \"zeroline\": false,\n",
- " \"type\": \"-\",\n",
- " \"tickfont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"zerolinecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"anchor\": \"y\"\n",
- " },\n",
- " \"paper_bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"annotations\": [\n",
- " {\n",
- " \"yanchor\": \"top\",\n",
- " \"xanchor\": \"center\",\n",
- " \"rotation\": -0.0,\n",
- " \"y\": 1.0,\n",
- " \"font\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 20\n",
- " },\n",
- " \"yref\": \"paper\",\n",
- " \"showarrow\": false,\n",
- " \"text\": \"Taylor relative error calculating sin(100)\",\n",
- " \"xref\": \"paper\",\n",
- " \"x\": 0.5423611111111111\n",
- " }\n",
- " ],\n",
- " \"height\": 400,\n",
- " \"margin\": {\n",
- " \"l\": 0,\n",
- " \"b\": 20,\n",
- " \"r\": 0,\n",
- " \"t\": 20\n",
- " },\n",
- " \"plot_bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"yaxis\": {\n",
- " \"showticklabels\": true,\n",
- " \"gridwidth\": 0.5,\n",
- " \"tickvals\": [\n",
- " 0.0,\n",
- " 0.01,\n",
- " 0.02,\n",
- " 0.03,\n",
- " 0.04,\n",
- " 0.05\n",
- " ],\n",
- " \"visible\": true,\n",
- " \"ticks\": \"inside\",\n",
- " \"range\": [\n",
- " -0.0014574018317894857,\n",
- " 0.05003746289144676\n",
- " ],\n",
- " \"domain\": [\n",
- " 0.07581474190726165,\n",
- " 0.9415463692038496\n",
- " ],\n",
- " \"tickmode\": \"array\",\n",
- " \"linecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"showgrid\": true,\n",
- " \"title\": \"relative error\",\n",
- " \"mirror\": false,\n",
- " \"tickangle\": 0,\n",
- " \"showline\": true,\n",
- " \"gridcolor\": \"rgba(0, 0, 0, 0.100)\",\n",
- " \"titlefont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 15\n",
- " },\n",
- " \"tickcolor\": \"rgb(0, 0, 0)\",\n",
- " \"ticktext\": [\n",
- " \"0.00\",\n",
- " \"0.01\",\n",
- " \"0.02\",\n",
- " \"0.03\",\n",
- " \"0.04\",\n",
- " \"0.05\"\n",
- " ],\n",
- " \"zeroline\": false,\n",
- " \"type\": \"-\",\n",
- " \"tickfont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"zerolinecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"anchor\": \"x\"\n",
- " },\n",
- " \"legend\": {\n",
- " \"yanchor\": \"auto\",\n",
- " \"xanchor\": \"auto\",\n",
- " \"bordercolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"font\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"tracegroupgap\": 0,\n",
- " \"y\": 1.0,\n",
- " \"borderwidth\": 1,\n",
- " \"traceorder\": \"normal\",\n",
- " \"x\": 1.0\n",
- " },\n",
- " \"width\": 600\n",
- "}\n",
- ");\n",
- " </script>\n",
- "\n",
- " </body>\n",
- "</html>\n"
- ]
- },
- "execution_count": 114,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "plot(taylor_error_of_iterations2, X, title=\"Taylor relative error calculating sin(100)\", xguide = \"iterations\", yguide = \"relative error\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 109,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.plotly.v1+json": {
- "data": [
- {
- "colorbar": {
- "title": ""
- },
- "legendgroup": "y1",
- "line": {
- "color": "rgba(0, 154, 250, 1.000)",
- "dash": "solid",
- "shape": "linear",
- "width": 1
- },
- "mode": "lines",
- "name": "y1",
- "showlegend": true,
- "type": "scatter",
- "x": [
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 16,
- 17,
- 18,
- 19,
- 20
- ],
- "xaxis": "x",
- "y": [
- 0.19923803206067645,
- 0.40038098396966176,
- 0.04933327667366985,
- 0.15678575968442748,
- 0.04552832522388985,
- 0.008453488065297705,
- 0.018071367045314653,
- 0.004685838026992587,
- 0.0019769599175434157,
- 0.001346845796143942,
- 0.0003169671004323271,
- 0.0005144620678263349,
- 9.862885340066103e-05,
- 0.00010925740652706494,
- 5.322553095504949e-06,
- 4.664671284967571e-05,
- 2.066207987708538e-05,
- 7.669763390790217e-06,
- 1.1736051476426335e-06,
- 2.074473973931158e-06
- ],
- "yaxis": "y",
- "zmax": null,
- "zmin": null
- }
- ],
- "layout": {
- "annotations": [
- {
- "font": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 20
- },
- "rotation": 0,
- "showarrow": false,
- "text": "Cordic relative error calculating sin(100)",
- "x": 0.5349537037037038,
- "xanchor": "center",
- "xref": "paper",
- "y": 1,
- "yanchor": "top",
- "yref": "paper"
- }
- ],
- "height": 400,
- "legend": {
- "bgcolor": "rgba(255, 255, 255, 1.000)",
- "bordercolor": "rgba(0, 0, 0, 1.000)",
- "borderwidth": 1,
- "font": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tracegroupgap": 0,
- "traceorder": "normal",
- "x": 1,
- "xanchor": "auto",
- "y": 1,
- "yanchor": "auto"
- },
- "margin": {
- "b": 20,
- "l": 0,
- "r": 0,
- "t": 20
- },
- "paper_bgcolor": "rgba(255, 255, 255, 1.000)",
- "plot_bgcolor": "rgba(255, 255, 255, 1.000)",
- "showlegend": true,
- "width": 600,
- "xaxis": {
- "anchor": "y",
- "domain": [
- 0.07646908719743364,
- 0.9934383202099737
- ],
- "gridcolor": "rgba(0, 0, 0, 0.100)",
- "gridwidth": 0.5,
- "linecolor": "rgba(0, 0, 0, 1.000)",
- "mirror": false,
- "range": [
- 0.43000000000000005,
- 20.57
- ],
- "showgrid": true,
- "showline": true,
- "showticklabels": true,
- "tickangle": 0,
- "tickcolor": "rgb(0, 0, 0)",
- "tickfont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tickmode": "array",
- "ticks": "inside",
- "ticktext": [
- "5",
- "10",
- "15",
- "20"
- ],
- "tickvals": [
- 5,
- 10,
- 15,
- 20
- ],
- "title": "iterations",
- "titlefont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 15
- },
- "type": "-",
- "visible": true,
- "zeroline": false,
- "zerolinecolor": "rgba(0, 0, 0, 1.000)"
- },
- "yaxis": {
- "anchor": "x",
- "domain": [
- 0.07581474190726165,
- 0.9415463692038496
- ],
- "gridcolor": "rgba(0, 0, 0, 0.100)",
- "gridwidth": 0.5,
- "linecolor": "rgba(0, 0, 0, 1.000)",
- "mirror": false,
- "range": [
- -0.012010220705787781,
- 0.41239237828059716
- ],
- "showgrid": true,
- "showline": true,
- "showticklabels": true,
- "tickangle": 0,
- "tickcolor": "rgb(0, 0, 0)",
- "tickfont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 11
- },
- "tickmode": "array",
- "ticks": "inside",
- "ticktext": [
- "0.0",
- "0.1",
- "0.2",
- "0.3",
- "0.4"
- ],
- "tickvals": [
- 0,
- 0.1,
- 0.2,
- 0.30000000000000004,
- 0.4
- ],
- "title": "relative error",
- "titlefont": {
- "color": "rgba(0, 0, 0, 1.000)",
- "family": "sans-serif",
- "size": 15
- },
- "type": "-",
- "visible": true,
- "zeroline": false,
- "zerolinecolor": "rgba(0, 0, 0, 1.000)"
- }
- }
- },
- "text/html": [
- "<!DOCTYPE html>\n",
- "<html>\n",
- " <head>\n",
- " <title>Plots.jl</title>\n",
- " <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n",
- " <script src=\"https://cdn.plot.ly/plotly-1.54.2.min.js\"></script>\n",
- " </head>\n",
- " <body>\n",
- " <div id=\"2f136220-4174-4b26-9791-afadf0ef3c82\" style=\"width:600px;height:400px;\"></div>\n",
- " <script>\n",
- " PLOT = document.getElementById('2f136220-4174-4b26-9791-afadf0ef3c82');\n",
- " Plotly.plot(PLOT, [\n",
- " {\n",
- " \"xaxis\": \"x\",\n",
- " \"colorbar\": {\n",
- " \"title\": \"\"\n",
- " },\n",
- " \"yaxis\": \"y\",\n",
- " \"x\": [\n",
- " 1,\n",
- " 2,\n",
- " 3,\n",
- " 4,\n",
- " 5,\n",
- " 6,\n",
- " 7,\n",
- " 8,\n",
- " 9,\n",
- " 10,\n",
- " 11,\n",
- " 12,\n",
- " 13,\n",
- " 14,\n",
- " 15,\n",
- " 16,\n",
- " 17,\n",
- " 18,\n",
- " 19,\n",
- " 20\n",
- " ],\n",
- " \"showlegend\": true,\n",
- " \"mode\": \"lines\",\n",
- " \"name\": \"y1\",\n",
- " \"zmin\": null,\n",
- " \"legendgroup\": \"y1\",\n",
- " \"zmax\": null,\n",
- " \"line\": {\n",
- " \"color\": \"rgba(0, 154, 250, 1.000)\",\n",
- " \"shape\": \"linear\",\n",
- " \"dash\": \"solid\",\n",
- " \"width\": 1\n",
- " },\n",
- " \"y\": [\n",
- " 0.19923803206067645,\n",
- " 0.40038098396966176,\n",
- " 0.04933327667366985,\n",
- " 0.15678575968442748,\n",
- " 0.04552832522388985,\n",
- " 0.008453488065297705,\n",
- " 0.018071367045314653,\n",
- " 0.004685838026992587,\n",
- " 0.0019769599175434157,\n",
- " 0.001346845796143942,\n",
- " 0.0003169671004323271,\n",
- " 0.0005144620678263349,\n",
- " 9.862885340066103e-5,\n",
- " 0.00010925740652706494,\n",
- " 5.322553095504949e-6,\n",
- " 4.664671284967571e-5,\n",
- " 2.066207987708538e-5,\n",
- " 7.669763390790217e-6,\n",
- " 1.1736051476426335e-6,\n",
- " 2.074473973931158e-6\n",
- " ],\n",
- " \"type\": \"scatter\"\n",
- " }\n",
- "]\n",
- ", {\n",
- " \"showlegend\": true,\n",
- " \"xaxis\": {\n",
- " \"showticklabels\": true,\n",
- " \"gridwidth\": 0.5,\n",
- " \"tickvals\": [\n",
- " 5.0,\n",
- " 10.0,\n",
- " 15.0,\n",
- " 20.0\n",
- " ],\n",
- " \"visible\": true,\n",
- " \"ticks\": \"inside\",\n",
- " \"range\": [\n",
- " 0.43000000000000005,\n",
- " 20.57\n",
- " ],\n",
- " \"domain\": [\n",
- " 0.07646908719743364,\n",
- " 0.9934383202099737\n",
- " ],\n",
- " \"tickmode\": \"array\",\n",
- " \"linecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"showgrid\": true,\n",
- " \"title\": \"iterations\",\n",
- " \"mirror\": false,\n",
- " \"tickangle\": 0,\n",
- " \"showline\": true,\n",
- " \"gridcolor\": \"rgba(0, 0, 0, 0.100)\",\n",
- " \"titlefont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 15\n",
- " },\n",
- " \"tickcolor\": \"rgb(0, 0, 0)\",\n",
- " \"ticktext\": [\n",
- " \"5\",\n",
- " \"10\",\n",
- " \"15\",\n",
- " \"20\"\n",
- " ],\n",
- " \"zeroline\": false,\n",
- " \"type\": \"-\",\n",
- " \"tickfont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"zerolinecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"anchor\": \"y\"\n",
- " },\n",
- " \"paper_bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"annotations\": [\n",
- " {\n",
- " \"yanchor\": \"top\",\n",
- " \"xanchor\": \"center\",\n",
- " \"rotation\": -0.0,\n",
- " \"y\": 1.0,\n",
- " \"font\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 20\n",
- " },\n",
- " \"yref\": \"paper\",\n",
- " \"showarrow\": false,\n",
- " \"text\": \"Cordic relative error calculating sin(100)\",\n",
- " \"xref\": \"paper\",\n",
- " \"x\": 0.5349537037037038\n",
- " }\n",
- " ],\n",
- " \"height\": 400,\n",
- " \"margin\": {\n",
- " \"l\": 0,\n",
- " \"b\": 20,\n",
- " \"r\": 0,\n",
- " \"t\": 20\n",
- " },\n",
- " \"plot_bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"yaxis\": {\n",
- " \"showticklabels\": true,\n",
- " \"gridwidth\": 0.5,\n",
- " \"tickvals\": [\n",
- " 0.0,\n",
- " 0.1,\n",
- " 0.2,\n",
- " 0.30000000000000004,\n",
- " 0.4\n",
- " ],\n",
- " \"visible\": true,\n",
- " \"ticks\": \"inside\",\n",
- " \"range\": [\n",
- " -0.012010220705787781,\n",
- " 0.41239237828059716\n",
- " ],\n",
- " \"domain\": [\n",
- " 0.07581474190726165,\n",
- " 0.9415463692038496\n",
- " ],\n",
- " \"tickmode\": \"array\",\n",
- " \"linecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"showgrid\": true,\n",
- " \"title\": \"relative error\",\n",
- " \"mirror\": false,\n",
- " \"tickangle\": 0,\n",
- " \"showline\": true,\n",
- " \"gridcolor\": \"rgba(0, 0, 0, 0.100)\",\n",
- " \"titlefont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 15\n",
- " },\n",
- " \"tickcolor\": \"rgb(0, 0, 0)\",\n",
- " \"ticktext\": [\n",
- " \"0.0\",\n",
- " \"0.1\",\n",
- " \"0.2\",\n",
- " \"0.3\",\n",
- " \"0.4\"\n",
- " ],\n",
- " \"zeroline\": false,\n",
- " \"type\": \"-\",\n",
- " \"tickfont\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"zerolinecolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"anchor\": \"x\"\n",
- " },\n",
- " \"legend\": {\n",
- " \"yanchor\": \"auto\",\n",
- " \"xanchor\": \"auto\",\n",
- " \"bordercolor\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"bgcolor\": \"rgba(255, 255, 255, 1.000)\",\n",
- " \"font\": {\n",
- " \"color\": \"rgba(0, 0, 0, 1.000)\",\n",
- " \"family\": \"sans-serif\",\n",
- " \"size\": 11\n",
- " },\n",
- " \"tracegroupgap\": 0,\n",
- " \"y\": 1.0,\n",
- " \"borderwidth\": 1,\n",
- " \"traceorder\": \"normal\",\n",
- " \"x\": 1.0\n",
- " },\n",
- " \"width\": 600\n",
- "}\n",
- ");\n",
- " </script>\n",
- "\n",
- " </body>\n",
- "</html>\n"
- ]
- },
- "execution_count": 109,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "plot(cordic_error_of_iterations, X, title=\"Cordic relative error calculating sin(100)\", xguide = \"iterations\", yguide = \"relative error\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 106,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Poniżej znajdują się funkcje testujące, na podstawie których powstała tabelka z błędami w sprawozdaniu"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "MersenneTwister(UInt32[0x00003039], Random.DSFMT.DSFMT_state(Int32[-870096391, 1072918504, -1812426662, 1073255081, -733866021, 1073404543, 807620846, 1073368448, 1919433844, 1072852359 … -362113007, 1073100625, -166402106, 1073460158, -1907020342, 721295190, -750225566, -1300227565, 382, 0]), [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], UInt128[0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000 … 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000], 1002, 0)"
- ]
- },
- "execution_count": 18,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "TESTS = 100000000\n",
- "\n",
- "Random.seed!(12345)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 19,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "taylor_test_error_real (generic function with 3 methods)"
- ]
- },
- "execution_count": 19,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function taylor_test_error_real(l::Float64=floatmin(), r::Float64=floatmax())\n",
- " res = BigFloat(0)\n",
- " abs_res = BigFloat(0)\n",
- " maksi_rel = BigFloat(0)\n",
- " maksi_abs = BigFloat(0)\n",
- " for i = 1:TESTS\n",
- " if i % 100000 == 0\n",
- " println(i)\n",
- " end\n",
- " x = rand(Uniform(l, r))\n",
- " lib_sin = sin(x)\n",
- " if lib_sin == 0\n",
- " continue\n",
- " end\n",
- " my_sin = taylor_sin(x, 0)\n",
- " error = rel_error(lib_sin, my_sin[1])\n",
- " abs_error = abs(my_sin[1] - lib_sin)\n",
- " res += error\n",
- " abs_res += abs_error\n",
- " maksi_rel = max(maksi_rel, error)\n",
- " maksi_abs = max(maksi_abs, abs_error)\n",
- " end\n",
- " return (res/TESTS, maksi_rel, abs_res/TESTS, maksi_abs)\n",
- "end\n",
- "\n",
- "# (floatmin(), floatmax()):\n",
- "# (1.887844299668514797145972383393008309519973773948872165524132116232181033410611e-15, \n",
- "# 3.16719187748669057932019506480803006098767582443542778491973876953125e-08,\n",
- "# 1.1794041986528804301572959036155385792454808324691839516162872314453125e-16,\n",
- "# 8.8817841970012523233890533447265625e-16)\n",
- "\n",
- "# (-pi/2, pi/2):\n",
- "# (1.471587646915289673578957365178574707202863924359834292944840261618821841693717e-15, \n",
- "# 1.1848604479598457485905096801294400510329296594136394560337066650390625e-08, \n",
- "# 9.765754183892570637182101557852154094518937199609354138374328613281249999999994e-17, \n",
- "# 5.5511151231257827021181583404541015625e-16)\n",
- "\n",
- "# (0, 1):\n",
- "# (8.693695902799099432701533207691913249153884601349429181102457242502623557811573e-17,\n",
- "# 6.661260307992334044328275268948192015174572739102942797728701407322660088539124e-16,\n",
- "# 4.293257315426284893844499634951716871000826358795166015624999999999999999999994e-17,\n",
- "# 4.44089209850062616169452667236328125e-16)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 20,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "taylor_test_error_complex (generic function with 3 methods)"
- ]
- },
- "execution_count": 20,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function taylor_test_error_complex(l::Float64=-100.0, r::Float64=100.0)\n",
- " res = BigFloat(0)\n",
- " abs_res = BigFloat(0)\n",
- " maksi_rel = BigFloat(0)\n",
- " maksi_abs = BigFloat(0)\n",
- " for i = 1:TESTS\n",
- " if i % 100000 == 0\n",
- " println(i)\n",
- " end\n",
- " x = rand(Uniform(l, r))\n",
- " y = rand(Uniform(max(l, -Float64(√(BigFloat(r)*r - BigFloat(x)*x))), \n",
- " Float64(√(BigFloat(r)*r - BigFloat(x)*x))))\n",
- " lib_sin = sin(x + y*im)\n",
- " my_sin = taylor_sin(x, y)\n",
- " error = rel_error(lib_sin, my_sin[1] + my_sin[2]*im)\n",
- " abs_error = abs(lib_sin - (my_sin[1] + my_sin[2]*im))\n",
- " res += error\n",
- " abs_res += abs_error\n",
- " maksi_rel = max(maksi_rel, error)\n",
- " maksi_abs = max(maksi_abs, abs_error)\n",
- " end\n",
- " return (res/TESTS, maksi_rel, abs_res/TESTS, maksi_abs)\n",
- "end\n",
- "\n",
- "# (-100, 100):\n",
- "# (4.932205036590292360305897845543684560590114030155004375572792447173773555907229e-15, \n",
- "# 1.3111008357751143737471652583705182364137709072338111582212150096893310546875e-13, \n",
- "# 1.688623533003329462861070079404255492323042928202526655997186385923664654746476e+26, \n",
- "# 5.89784569029861503624382775296e+29)\n",
- "\n",
- "# (-2pi, 2pi):\n",
- "# (4.338436856498561167962902801400526155223569336855327458414068651872587652334067e-16, \n",
- "# 1.48720543982594402760972427363260419015678071019692652043886482715606689453125e-11, \n",
- "# 1.364745868545483273874507699553481910023596725366415789061836204439613629002538e-14, \n",
- "# 8.7095846425677781478128738959826782468909289747216462274082005023956298828125e-13)\n",
- "\n",
- "# (0, 1):\n",
- "# (1.596935223079780368874812440778376297707878344605454825588075017177200118204992e-16, \n",
- "# 1.098997011961567777204023105931451003520679665648174250236479565501213073730469e-15, \n",
- "# 1.124298405324025732059699593805301650508046127888472394113736655893442950571177e-16, \n",
- "# 1.110569915127177230816030746289393434073728902933275719533412484452128410339355e-15)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 21,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "cordic_test_error (generic function with 3 methods)"
- ]
- },
- "execution_count": 21,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function cordic_test_error(l::Float64=floatmin(), r::Float64=floatmax())\n",
- " res = BigFloat(0)\n",
- " abs_res = BigFloat(0)\n",
- " maksi_rel = BigFloat(0)\n",
- " maksi_abs = BigFloat(0)\n",
- " for i = 1:TESTS\n",
- " if i % 100000 == 0\n",
- " println(i)\n",
- " end\n",
- " x = rand(Uniform(l, r))\n",
- " lib_sin = sin(x)\n",
- " my_sin = cordic_sin(x)\n",
- " error = rel_error(lib_sin, my_sin)\n",
- " abs_error = abs(lib_sin - my_sin)\n",
- " res += error\n",
- " abs_res += abs_error\n",
- " if error > maksi_rel\n",
- " worst_rel = x\n",
- " end\n",
- " maksi_rel = max(maksi_rel, error)\n",
- " maksi_abs = max(maksi_abs, abs_error)\n",
- " end\n",
- " return (res/TESTS, maksi_rel, abs_res/TESTS, maksi_abs)\n",
- "end\n",
- "\n",
- "# (floatmin(), floatmax()):\n",
- "# (3.099880824631376815575307358441341907045753361742215192539218280437518515668677e-08, \n",
- "# 0.457561153670805575988111968399607576429843902587890625, \n",
- "# 2.459716652636021482355597144179802356154379561203882076370064169168472290039072e-09, \n",
- "# 0.0006041780891818948617810747236944735050201416015625)\n",
- "\n",
- "# (-2pi, 2pi):\n",
- "# (2.769658715752475495709394998775060901506630522496771093654899307916206208091117e-08, \n",
- "# 0.11834204003306579566778822254491387866437435150146484375, \n",
- "# 2.532059440779907667675144447194875727078638982803227008844260126352310180664052e-09,\n",
- "# 0.00552917548107156875403234153054654598236083984375)\n",
- "\n",
- "# (0, 1):\n",
- "# (4.176404604808155838824592152607760760141260709650975486490997166423577713345588e-08, \n",
- "# 0.091828765031669201679420666550868190824985504150390625, \n",
- "# 2.613683444981852927700279986835644064485650872597943816799670457839965820312493e-09, \n",
- "# 0.00052619288922584050993691562325693666934967041015625)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 22,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "taylor_without_reduction_test_error (generic function with 3 methods)"
- ]
- },
- "execution_count": 22,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function taylor_without_reduction_test_error(l::Float64=-100.0, r::Float64=100.0)\n",
- " res = BigFloat(0)\n",
- " abs_res = BigFloat(0)\n",
- " maksi_rel = BigFloat(0)\n",
- " maksi_abs = BigFloat(0)\n",
- " for i = 1:TESTS\n",
- " if i % 1000000 == 0\n",
- " println(i)\n",
- " end\n",
- " x = rand(Uniform(l, r))\n",
- " y = rand(Uniform(max(l, -Float64(√(BigFloat(r)*r - BigFloat(x)*x))), \n",
- " Float64(√(BigFloat(r)*r - BigFloat(x)*x))))\n",
- " lib_sin = sin(x + y*im)\n",
- " my_sin = taylor_sin_no_reduction(x, y)\n",
- " error = rel_error(lib_sin, my_sin[1] + my_sin[2]*im)\n",
- " abs_error = abs(lib_sin - (my_sin[1] + my_sin[2]*im))\n",
- " res += error\n",
- " abs_res += abs_error\n",
- " maksi_rel = max(maksi_rel, error)\n",
- " maksi_abs = max(maksi_abs, abs_error)\n",
- " end\n",
- " return (res/TESTS, maksi_rel, abs_res/TESTS, maksi_abs)\n",
- "end\n",
- "\n",
- "# (-100, 100)\n",
- "# (4.774091809397734982069398193189465079787514988283523440828527859306283137571149e+23, \n",
- "# 4.48814142545670189837451264e+26, \n",
- "# 7.758560481134976967771949796127369173267383351574525337904198599731007318070319e+40, \n",
- "# 2.20832987186165589366506156220211970162294784e+44)\n",
- "\n",
- "# (-2pi, 2pi)\n",
- "# (0.6332711088634405192103194531076134843075526902544601426097735760298574150340518, \n",
- "# 1.0, \n",
- "# 23.44057586605533515691829807979128873527513778367553433852055381911453864572971, \n",
- "# 267.74654227273646256435313262045383453369140625)\n",
- "\n",
- "# (0, 1)\n",
- "# (1.589482169544726703219739509256918022523030217883325972454504856003547167066932e-16, \n",
- "# 1.291897416767691567199962520855285151964115327068161054313577551511116325855255e-15, \n",
- "# 1.118367257755837281340217148887719929595000777959128862241583039814976641146415e-16, \n",
- "# 1.115760330918745818020084658567032229219617364690542160587938269600272178649902e-15)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Julia 1.4.1",
- "language": "julia",
- "name": "julia-1.4"
- },
- "language_info": {
- "file_extension": ".jl",
- "mimetype": "application/julia",
- "name": "julia",
- "version": "1.4.1"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 4
-}