From 9477dbe667f250ecd23f8fc0d56b942191526421 Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Thu, 25 Feb 2021 14:42:55 +0100 Subject: Stare semestry, niepoukladane --- Semestr 3/anm/pracowniaPOP/prog/program.html | 19173 ++++++++++++++++++++++++ Semestr 3/anm/pracowniaPOP/prog/program.ipynb | 7922 ++++++++++ Semestr 3/anm/pracowniaPOP/prog/program.jl | 273 + 3 files changed, 27368 insertions(+) create mode 100644 Semestr 3/anm/pracowniaPOP/prog/program.html create mode 100644 Semestr 3/anm/pracowniaPOP/prog/program.ipynb create mode 100644 Semestr 3/anm/pracowniaPOP/prog/program.jl (limited to 'Semestr 3/anm/pracowniaPOP/prog') diff --git a/Semestr 3/anm/pracowniaPOP/prog/program.html b/Semestr 3/anm/pracowniaPOP/prog/program.html new file mode 100644 index 0000000..3525493 --- /dev/null +++ b/Semestr 3/anm/pracowniaPOP/prog/program.html @@ -0,0 +1,19173 @@ + + + + + +program + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + + + diff --git a/Semestr 3/anm/pracowniaPOP/prog/program.ipynb b/Semestr 3/anm/pracowniaPOP/prog/program.ipynb new file mode 100644 index 0000000..f8cb21c --- /dev/null +++ b/Semestr 3/anm/pracowniaPOP/prog/program.ipynb @@ -0,0 +1,7922 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set_cordic_iterations (generic function with 1 method)" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "include(\"program.jl\")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Plots.PlotlyBackend()" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "using Plots\n", + "using Random\n", + "using Distributions\n", + "\n", + "plotly()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "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": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9092974268256817" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# porównianie na sin(2), cos(2)\n", + "sin(2.0)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(0.9092974268256817, -0.0)" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "taylor_sin(2.0, 0.0)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9092974280938506" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cordic_sin(2.0)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-0.4161468365471424" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cos(2)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(-0.41614683654714246, -0.0)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "taylor_cos(2.0, 0.0)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-0.4161468353122473" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cordic_cos(2.0)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-5991.431207677988 - 9240.89014825243im" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# porównianie na sin(10 + 10i)\n", + "sin(10 + 10im)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(-5991.431207678, -9240.890148252452)" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "taylor_sin(10, 10)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "rel_error (generic function with 1 method)" + ] + }, + "execution_count": 12, + "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": 13, + "metadata": {}, + "outputs": [], + "source": [ + "# Funkcje użyte w wykresach błędów od liczby iteracji:" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "taylor_error_of_iterations (generic function with 1 method)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# błąd przy liczeniu sin(100 + 100i) szeregiem Taylora przy x iteracjach\n", + "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": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "cordic_error_of_iterations (generic function with 1 method)" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# błąd przy liczeniu sin(100) Cordicem przy x iteracjach\n", + "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": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "taylor_error_of_iterations2 (generic function with 1 method)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# błąd przy liczeniu sin(100) szeregiem Taylora przy x iteracjach\n", + "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": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1:20" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "X = 1:20" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [], + "source": [ + "# Przykładowe błędy w zależności od liczby iteracji\n", + "# obrazują jak szybko zbiega metoda:" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + " \n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "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": [ + "\n", + "\n", + " \n", + " Plots.jl\n", + " \n", + " \n", + " \n", + " \n", + "
\n", + " \n", + "\n", + " \n", + "\n" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plot(taylor_error_of_iterations, X, title=\"Taylor relative error calculating sin(100+100i)\", xguide = \"iterations\", yguide = \"relative error\")" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "scrolled": true + }, + "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": [ + "\n", + "\n", + " \n", + " Plots.jl\n", + " \n", + " \n", + " \n", + " \n", + "
\n", + " \n", + "\n", + " \n", + "\n" + ] + }, + "execution_count": 20, + "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": 21, + "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": [ + "\n", + "\n", + " \n", + " Plots.jl\n", + " \n", + " \n", + " \n", + " \n", + "
\n", + " \n", + "\n", + " \n", + "\n" + ] + }, + "execution_count": 21, + "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": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "rel_error_cordic (generic function with 1 method)" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# funkcje do kolejnych wykresów, pokaujących błąd względny liczenia sinusa w przedziale [0, 2pi]:\n", + "\n", + "function rel_error_cordic(x)\n", + " return rel_error(sin(x), cordic_sin(x)) \n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "rel_error_taylor (generic function with 1 method)" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function rel_error_taylor(x)\n", + " return rel_error(sin(x), taylor_sin(x, 0.0)[1]) \n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "631-element Array{Real,1}:\n", + " 0\n", + " 0.0\n", + " 0.0\n", + " 1.1566558078817942e-16\n", + " 0.0\n", + " 1.3883571906382453e-16\n", + " 0.0\n", + " 0.0\n", + " 1.7365752302283546e-16\n", + " 1.5440600601196135e-16\n", + " 1.3900944467230525e-16\n", + " 0.0\n", + " 1.1592625449066459e-16\n", + " ⋮\n", + " 2.684565604502478e-15\n", + " 2.839380050077419e-15\n", + " 3.0367153263107948e-15\n", + " 3.956085449056853e-15\n", + " 4.6990042927913394e-15\n", + " 5.625450115568505e-15\n", + " 7.319681171152798e-15\n", + " 1.062538454174323e-14\n", + " 1.8551186877114254e-14\n", + " 7.69251100506661e-14\n", + " 1.2727917079577463e-16\n", + " 2.0634396850290369e-16" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xs = range(0, stop = 6.3, step = 0.01)\n", + "OX = [x for x in xs]\n", + "\n", + "# rysowane zbiory punktów:\n", + "res_cordic = [rel_error_cordic(x) for x in xs]\n", + "res_taylor = [rel_error_taylor(x) for x in xs]" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "data": [ + { + "colorbar": { + "title": "" + }, + "legendgroup": "cordic_sin", + "line": { + "color": "rgba(0, 154, 250, 1.000)", + "dash": "solid", + "shape": "linear", + "width": 1 + }, + "mode": "lines", + "name": "cordic_sin", + "showlegend": true, + "type": "scatter", + "x": [ + 0, + 0.01, + 0.02, + 0.03, + 0.04, + 0.05, + 0.06, + 0.07, + 0.08, + 0.09, + 0.1, + 0.11, + 0.12, + 0.13, + 0.14, + 0.15, + 0.16, + 0.17, + 0.18, + 0.19, + 0.2, + 0.21, + 0.22, + 0.23, + 0.24, + 0.25, + 0.26, + 0.27, + 0.28, + 0.29, + 0.3, + 0.31, + 0.32, + 0.33, + 0.34, + 0.35, + 0.36, + 0.37, + 0.38, + 0.39, + 0.4, + 0.41, + 0.42, + 0.43, + 0.44, + 0.45, + 0.46, + 0.47, + 0.48, + 0.49, + 0.5, + 0.51, + 0.52, + 0.53, + 0.54, + 0.55, + 0.56, + 0.57, + 0.58, + 0.59, + 0.6, + 0.61, + 0.62, + 0.63, + 0.64, + 0.65, + 0.66, + 0.67, + 0.68, + 0.69, + 0.7, + 0.71, + 0.72, + 0.73, + 0.74, + 0.75, + 0.76, + 0.77, + 0.78, + 0.79, + 0.8, + 0.81, + 0.82, + 0.83, + 0.84, + 0.85, + 0.86, + 0.87, + 0.88, + 0.89, + 0.9, + 0.91, + 0.92, + 0.93, + 0.94, + 0.95, + 0.96, + 0.97, + 0.98, + 0.99, + 1, + 1.01, + 1.02, + 1.03, + 1.04, + 1.05, + 1.06, + 1.07, + 1.08, + 1.09, + 1.1, + 1.11, + 1.12, + 1.13, + 1.14, + 1.15, + 1.16, + 1.17, + 1.18, + 1.19, + 1.2, + 1.21, + 1.22, + 1.23, + 1.24, + 1.25, + 1.26, + 1.27, + 1.28, + 1.29, + 1.3, + 1.31, + 1.32, + 1.33, + 1.34, + 1.35, + 1.36, + 1.37, + 1.38, + 1.39, + 1.4, + 1.41, + 1.42, + 1.43, + 1.44, + 1.45, + 1.46, + 1.47, + 1.48, + 1.49, + 1.5, + 1.51, + 1.52, + 1.53, + 1.54, + 1.55, + 1.56, + 1.57, + 1.58, + 1.59, + 1.6, + 1.61, + 1.62, + 1.63, + 1.64, + 1.65, + 1.66, + 1.67, + 1.68, + 1.69, + 1.7, + 1.71, + 1.72, + 1.73, + 1.74, + 1.75, + 1.76, + 1.77, + 1.78, + 1.79, + 1.8, + 1.81, + 1.82, + 1.83, + 1.84, + 1.85, + 1.86, + 1.87, + 1.88, + 1.89, + 1.9, + 1.91, + 1.92, + 1.93, + 1.94, + 1.95, + 1.96, + 1.97, + 1.98, + 1.99, + 2, + 2.01, + 2.02, + 2.03, + 2.04, + 2.05, + 2.06, + 2.07, + 2.08, + 2.09, + 2.1, + 2.11, + 2.12, + 2.13, + 2.14, + 2.15, + 2.16, + 2.17, + 2.18, + 2.19, + 2.2, + 2.21, + 2.22, + 2.23, + 2.24, + 2.25, + 2.26, + 2.27, + 2.28, + 2.29, + 2.3, + 2.31, + 2.32, + 2.33, + 2.34, + 2.35, + 2.36, + 2.37, + 2.38, + 2.39, + 2.4, + 2.41, + 2.42, + 2.43, + 2.44, + 2.45, + 2.46, + 2.47, + 2.48, + 2.49, + 2.5, + 2.51, + 2.52, + 2.53, + 2.54, + 2.55, + 2.56, + 2.57, + 2.58, + 2.59, + 2.6, + 2.61, + 2.62, + 2.63, + 2.64, + 2.65, + 2.66, + 2.67, + 2.68, + 2.69, + 2.7, + 2.71, + 2.72, + 2.73, + 2.74, + 2.75, + 2.76, + 2.77, + 2.78, + 2.79, + 2.8, + 2.81, + 2.82, + 2.83, + 2.84, + 2.85, + 2.86, + 2.87, + 2.88, + 2.89, + 2.9, + 2.91, + 2.92, + 2.93, + 2.94, + 2.95, + 2.96, + 2.97, + 2.98, + 2.99, + 3, + 3.01, + 3.02, + 3.03, + 3.04, + 3.05, + 3.06, + 3.07, + 3.08, + 3.09, + 3.1, + 3.11, + 3.12, + 3.13, + 3.14, + 3.15, + 3.16, + 3.17, + 3.18, + 3.19, + 3.2, + 3.21, + 3.22, + 3.23, + 3.24, + 3.25, + 3.26, + 3.27, + 3.28, + 3.29, + 3.3, + 3.31, + 3.32, + 3.33, + 3.34, + 3.35, + 3.36, + 3.37, + 3.38, + 3.39, + 3.4, + 3.41, + 3.42, + 3.43, + 3.44, + 3.45, + 3.46, + 3.47, + 3.48, + 3.49, + 3.5, + 3.51, + 3.52, + 3.53, + 3.54, + 3.55, + 3.56, + 3.57, + 3.58, + 3.59, + 3.6, + 3.61, + 3.62, + 3.63, + 3.64, + 3.65, + 3.66, + 3.67, + 3.68, + 3.69, + 3.7, + 3.71, + 3.72, + 3.73, + 3.74, + 3.75, + 3.76, + 3.77, + 3.78, + 3.79, + 3.8, + 3.81, + 3.82, + 3.83, + 3.84, + 3.85, + 3.86, + 3.87, + 3.88, + 3.89, + 3.9, + 3.91, + 3.92, + 3.93, + 3.94, + 3.95, + 3.96, + 3.97, + 3.98, + 3.99, + 4, + 4.01, + 4.02, + 4.03, + 4.04, + 4.05, + 4.06, + 4.07, + 4.08, + 4.09, + 4.1, + 4.11, + 4.12, + 4.13, + 4.14, + 4.15, + 4.16, + 4.17, + 4.18, + 4.19, + 4.2, + 4.21, + 4.22, + 4.23, + 4.24, + 4.25, + 4.26, + 4.27, + 4.28, + 4.29, + 4.3, + 4.31, + 4.32, + 4.33, + 4.34, + 4.35, + 4.36, + 4.37, + 4.38, + 4.39, + 4.4, + 4.41, + 4.42, + 4.43, + 4.44, + 4.45, + 4.46, + 4.47, + 4.48, + 4.49, + 4.5, + 4.51, + 4.52, + 4.53, + 4.54, + 4.55, + 4.56, + 4.57, + 4.58, + 4.59, + 4.6, + 4.61, + 4.62, + 4.63, + 4.64, + 4.65, + 4.66, + 4.67, + 4.68, + 4.69, + 4.7, + 4.71, + 4.72, + 4.73, + 4.74, + 4.75, + 4.76, + 4.77, + 4.78, + 4.79, + 4.8, + 4.81, + 4.82, + 4.83, + 4.84, + 4.85, + 4.86, + 4.87, + 4.88, + 4.89, + 4.9, + 4.91, + 4.92, + 4.93, + 4.94, + 4.95, + 4.96, + 4.97, + 4.98, + 4.99, + 5, + 5.01, + 5.02, + 5.03, + 5.04, + 5.05, + 5.06, + 5.07, + 5.08, + 5.09, + 5.1, + 5.11, + 5.12, + 5.13, + 5.14, + 5.15, + 5.16, + 5.17, + 5.18, + 5.19, + 5.2, + 5.21, + 5.22, + 5.23, + 5.24, + 5.25, + 5.26, + 5.27, + 5.28, + 5.29, + 5.3, + 5.31, + 5.32, + 5.33, + 5.34, + 5.35, + 5.36, + 5.37, + 5.38, + 5.39, + 5.4, + 5.41, + 5.42, + 5.43, + 5.44, + 5.45, + 5.46, + 5.47, + 5.48, + 5.49, + 5.5, + 5.51, + 5.52, + 5.53, + 5.54, + 5.55, + 5.56, + 5.57, + 5.58, + 5.59, + 5.6, + 5.61, + 5.62, + 5.63, + 5.64, + 5.65, + 5.66, + 5.67, + 5.68, + 5.69, + 5.7, + 5.71, + 5.72, + 5.73, + 5.74, + 5.75, + 5.76, + 5.77, + 5.78, + 5.79, + 5.8, + 5.81, + 5.82, + 5.83, + 5.84, + 5.85, + 5.86, + 5.87, + 5.88, + 5.89, + 5.9, + 5.91, + 5.92, + 5.93, + 5.94, + 5.95, + 5.96, + 5.97, + 5.98, + 5.99, + 6, + 6.01, + 6.02, + 6.03, + 6.04, + 6.05, + 6.06, + 6.07, + 6.08, + 6.09, + 6.1, + 6.11, + 6.12, + 6.13, + 6.14, + 6.15, + 6.16, + 6.17, + 6.18, + 6.19, + 6.2, + 6.21, + 6.22, + 6.23, + 6.24, + 6.25, + 6.26, + 6.27, + 6.28, + 6.29, + 6.3 + ], + "xaxis": "x", + "y": [ + 0, + 0.00016677621020938347, + 8.136330239480024e-05, + 3.1390036932902063e-06, + 4.3233507831440966e-05, + 3.3571872735614436e-05, + 6.630584034559424e-07, + 2.5506121816963454e-05, + 2.3042987121599685e-05, + 2.73189933923778e-06, + 1.7387761015487547e-05, + 1.622905631078576e-05, + 2.4754202598377782e-06, + 1.269274692074359e-05, + 1.2276610127581432e-05, + 2.418469066019671e-06, + 9.918746110841466e-06, + 9.782526483496634e-06, + 2.2695537474389798e-06, + 8.034939038575458e-06, + 2.6925764599116515e-06, + 3.922173541669577e-06, + 5.029558937496937e-06, + 4.1302849221522485e-06, + 3.7429998547060105e-06, + 4.202835570400495e-06, + 3.826632029978928e-06, + 3.546260872387151e-06, + 3.508730935892312e-06, + 3.638754591578394e-06, + 3.331954809314995e-06, + 2.1453600656640507e-06, + 3.426762875544479e-06, + 5.162888936079118e-07, + 5.036864880984133e-06, + 5.093171504887845e-06, + 6.086293275469183e-07, + 4.467130417358192e-06, + 4.505420244303924e-06, + 7.120645611256103e-07, + 3.9369354085236545e-06, + 9.838858437848442e-07, + 7.77418578690557e-07, + 3.51593352124834e-06, + 1.0076909122430796e-06, + 1.655158311995286e-06, + 2.4043822254662743e-06, + 1.7703119172759281e-06, + 1.6291193397887973e-06, + 2.140353871487183e-06, + 1.7477529186408324e-06, + 1.6301702379807873e-06, + 1.4104744250895807e-06, + 1.731946581448855e-06, + 1.6113385332296432e-06, + 1.2375890499695025e-06, + 1.7058808494438454e-06, + 1.9600509995603334e-06, + 7.145830791281689e-07, + 2.0262457900948957e-06, + 1.9078783511076866e-06, + 5.942311085682186e-07, + 2.0162739733958558e-06, + 1.8811682445964538e-06, + 4.748548450715459e-07, + 1.9710949121281292e-06, + 1.8350042720552876e-06, + 3.7853504295425717e-07, + 1.921721227254371e-06, + 2.0203008726931996e-07, + 1.4232904296101666e-07, + 2.1377895923441237e-06, + 2.8756659510980317e-07, + 2.2727723705575575e-07, + 1.9531920056448033e-06, + 3.2859969611650417e-07, + 2.8244905664856816e-07, + 1.7764930557950882e-06, + 3.782687870872815e-07, + 1.3037407793856227e-06, + 7.562428766961543e-07, + 1.1517435527049867e-06, + 1.1665589692723913e-06, + 7.718802095392873e-07, + 9.991396451326738e-07, + 1.0481845922212602e-06, + 7.658733146296648e-07, + 9.028695233238258e-07, + 6.400108386993461e-07, + 1.067184758690287e-06, + 5.13299710298778e-07, + 1.125945954653286e-06, + 1.0433750814731784e-06, + 4.37393920569202e-07, + 1.092463736780041e-06, + 1.0261270610232113e-06, + 3.6806826159369194e-07, + 1.0720933846894787e-06, + 1.0155213292289535e-06, + 3.1211025961174296e-07, + 1.038080622692402e-06, + 1.133358220154902e-06, + 1.1556219672455318e-07, + 1.1435251933148351e-06, + 1.0853293553008166e-06, + 7.469569308172553e-08, + 1.0428158421681541e-06, + 1.0377824005839457e-06, + 1.0215927043495327e-07, + 9.331099222543582e-07, + 9.367014931935066e-07, + 1.2527539449564007e-07, + 8.293700305166013e-07, + 6.722973556330139e-07, + 3.0496259831710155e-07, + 5.755661706218008e-07, + 5.975777994927455e-07, + 3.041907552177807e-07, + 5.099218360758454e-07, + 3.428481963718889e-07, + 3.045599449936168e-07, + 4.4004290757728077e-07, + 3.344361113581753e-07, + 2.9715154282543336e-07, + 3.856900311337885e-07, + 5.779055118798982e-07, + 3.920394806861428e-09, + 5.716259302950991e-07, + 5.373507344029019e-07, + 1.9963592243478292e-08, + 5.272117775293123e-07, + 4.96161097507389e-07, + 3.7939407172573845e-08, + 4.4946334855629977e-07, + 4.492272658549481e-07, + 4.0134392134995915e-08, + 3.7986072515472317e-07, + 2.9861996526012693e-07, + 1.1514945599244228e-07, + 2.472596866977524e-07, + 1.2707638303389167e-07, + 1.0101683861908647e-07, + 1.9795947937788527e-07, + 1.0857965381340321e-07, + 9.655786186190439e-08, + 1.5170517635756876e-07, + 9.15089264175772e-08, + 7.949869072810901e-08, + 1.0801315162126919e-07, + 7.201338636425357e-08, + 7.530250679868071e-08, + 5.360316800541461e-08, + 6.095019097460274e-08, + 4.843356488266589e-08, + 1.9091332503951412e-08, + 2.4623657666393807e-08, + 1.5299334820649933e-08, + 4.184901531050682e-10, + 5.843648817360347e-09, + 1.32812232699413e-08, + 3.097778673579372e-08, + 2.9584889621572948e-08, + 3.7248187345509306e-08, + 5.8951187874844764e-08, + 5.649112025685202e-08, + 8.308664418800058e-08, + 6.201118127497604e-08, + 1.1423629772877784e-07, + 1.1998264064133654e-07, + 7.467994129291393e-08, + 1.571873667710581e-07, + 1.6368068361431314e-07, + 8.468085985132633e-08, + 1.9975572469275567e-07, + 7.555246887154466e-08, + 9.806778597773041e-08, + 2.531176187765936e-07, + 8.328594611592928e-08, + 2.2064785239322082e-08, + 3.9036648135312413e-07, + 5.238057399383078e-09, + 6.125737041506026e-09, + 4.571511566609404e-07, + 1.864896655056474e-08, + 8.302553503456434e-09, + 5.346147164397727e-07, + 4.250570248570329e-08, + 2.7745708880905565e-08, + 5.227345654431287e-07, + 6.4704613530997e-08, + 2.586357796387307e-07, + 3.872281281805299e-07, + 3.7051704553938665e-07, + 2.6786272347036687e-07, + 4.386372659046718e-07, + 2.2977218046915754e-07, + 2.678405862825747e-07, + 5.094642458537421e-07, + 2.2382578501459784e-07, + 2.664513264974218e-07, + 5.762666292911002e-07, + 2.2087115826361445e-07, + 6.770720063221348e-08, + 8.306921804074056e-07, + 2.13505643220662e-08, + 4.8021337987529953e-08, + 9.231098709152851e-07, + 6.800716322105629e-09, + 1.598798349995861e-08, + 1.0024772605874508e-06, + 4.6219775968058614e-08, + 1.2588494303194095e-08, + 1.0412039174972583e-06, + 9.473809826842581e-08, + 2.0131257939343222e-07, + 9.223819493862206e-07, + 2.9866983962347206e-07, + 2.4781101602778816e-07, + 9.498415955148546e-07, + 3.5131966648986526e-07, + 3.0794797357366016e-07, + 9.636607159482467e-07, + 4.2218146388662263e-07, + 9.03925746048819e-07, + 9.84390951254022e-07, + 4.915100587218641e-07, + 9.13526431200576e-07, + 6.914921097749508e-07, + 8.894983742138714e-07, + 6.049099099788847e-07, + 6.610646303786138e-07, + 9.857698054286815e-07, + 5.91046215479638e-07, + 6.415662310110644e-07, + 1.1152953851316633e-06, + 5.634574682705778e-07, + 1.5686851206750682e-06, + 1.7294887784038136e-07, + 1.7714006072746958e-06, + 1.730807210270564e-06, + 1.1370912493636692e-07, + 1.9550687670502676e-06, + 1.9004281422602033e-06, + 6.169515151094907e-08, + 2.1346605559649647e-06, + 1.0156726576107437e-07, + 4.59471018255886e-07, + 1.9971877127367594e-06, + 6.49095594909011e-07, + 5.580124089269955e-07, + 2.0516141421743213e-06, + 7.586500089476397e-07, + 7.305469093531957e-07, + 2.09912280446682e-06, + 9.053717555265411e-07, + 8.432196642332121e-07, + 2.1558567855673484e-06, + 1.0443759587273774e-06, + 1.3640706883984284e-06, + 1.8317419696168569e-06, + 1.6029438530035396e-06, + 1.5508927949937706e-06, + 1.4116660095779266e-06, + 1.8041486808219034e-06, + 1.7812805373664235e-06, + 1.3981003550027754e-06, + 2.1205826278387086e-06, + 2.01837435276314e-06, + 1.4069046489670083e-06, + 2.3869364199054503e-06, + 3.055472779889327e-06, + 5.9525278057603e-07, + 3.5275017088594584e-06, + 3.2451697405909503e-07, + 5.206740016662081e-07, + 3.957380844175005e-06, + 2.1045316756134873e-07, + 3.995349236020163e-07, + 4.497519386231671e-06, + 7.110066670940273e-08, + 2.0749269980682052e-07, + 5.087159697949744e-06, + 2.3684663439354745e-06, + 2.8857187504666256e-06, + 2.8793476715228005e-06, + 2.813076818257833e-06, + 3.0369214769282343e-06, + 3.519693799152605e-06, + 3.3966848454070925e-06, + 3.180636263123593e-06, + 4.216328071726493e-06, + 4.0555015342576406e-06, + 3.3786228223701446e-06, + 5.086239683434251e-06, + 3.083720091452432e-06, + 1.7670118840319036e-06, + 8.24643024824966e-06, + 1.1984652016920644e-06, + 1.7813870207188e-06, + 1.0255544061830541e-05, + 1.1030608723380003e-06, + 1.481504318993448e-06, + 1.3336355554527497e-05, + 8.290889308929516e-07, + 1.3901794832688515e-06, + 1.832596420123065e-05, + 5.131738016905805e-07, + 1.995222992217299e-06, + 2.9945361668663875e-05, + 4.807132363976872e-06, + 4.688438992266793e-06, + 4.824133555540869e-05, + 1.396092878441276e-05, + 2.2833140359470374e-05, + 0.0009162939252287975, + 2.6267555460253545e-05, + 1.4044966400875843e-05, + 6.447328501756225e-05, + 4.0995280450886906e-06, + 4.262067089241002e-06, + 3.220806629035887e-05, + 1.1201119861059786e-06, + 1.001301644934874e-06, + 1.8534568946130973e-05, + 2.158866885356622e-06, + 1.1956388277094093e-06, + 1.3352638857834146e-05, + 2.0570861326432168e-06, + 1.0462916551747843e-05, + 1.0196982769604098e-05, + 2.0465596292309897e-06, + 8.19624262246364e-06, + 8.175017954978889e-06, + 2.0006451794667927e-06, + 6.658052733939689e-06, + 4.822907663164333e-06, + 3.61899120512606e-06, + 3.954743020567983e-06, + 4.005966844965583e-06, + 3.3625420622151497e-06, + 3.2873397026217485e-06, + 3.305983763685475e-06, + 4.148578293435779e-06, + 2.7222396550992205e-06, + 2.7756930305496353e-06, + 3.879677496428694e-06, + 2.2804646305679867e-06, + 5.018238351694565e-06, + 4.0805779507409517e-07, + 4.347856314313516e-06, + 4.4251302377706235e-06, + 5.04583277085943e-07, + 3.836018227892394e-06, + 3.896304562934789e-06, + 6.163513316330261e-07, + 3.375757717404599e-06, + 3.3986542643076634e-06, + 6.915592968933292e-07, + 3.005778672939432e-06, + 2.2681131838795328e-06, + 1.4859629015025608e-06, + 1.949838890730368e-06, + 2.0090380645775204e-06, + 1.986834457572499e-06, + 1.7226285234092275e-06, + 1.7487197709525904e-06, + 1.9547860750073204e-06, + 1.4921552434383949e-06, + 1.5444957899764357e-06, + 1.914601191900645e-06, + 1.264459609441954e-06, + 9.848234452063935e-07, + 2.234998440843193e-06, + 7.481312408358838e-07, + 8.490097705138624e-07, + 2.1689190074666352e-06, + 6.327367039752739e-07, + 2.2616472531561394e-06, + 2.119452681413545e-06, + 5.114710425662731e-07, + 2.201217811496104e-06, + 2.059034261620805e-06, + 4.0908094309487583e-07, + 2.140352606776852e-06, + 2.061257949573939e-06, + 1.0247215376214176e-07, + 1.8648661373086343e-06, + 1.887077311004228e-06, + 1.5877067119790254e-07, + 1.7019552093789325e-06, + 1.710597505763873e-06, + 4.92810059656002e-07, + 1.5343415199685513e-06, + 6.059462603123253e-07, + 1.0829064471685249e-06, + 7.128600803509171e-07, + 6.365731024612185e-07, + 9.57756516473787e-07, + 7.302766113638304e-07, + 8.05125478385067e-07, + 8.586151586514856e-07, + 7.290279407799948e-07, + 7.16455518140869e-07, + 4.657120386904872e-07, + 1.0213885739977663e-06, + 3.4364837794771835e-07, + 3.7429386287717867e-07, + 1.0013736219850955e-06, + 2.847647688737152e-07, + 3.0829797466031765e-07, + 9.824837392870833e-07, + 2.2433546871339207e-07, + 2.517783048808815e-07, + 1.128294750188373e-06, + 1.7642364675183023e-07, + 5.0934221055954684e-08, + 1.1161814365581977e-06, + 6.311459513195471e-09, + 2.3015511602970997e-08, + 1.0132834558390009e-06, + 3.886790357451061e-08, + 1.8704563664921285e-08, + 9.094312233805292e-07, + 8.452385079865297e-08, + 4.301701755712191e-08, + 8.18912778542283e-07, + 1.0343393315847527e-07, + 7.163637255801159e-07, + 5.616308845324068e-07, + 2.8536390428618235e-07, + 4.757546091790386e-07, + 4.946994330915469e-07, + 2.859286173694266e-07, + 4.217731838016017e-07, + 4.166072650637562e-07, + 2.8370025285791154e-07, + 3.5523151711040205e-07, + 3.653514083601695e-07, + 2.786078248160347e-07, + 3.0896165467210857e-07, + 6.053586593679036e-07, + 1.3447001654204897e-08, + 2.57782116256493e-08, + 5.276054740913599e-07, + 6.628983542078349e-09, + 7.406879953632981e-09, + 4.5395549576686275e-07, + 2.423065465542607e-08, + 3.866642901383941e-07, + 3.850923501930089e-07, + 3.1862487695475616e-08, + 3.2342231229948956e-07, + 2.48689910697336e-07, + 1.0631111690031574e-07, + 2.052096534466154e-07, + 2.006694486392371e-07, + 9.27927010605262e-08, + 1.565944576295951e-07, + 1.5475468335068268e-07, + 8.606391704832061e-08, + 1.1971665101309176e-07, + 1.1264370236996784e-07, + 9.077683600735547e-08, + 8.336950459274067e-08, + 5.6409644619865374e-08, + 8.069380774109636e-08, + 3.4740763775934173e-08, + 3.0766812476665594e-08, + 4.572964385573037e-08, + 1.1988311290631891e-08, + 5.063895784809524e-09, + 5.6278649133510036e-09, + 7.920037535984654e-09, + 2.1556471266115275e-08, + 2.3833802023791726e-08, + 4.199092915875403e-08, + 5.31872902277771e-08, + 5.53685538557165e-08, + 6.944798944105674e-08, + 6.456420091904043e-08, + 1.0853878097426772e-07, + 7.220565757094848e-08, + 8.298595126383666e-08, + 1.526666354146231e-07, + 8.484078569134354e-08, + 1.9301191262483898e-07, + 2.03085300315276e-07, + 9.763678185806494e-08, + 2.510941593394132e-07, + 2.5512528481343864e-07, + 1.0496458006111885e-07, + 3.0465017587011186e-07, + 3.888842803827447e-07, + 3.15977907899036e-08, + 4.300444487191299e-07, + 4.5947022525802873e-07, + 4.457358351319885e-08, + 4.788229184872339e-07, + 5.078125138403814e-07, + 6.690656819358082e-08, + 5.19838810060751e-07, + 5.527621816662534e-07, + 9.11221885823643e-08, + 5.501908702910252e-07, + 3.9482578008442074e-07, + 2.76871433675417e-07, + 4.662333038511122e-07, + 4.559936537230247e-07, + 2.8620533561917043e-07, + 5.332890700312287e-07, + 5.348517020233348e-07, + 2.835033564484093e-07, + 6.107220931107148e-07, + 6.057075682971134e-07, + 2.873389312475139e-07, + 6.845123029909193e-07, + 8.534060298010892e-07, + 2.9207088538187996e-08, + 9.509902727269769e-07, + 9.515111331562438e-07, + 5.7404725068603334e-08, + 1.0205031574441393e-06, + 1.0562907048235364e-06, + 1.005384109996792e-07, + 1.039464975621465e-06, + 1.1139116336251914e-06, + 1.36414534167152e-07, + 1.0775332335147047e-06, + 1.0052119324302351e-06, + 3.3541729890938936e-07, + 9.618306543775862e-07, + 1.0354124374508527e-06, + 3.94521951820584e-07, + 9.930902089692318e-07, + 5.050364753963192e-07, + 4.668265763819949e-07, + 1.0054530103180947e-06, + 5.88467012946433e-07, + 5.62248046394485e-07, + 1.0238335250566913e-06, + 6.645267727829921e-07, + 9.52709522879686e-07, + 7.341953243087967e-07, + 1.0817970046836948e-06, + 1.0544745942687076e-06, + 4.866717243418797e-07, + 1.193160402425052e-06, + 1.1835608470314852e-06, + 4.5626633773964563e-07, + 1.334307392340307e-06, + 3.312130948484368e-07, + 1.8055919043728453e-06, + 2.06774261109133e-07, + 2.836015693609774e-07, + 1.9864739426616124e-06, + 1.4605625775180768e-07, + 2.103407559202128e-06, + 2.17030350341847e-06, + 9.315494412835267e-08, + 2.174560512392218e-06, + 1.8601184364824968e-06, + 4.25979002097143e-07, + 1.7713014101550298e-06, + 1.8698835504719406e-06, + 5.198324048482947e-07, + 1.8118587603422188e-06, + 1.906184442626963e-06, + 1.0266800482336264e-06, + 1.8377179548226696e-06, + 1.956918135623305e-06, + 1.1736278415310166e-06, + 1.8828777561955507e-06, + 1.6266560602723885e-06, + 1.7207352496750878e-06, + 1.5351365186696437e-06, + 1.653151707950917e-06, + 1.93280717443021e-06, + 1.5007195270023523e-06, + 1.6601359462348644e-06, + 2.196477641939507e-06, + 1.480250500561593e-06, + 1.6743668109827781e-06, + 2.4621954448640057e-06, + 1.50091403140485e-06, + 2.87581473136407e-06, + 3.565786788860893e-06, + 6.786619509708832e-07, + 4.069863882813699e-06, + 4.002430698566922e-06, + 6.108526007401109e-07, + 4.551150710923135e-06, + 4.593017026756196e-06, + 5.046942983055157e-07, + 5.1621753681482535e-06, + 5.1778510726075526e-06, + 3.743637173893063e-07, + 5.541757288214633e-06, + 3.0786181268314195e-06, + 3.0758118249191078e-06, + 3.4580035041185573e-06, + 3.605391636253404e-06, + 3.24586102323824e-06, + 3.6286138811564624e-06, + 4.2983929320823735e-06, + 3.4190614871136356e-06, + 5.247080316631971e-06, + 5.121680773962285e-06, + 3.658639119748256e-06, + 6.290949921962391e-06, + 8.098307662173378e-06, + 2.011285907818575e-06, + 9.81150348802739e-06, + 1.0121101560280998e-05, + 2.0836875586024124e-06, + 1.2289029141254689e-05, + 1.291463852107093e-05, + 6.539491072073676e-08, + 1.6140902382078228e-05, + 1.7234689161566977e-05, + 6.715634932876199e-07, + 2.2595986357094136e-05, + 2.377734868469825e-05, + 5.506161673691973e-06, + 3.080678784177108e-05, + 3.913736395244706e-05, + 1.202761233704277e-05, + 6.706121953572653e-05, + 0.00012328971426099088, + 0.00014728921364518045, + 0.0002543247898438008, + 9.919388454847705e-05 + ], + "yaxis": "y", + "zmax": null, + "zmin": null + } + ], + "layout": { + "annotations": [], + "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.1209135316418781, + 0.9934383202099738 + ], + "gridcolor": "rgba(0, 0, 0, 0.100)", + "gridwidth": 0.5, + "linecolor": "rgba(0, 0, 0, 1.000)", + "mirror": false, + "range": [ + -0.189, + 6.489 + ], + "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", + "1", + "2", + "3", + "4", + "5", + "6" + ], + "tickvals": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "title": "x", + "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.9901574803149606 + ], + "gridcolor": "rgba(0, 0, 0, 0.100)", + "gridwidth": 0.5, + "linecolor": "rgba(0, 0, 0, 1.000)", + "mirror": false, + "range": [ + -2.7488817756863925e-05, + 0.0009437827429856615 + ], + "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.0000", + "0.0002", + "0.0004", + "0.0006", + "0.0008" + ], + "tickvals": [ + 0, + 0.0002, + 0.0004, + 0.0006000000000000001, + 0.0008 + ], + "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": [ + "\n", + "\n", + " \n", + " Plots.jl\n", + " \n", + " \n", + " \n", + " \n", + "
\n", + " \n", + "\n", + " \n", + "\n" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Błąd względny obliczania sinusa Cordicem na przedziale (0, 6.3)\n", + "plot(OX, res_cordic, xguide = \"x\", yguide = \"relative error\", label = \"cordic_sin\")" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "data": [ + { + "colorbar": { + "title": "" + }, + "legendgroup": "taylor_sin", + "line": { + "color": "rgba(0, 154, 250, 1.000)", + "dash": "solid", + "shape": "linear", + "width": 1 + }, + "mode": "lines", + "name": "taylor_sin", + "showlegend": true, + "type": "scatter", + "x": [ + 0, + 0.01, + 0.02, + 0.03, + 0.04, + 0.05, + 0.06, + 0.07, + 0.08, + 0.09, + 0.1, + 0.11, + 0.12, + 0.13, + 0.14, + 0.15, + 0.16, + 0.17, + 0.18, + 0.19, + 0.2, + 0.21, + 0.22, + 0.23, + 0.24, + 0.25, + 0.26, + 0.27, + 0.28, + 0.29, + 0.3, + 0.31, + 0.32, + 0.33, + 0.34, + 0.35, + 0.36, + 0.37, + 0.38, + 0.39, + 0.4, + 0.41, + 0.42, + 0.43, + 0.44, + 0.45, + 0.46, + 0.47, + 0.48, + 0.49, + 0.5, + 0.51, + 0.52, + 0.53, + 0.54, + 0.55, + 0.56, + 0.57, + 0.58, + 0.59, + 0.6, + 0.61, + 0.62, + 0.63, + 0.64, + 0.65, + 0.66, + 0.67, + 0.68, + 0.69, + 0.7, + 0.71, + 0.72, + 0.73, + 0.74, + 0.75, + 0.76, + 0.77, + 0.78, + 0.79, + 0.8, + 0.81, + 0.82, + 0.83, + 0.84, + 0.85, + 0.86, + 0.87, + 0.88, + 0.89, + 0.9, + 0.91, + 0.92, + 0.93, + 0.94, + 0.95, + 0.96, + 0.97, + 0.98, + 0.99, + 1, + 1.01, + 1.02, + 1.03, + 1.04, + 1.05, + 1.06, + 1.07, + 1.08, + 1.09, + 1.1, + 1.11, + 1.12, + 1.13, + 1.14, + 1.15, + 1.16, + 1.17, + 1.18, + 1.19, + 1.2, + 1.21, + 1.22, + 1.23, + 1.24, + 1.25, + 1.26, + 1.27, + 1.28, + 1.29, + 1.3, + 1.31, + 1.32, + 1.33, + 1.34, + 1.35, + 1.36, + 1.37, + 1.38, + 1.39, + 1.4, + 1.41, + 1.42, + 1.43, + 1.44, + 1.45, + 1.46, + 1.47, + 1.48, + 1.49, + 1.5, + 1.51, + 1.52, + 1.53, + 1.54, + 1.55, + 1.56, + 1.57, + 1.58, + 1.59, + 1.6, + 1.61, + 1.62, + 1.63, + 1.64, + 1.65, + 1.66, + 1.67, + 1.68, + 1.69, + 1.7, + 1.71, + 1.72, + 1.73, + 1.74, + 1.75, + 1.76, + 1.77, + 1.78, + 1.79, + 1.8, + 1.81, + 1.82, + 1.83, + 1.84, + 1.85, + 1.86, + 1.87, + 1.88, + 1.89, + 1.9, + 1.91, + 1.92, + 1.93, + 1.94, + 1.95, + 1.96, + 1.97, + 1.98, + 1.99, + 2, + 2.01, + 2.02, + 2.03, + 2.04, + 2.05, + 2.06, + 2.07, + 2.08, + 2.09, + 2.1, + 2.11, + 2.12, + 2.13, + 2.14, + 2.15, + 2.16, + 2.17, + 2.18, + 2.19, + 2.2, + 2.21, + 2.22, + 2.23, + 2.24, + 2.25, + 2.26, + 2.27, + 2.28, + 2.29, + 2.3, + 2.31, + 2.32, + 2.33, + 2.34, + 2.35, + 2.36, + 2.37, + 2.38, + 2.39, + 2.4, + 2.41, + 2.42, + 2.43, + 2.44, + 2.45, + 2.46, + 2.47, + 2.48, + 2.49, + 2.5, + 2.51, + 2.52, + 2.53, + 2.54, + 2.55, + 2.56, + 2.57, + 2.58, + 2.59, + 2.6, + 2.61, + 2.62, + 2.63, + 2.64, + 2.65, + 2.66, + 2.67, + 2.68, + 2.69, + 2.7, + 2.71, + 2.72, + 2.73, + 2.74, + 2.75, + 2.76, + 2.77, + 2.78, + 2.79, + 2.8, + 2.81, + 2.82, + 2.83, + 2.84, + 2.85, + 2.86, + 2.87, + 2.88, + 2.89, + 2.9, + 2.91, + 2.92, + 2.93, + 2.94, + 2.95, + 2.96, + 2.97, + 2.98, + 2.99, + 3, + 3.01, + 3.02, + 3.03, + 3.04, + 3.05, + 3.06, + 3.07, + 3.08, + 3.09, + 3.1, + 3.11, + 3.12, + 3.13, + 3.14, + 3.15, + 3.16, + 3.17, + 3.18, + 3.19, + 3.2, + 3.21, + 3.22, + 3.23, + 3.24, + 3.25, + 3.26, + 3.27, + 3.28, + 3.29, + 3.3, + 3.31, + 3.32, + 3.33, + 3.34, + 3.35, + 3.36, + 3.37, + 3.38, + 3.39, + 3.4, + 3.41, + 3.42, + 3.43, + 3.44, + 3.45, + 3.46, + 3.47, + 3.48, + 3.49, + 3.5, + 3.51, + 3.52, + 3.53, + 3.54, + 3.55, + 3.56, + 3.57, + 3.58, + 3.59, + 3.6, + 3.61, + 3.62, + 3.63, + 3.64, + 3.65, + 3.66, + 3.67, + 3.68, + 3.69, + 3.7, + 3.71, + 3.72, + 3.73, + 3.74, + 3.75, + 3.76, + 3.77, + 3.78, + 3.79, + 3.8, + 3.81, + 3.82, + 3.83, + 3.84, + 3.85, + 3.86, + 3.87, + 3.88, + 3.89, + 3.9, + 3.91, + 3.92, + 3.93, + 3.94, + 3.95, + 3.96, + 3.97, + 3.98, + 3.99, + 4, + 4.01, + 4.02, + 4.03, + 4.04, + 4.05, + 4.06, + 4.07, + 4.08, + 4.09, + 4.1, + 4.11, + 4.12, + 4.13, + 4.14, + 4.15, + 4.16, + 4.17, + 4.18, + 4.19, + 4.2, + 4.21, + 4.22, + 4.23, + 4.24, + 4.25, + 4.26, + 4.27, + 4.28, + 4.29, + 4.3, + 4.31, + 4.32, + 4.33, + 4.34, + 4.35, + 4.36, + 4.37, + 4.38, + 4.39, + 4.4, + 4.41, + 4.42, + 4.43, + 4.44, + 4.45, + 4.46, + 4.47, + 4.48, + 4.49, + 4.5, + 4.51, + 4.52, + 4.53, + 4.54, + 4.55, + 4.56, + 4.57, + 4.58, + 4.59, + 4.6, + 4.61, + 4.62, + 4.63, + 4.64, + 4.65, + 4.66, + 4.67, + 4.68, + 4.69, + 4.7, + 4.71, + 4.72, + 4.73, + 4.74, + 4.75, + 4.76, + 4.77, + 4.78, + 4.79, + 4.8, + 4.81, + 4.82, + 4.83, + 4.84, + 4.85, + 4.86, + 4.87, + 4.88, + 4.89, + 4.9, + 4.91, + 4.92, + 4.93, + 4.94, + 4.95, + 4.96, + 4.97, + 4.98, + 4.99, + 5, + 5.01, + 5.02, + 5.03, + 5.04, + 5.05, + 5.06, + 5.07, + 5.08, + 5.09, + 5.1, + 5.11, + 5.12, + 5.13, + 5.14, + 5.15, + 5.16, + 5.17, + 5.18, + 5.19, + 5.2, + 5.21, + 5.22, + 5.23, + 5.24, + 5.25, + 5.26, + 5.27, + 5.28, + 5.29, + 5.3, + 5.31, + 5.32, + 5.33, + 5.34, + 5.35, + 5.36, + 5.37, + 5.38, + 5.39, + 5.4, + 5.41, + 5.42, + 5.43, + 5.44, + 5.45, + 5.46, + 5.47, + 5.48, + 5.49, + 5.5, + 5.51, + 5.52, + 5.53, + 5.54, + 5.55, + 5.56, + 5.57, + 5.58, + 5.59, + 5.6, + 5.61, + 5.62, + 5.63, + 5.64, + 5.65, + 5.66, + 5.67, + 5.68, + 5.69, + 5.7, + 5.71, + 5.72, + 5.73, + 5.74, + 5.75, + 5.76, + 5.77, + 5.78, + 5.79, + 5.8, + 5.81, + 5.82, + 5.83, + 5.84, + 5.85, + 5.86, + 5.87, + 5.88, + 5.89, + 5.9, + 5.91, + 5.92, + 5.93, + 5.94, + 5.95, + 5.96, + 5.97, + 5.98, + 5.99, + 6, + 6.01, + 6.02, + 6.03, + 6.04, + 6.05, + 6.06, + 6.07, + 6.08, + 6.09, + 6.1, + 6.11, + 6.12, + 6.13, + 6.14, + 6.15, + 6.16, + 6.17, + 6.18, + 6.19, + 6.2, + 6.21, + 6.22, + 6.23, + 6.24, + 6.25, + 6.26, + 6.27, + 6.28, + 6.29, + 6.3 + ], + "xaxis": "x", + "y": [ + 0, + 0, + 0, + 1.1566558078817942e-16, + 0, + 1.3883571906382453e-16, + 0, + 0, + 1.7365752302283546e-16, + 1.5440600601196135e-16, + 1.3900944467230525e-16, + 0, + 1.1592625449066459e-16, + 2.1410698643685947e-16, + 0, + 1.8573288595220103e-16, + 1.742147128409055e-16, + 0, + 1.550334678484203e-16, + 0, + 1.3970739975089753e-16, + 0, + 1.2718518789423714e-16, + 0, + 0, + 0, + 2.159290184445561e-16, + 2.0811626825981194e-16, + 2.0086852401853256e-16, + 3.882547247947197e-16, + 0, + 0, + 1.7646869750723767e-16, + 0, + 0, + 1.6188832364718382e-16, + 0, + 1.5350880057750542e-16, + 0, + 0, + 1.4254888689156825e-16, + 0, + 2.722733448755912e-16, + 0, + 1.3032638622170484e-16, + 1.2762195364440624e-16, + 1.250397295546284e-16, + 0, + 0, + 1.1795175876740006e-16, + 0, + 0, + 1.1171940072339029e-16, + 2.196142042736769e-16, + 4.3187913028824577e-16, + 0, + 2.090082590569337e-16, + 0, + 0, + 1.9955082741286808e-16, + 0, + 0, + 3.8215347367222716e-16, + 1.8844655912799408e-16, + 0, + 1.8345141498591358e-16, + 0, + 1.7878390942818387e-16, + 0, + 3.4883210459118443e-16, + 0, + 3.4064605854503194e-16, + 1.6837258611209998e-16, + 0, + 1.6465118319330336e-16, + 0, + 0, + 0, + 1.578637159448543e-16, + 1.5629167454196935e-16, + 1.5476595775927705e-16, + 1.532849212179731e-16, + 0, + 1.5045071507872196e-16, + 1.4909464612640263e-16, + 1.477774499413219e-16, + 0, + 1.452546110508059e-16, + 0, + 1.4287265341439178e-16, + 1.417317611561603e-16, + 1.406228962336717e-16, + 1.3954509350727686e-16, + 0, + 0, + 0, + 1.3552666648263445e-16, + 1.345911326469577e-16, + 1.3368170256426966e-16, + 0, + 0, + 0, + 1.3029134757883222e-16, + 2.5900486029405794e-16, + 0, + 1.2799092667421588e-16, + 0, + 1.2656433953411267e-16, + 1.2588164830089048e-16, + 1.2521873705069078e-16, + 1.2457516335464547e-16, + 0, + 1.233443483196787e-16, + 1.2275630930933019e-16, + 0, + 0, + 1.2109721422220227e-16, + 0, + 2.4015050945509647e-16, + 2.391771081954276e-16, + 0, + 0, + 1.1822210473839875e-16, + 0, + 1.1738653067416278e-16, + 1.1699062366037716e-16, + 1.1660899981092887e-16, + 0, + 1.1588774994706041e-16, + 0, + 1.1522117101256962e-16, + 1.1490791931420558e-16, + 1.1460779588236164e-16, + 1.1432063831500512e-16, + 0, + 1.1378461074234033e-16, + 0, + 1.1329869284272903e-16, + 0, + 1.1286185879983775e-16, + 1.1266155855947696e-16, + 1.124731953208035e-16, + 1.122966717242045e-16, + 1.121318968823932e-16, + 0, + 1.1183726159005393e-16, + 0, + 0, + 0, + 0, + 0, + 0, + 1.1116569019772567e-16, + 0, + 0, + 0, + 0, + 0, + 1.1102700484490524e-16, + 0, + 0, + 0, + 1.1115683074271789e-16, + 0, + 0, + 0, + 0, + 1.1157085733943192e-16, + 1.1168760293015215e-16, + 0, + 1.11955472547079e-16, + 0, + 1.1226964448329402e-16, + 0, + 1.126307622356178e-16, + 1.1282915453744712e-16, + 0, + 0, + 1.1349692044505526e-16, + 1.137440937560308e-16, + 0, + 1.1427609063975448e-16, + 0, + 0, + 1.1517039502318996e-16, + 1.1549481576023593e-16, + 0, + 1.161841897801159e-16, + 0, + 0, + 0, + 1.177306001482301e-16, + 1.1815339462774402e-16, + 1.185911384901203e-16, + 0, + 0, + 1.199966709968528e-16, + 0, + 1.2101341766311912e-16, + 1.2154661532375033e-16, + 0, + 0, + 1.2324949112332057e-16, + 1.238527347224392e-16, + 1.2447442106926859e-16, + 1.251149545968473e-16, + 1.2577475689976607e-16, + 1.2645426748250882e-16, + 1.2715394455164995e-16, + 2.557485317095469e-16, + 0, + 1.2937885524388145e-16, + 0, + 1.309722835800706e-16, + 2.6360748298455665e-16, + 0, + 0, + 1.344445629182283e-16, + 1.3537589080570123e-16, + 1.3633394011664738e-16, + 0, + 0, + 0, + 0, + 1.4155303865666858e-16, + 0, + 1.4385736250252208e-16, + 1.4505988639078172e-16, + 1.4629743682461252e-16, + 4.4271350632044795e-16, + 0, + 0, + 0, + 1.5305306314935545e-16, + 1.5452712997703393e-16, + 0, + 4.72830518175548e-16, + 1.592224968196643e-16, + 1.6088440402557424e-16, + 1.625978010891599e-16, + 0, + 0, + 1.6806760811164993e-16, + 1.7000823026008362e-16, + 3.440231866850208e-16, + 3.4816069967792357e-16, + 1.762173094080196e-16, + 1.7842545056179684e-16, + 0, + 1.83068113520149e-16, + 1.8550955722214991e-16, + 1.880360581677667e-16, + 1.9065165564143022e-16, + 1.9336065460624755e-16, + 3.9233529552097936e-16, + 1.9907753983176333e-16, + 0, + 2.052273634035169e-16, + 4.1695784027423524e-16, + 2.1185669538011786e-16, + 0, + 2.1901913925635238e-16, + 2.228192841116798e-16, + 2.267767059975127e-16, + 3.463511251393722e-16, + 1.1760076176335253e-16, + 1.1984498723136674e-16, + 2.443779812477027e-16, + 2.492784531475008e-16, + 1.272027222341621e-16, + 2.5977428418430155e-16, + 3.9810258537989523e-16, + 2.713061049462177e-16, + 2.77507554764331e-16, + 4.2604230884374537e-16, + 2.908924537074325e-16, + 2.981272525136537e-16, + 4.586436898171784e-16, + 4.707468570695312e-16, + 1.611852619422922e-16, + 3.314215813629388e-16, + 5.115459810125667e-16, + 1.7562486954369834e-16, + 3.621375108653764e-16, + 5.606406413151237e-16, + 3.861940659664331e-16, + 1.9976237036163137e-16, + 4.1385148093764346e-16, + 6.439326906977197e-16, + 5.574600095575805e-16, + 5.800554531712935e-16, + 6.046230094380958e-16, + 6.314295987455109e-16, + 5.286340832803578e-16, + 6.930923870916901e-16, + 5.830309787261056e-16, + 4.610656012872442e-16, + 6.501968567158412e-16, + 6.900496309238551e-16, + 9.189814298467548e-16, + 7.867226199095508e-16, + 8.461214961940835e-16, + 1.0297364864912689e-15, + 9.96956873142869e-16, + 1.368375404781893e-15, + 1.365555992149667e-15, + 1.362200875249003e-15, + 1.7460848831280113e-15, + 1.9163943510111623e-15, + 2.4219633740662516e-15, + 3.0038023196651155e-15, + 3.954111337202982e-15, + 5.624138754026257e-15, + 1.0475027331465813e-14, + 7.692501248866752e-14, + 1.4443567319413918e-14, + 6.5972301646406274e-15, + 4.275196108257585e-15, + 3.2527840224536355e-15, + 2.581196698545988e-15, + 2.0207781980178856e-15, + 2.0302815585144125e-15, + 1.594597481044501e-15, + 1.4146215679596336e-15, + 1.2712659337838948e-15, + 1.1543965522365806e-15, + 9.398247530195528e-16, + 8.669907995892048e-16, + 1.2070627104194234e-15, + 5.63133637027713e-16, + 7.038055971384979e-16, + 6.623750745065613e-16, + 6.256101964236946e-16, + 7.409601290981525e-16, + 7.040696284275414e-16, + 5.365937383997834e-16, + 5.123907293078001e-16, + 4.903237553301557e-16, + 4.701240782332899e-16, + 5.64457794804972e-16, + 6.516895026784688e-16, + 4.186422170561888e-16, + 2.0198751140496525e-16, + 3.9033848758762595e-16, + 1.8881452337315674e-16, + 5.486348546129152e-16, + 3.546422505683688e-16, + 1.7210844180680809e-16, + 3.3441944520939856e-16, + 3.2519591945573497e-16, + 4.747474809175474e-16, + 3.082838747033346e-16, + 1.502571654479259e-16, + 4.397330688653356e-16, + 2.8617615612702595e-16, + 1.397744111740744e-16, + 1.3662410086365711e-16, + 1.3362573515847505e-16, + 2.615378881495673e-16, + 3.84132850320522e-16, + 2.5088626784309084e-16, + 2.4591522597448154e-16, + 2.411609958216707e-16, + 1.1830515823406596e-16, + 4.645019854415669e-16, + 2.2807179031946066e-16, + 2.2406234327532465e-16, + 4.404261434629184e-16, + 2.1651510897764416e-16, + 0, + 0, + 2.062497865979453e-16, + 2.0308052062986278e-16, + 2.00026879333912e-16, + 5.912493798688494e-16, + 3.8848780987071593e-16, + 1.9150420465215325e-16, + 3.7771867286950397e-16, + 0, + 1.8383679219386276e-16, + 0, + 5.374328004375144e-16, + 3.538255951266435e-16, + 1.7475349614049675e-16, + 0, + 1.706394298924782e-16, + 0, + 1.6677979118636341e-16, + 0, + 0, + 1.614244914205175e-16, + 1.5974639490452063e-16, + 3.162369558719701e-16, + 0, + 1.550059187078887e-16, + 3.0703574565125046e-16, + 4.562195644258387e-16, + 4.520111007352465e-16, + 4.479239531389108e-16, + 1.479846845085956e-16, + 2.9339835201611706e-16, + 4.3635068591177836e-16, + 2.8847333952391093e-16, + 2.861147622891691e-16, + 0, + 2.8159479189618573e-16, + 2.794294178091305e-16, + 1.3866230613540849e-16, + 1.3763930022308267e-16, + 0, + 1.3567812292598344e-16, + 1.347383644442359e-16, + 1.3382482498261752e-16, + 1.3293679391630032e-16, + 1.3207359088969112e-16, + 0, + 1.3041909020121958e-16, + 1.2962657045647168e-16, + 0, + 0, + 0, + 1.266749249735528e-16, + 1.2598904139149041e-16, + 1.2532300997324656e-16, + 1.2467638534529696e-16, + 2.4809748058291475e-16, + 1.2343966499087125e-16, + 1.228487662980177e-16, + 0, + 1.217200054842107e-16, + 1.211814345078375e-16, + 0, + 2.403084928565876e-16, + 0, + 1.1919160012646444e-16, + 1.1873375372367847e-16, + 0, + 1.1786366571203686e-16, + 1.1745091831979103e-16, + 1.1705271597077228e-16, + 1.1666883197167736e-16, + 0, + 1.159431612485339e-16, + 1.1560096921050324e-16, + 0, + 0, + 0, + 0, + 1.1408913439809627e-16, + 0, + 0, + 1.13335576274266e-16, + 1.1310913742096956e-16, + 0, + 0, + 0, + 1.1232399696452744e-16, + 0, + 0, + 1.1185902892546942e-16, + 0, + 1.116068067205613e-16, + 1.1149782137461506e-16, + 0, + 1.1131382650628477e-16, + 0, + 0, + 0, + 0, + 0, + 1.1103082323835086e-16, + 0, + 0, + 1.1103952136087052e-16, + 0, + 1.1110087422561315e-16, + 1.111482546097965e-16, + 0, + 1.1127654203590062e-16, + 0, + 0, + 0, + 1.116682452440973e-16, + 1.1179460276394605e-16, + 0, + 1.1208186433579785e-16, + 1.1224291488962e-16, + 0, + 1.1260026828125086e-16, + 2.255935105086198e-16, + 1.1300524934831442e-16, + 0, + 0, + 0, + 1.139615708235788e-16, + 0, + 1.1451492765818807e-16, + 1.1481090382159398e-16, + 1.1511995564462182e-16, + 1.1544225107817406e-16, + 1.1577796641086888e-16, + 0, + 1.1649040509766376e-16, + 1.1686752498974867e-16, + 1.172588584202073e-16, + 1.1766462732973934e-16, + 1.1808506369274515e-16, + 0, + 1.1897091891543958e-16, + 0, + 0, + 1.2041612350137525e-16, + 1.209300435268994e-16, + 2.4292113410861716e-16, + 1.220080203971579e-16, + 0, + 0, + 0, + 0, + 1.250116608673639e-16, + 1.2566836536960143e-16, + 1.2634470692275536e-16, + 1.270411406998836e-16, + 1.2775814127819088e-16, + 1.2849620351960983e-16, + 1.2925584350397737e-16, + 0, + 1.3084203310632902e-16, + 0, + 1.3252130220909538e-16, + 0, + 1.3429865235506927e-16, + 1.3522579286198734e-16, + 0, + 0, + 2.763398071695497e-16, + 4.176244571865108e-16, + 0, + 1.4137512447723414e-16, + 2.8501141514186526e-16, + 4.3100700504617343e-16, + 1.4486605008501036e-16, + 1.4609794609662345e-16, + 1.4736583597381477e-16, + 1.4867092201840918e-16, + 1.5001446590650702e-16, + 3.027955845229322e-16, + 1.5282229249143696e-16, + 4.628682867434504e-16, + 3.1160147839328055e-16, + 4.720735233925574e-16, + 4.768873133628965e-16, + 4.818489692145068e-16, + 0, + 4.922388773801941e-16, + 4.976794250466422e-16, + 3.3552831543197403e-16, + 3.3939004479692484e-16, + 1.7168821935212026e-16, + 3.474927540733853e-16, + 5.276168379658806e-16, + 1.7806887700364007e-16, + 3.6067860072377473e-16, + 3.653737457482551e-16, + 3.7023025241565105e-16, + 1.8762781663467565e-16, + 3.804578860517068e-16, + 3.8584553321761154e-16, + 1.9571383268998396e-16, + 3.972139891509996e-16, + 0, + 4.0944144007780993e-16, + 2.0795278182375914e-16, + 4.2262000765257808e-16, + 2.147992357893987e-16, + 6.552835285415283e-16, + 3.333056321357456e-16, + 5.653388022234267e-16, + 3.4534855765927816e-16, + 4.690085762611658e-16, + 5.974051962186521e-16, + 4.872349332393389e-16, + 4.969663806653859e-16, + 6.339327832945269e-16, + 3.883535282291679e-16, + 6.612185522346913e-16, + 5.406927923382882e-16, + 5.529982124920038e-16, + 5.659346964712524e-16, + 4.3466270766498696e-16, + 4.454235028799948e-16, + 6.090366171355489e-16, + 4.687734971589835e-16, + 6.419547431386734e-16, + 6.598879258178374e-16, + 6.7892168171707615e-16, + 6.991580574555936e-16, + 5.405341027196453e-16, + 5.577856436088656e-16, + 9.603903370021445e-16, + 7.946753360364779e-16, + 8.229970997614497e-16, + 8.53500714909746e-16, + 1.1080557445894173e-15, + 1.1526620823533043e-15, + 1.0810220332254982e-15, + 1.1285963531614852e-15, + 1.0494882678197345e-15, + 1.1003739582952188e-15, + 1.3011380459329525e-15, + 1.3713040537010517e-15, + 1.4496222788057203e-15, + 1.7084347734374231e-15, + 1.637100998723299e-15, + 1.5560615516704497e-15, + 1.881140068692716e-15, + 1.920035175288847e-15, + 2.211721171685521e-15, + 2.2904575492979325e-15, + 2.684565604502478e-15, + 2.839380050077419e-15, + 3.0367153263107948e-15, + 3.956085449056853e-15, + 4.6990042927913394e-15, + 5.625450115568505e-15, + 7.319681171152798e-15, + 1.062538454174323e-14, + 1.8551186877114254e-14, + 7.69251100506661e-14, + 1.2727917079577463e-16, + 2.0634396850290369e-16 + ], + "yaxis": "y", + "zmax": null, + "zmin": null + } + ], + "layout": { + "annotations": [], + "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.2986913094196558, + 0.9934383202099738 + ], + "gridcolor": "rgba(0, 0, 0, 0.100)", + "gridwidth": 0.5, + "linecolor": "rgba(0, 0, 0, 1.000)", + "mirror": false, + "range": [ + -0.189, + 6.489 + ], + "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", + "1", + "2", + "3", + "4", + "5", + "6" + ], + "tickvals": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "title": "x", + "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.9901574803149606 + ], + "gridcolor": "rgba(0, 0, 0, 0.100)", + "gridwidth": 0.5, + "linecolor": "rgba(0, 0, 0, 1.000)", + "mirror": false, + "range": [ + -2.307753301519983e-15, + 7.923286335218608e-14 + ], + "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", + "2×10−14", + "4×10−14", + "6×10−14" + ], + "tickvals": [ + 0, + 2e-14, + 4e-14, + 6e-14 + ], + "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": [ + "\n", + "\n", + " \n", + " Plots.jl\n", + " \n", + " \n", + " \n", + " \n", + "
\n", + " \n", + "\n", + " \n", + "\n" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Błąd względny obliczania sinusa szeregiem Taylora na przedziale (0, 6.3)\n", + "plot(OX, res_taylor, xguide = \"x\", yguide = \"relative error\", label = \"taylor_sin\")" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [], + "source": [ + "# Poniżej znajdują się funkcje testujące, na podstawie których powstała Tabela 2 w sprawozdaniu" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "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": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "TESTS = 100000000\n", + "\n", + "Random.seed!(12345)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "taylor_test_error_real (generic function with 3 methods)" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# wszystkie te funkcje wyglądają bardzo podobnie\n", + "\n", + "function taylor_test_error_real(l::Float64=floatmin(), r::Float64=floatmax())\n", + " res = BigFloat(0) # suma błędów względnych\n", + " abs_res = BigFloat(0) # suma błędów bezwzględnych\n", + " maksi_rel = BigFloat(0) # max bląd względny\n", + " maksi_abs = BigFloat(0) # max bląd bezwzględny\n", + " for i = 1:TESTS\n", + " # losujemy argument z przedziału [l, r]\n", + " x = rand(Uniform(l, r))\n", + " lib_sin = sin(x)\n", + " # sprawdzanie błędu względnego z zerem nie ma sensu\n", + " if lib_sin == 0\n", + " continue\n", + " end\n", + " my_sin = taylor_sin(x, 0)\n", + " # obliczamy błąd względny względem funkcji bibliotecznej\n", + " error = rel_error(lib_sin, my_sin[1])\n", + " # obliczamy błąd bezwzględny względem funkcji bibliotecznej\n", + " abs_error = abs(my_sin[1] - lib_sin)\n", + " # aktualizujemy błędy\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": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "taylor_test_error_complex (generic function with 3 methods)" + ] + }, + "execution_count": 30, + "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", + " 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": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "cordic_test_error (generic function with 3 methods)" + ] + }, + "execution_count": 31, + "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:TESTSd\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": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "taylor_without_reduction_test_error (generic function with 3 methods)" + ] + }, + "execution_count": 32, + "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", + " 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)" + ] + } + ], + "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 +} diff --git a/Semestr 3/anm/pracowniaPOP/prog/program.jl b/Semestr 3/anm/pracowniaPOP/prog/program.jl new file mode 100644 index 0000000..d75f82b --- /dev/null +++ b/Semestr 3/anm/pracowniaPOP/prog/program.jl @@ -0,0 +1,273 @@ +using Printf + +# stałe dla CORDIC'A +global C_ITERATIONS = 30 +global CORDIC_MUL_POW = 30 +global CORDIC_MUL = 2.0^CORDIC_MUL_POW +global CORDIC_ATANS = [843314857, 497837829, 263043837, 133525159, 67021687, 33543516, 16775851, + 8388437, 4194283, 2097149, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, + 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2] +global CORDIC_F = 1768195363 +global CORDIC_F_INV = 652032874 + +# stałe dla obliczania szeregiem Taylora +global T_ITERATIONS = 15 +global HYPERBOLIC_MAX = 1 + +# liczenie szeregu Taylora +function series(x, parity, change_sign, iterations) + res = zero(x) + elem = one(x) + if parity == 1 + elem = x + end + i = parity + 1 + while i <= 2*iterations + parity + res += elem + elem *= change_sign*x*x/(i*(i+1)) + i += 2 + end + return res +end + +# generyczna funkcja stosująca wzory redukcyjne, licząca sin(x) +# za pomocą podanych funkcji sin_fun, cos_fun +function gen_sin(x, iterations, sin_fun, cos_fun) + # sin(-x) = sin(x) + if x < 0 + return -gen_sin(-x, iterations, sin_fun, cos_fun) + end + x = mod2pi(x) + # sin(π + x) = -sin(x) + if x > pi + return -gen_sin(x-pi, iterations, sin_fun, cos_fun) + end + # sin(π/2 + x) = cos(x) + if x > pi/2 + return gen_cos(x-pi/2, iterations, sin_fun, cos_fun) + end + # sin(π/2 - x) = cos(x) + if x > pi/4 + return gen_cos(pi/2-x, iterations, sin_fun, cos_fun) + end + return sin_fun(x, iterations) +end + +# generyczna funkcja stosująca wzory redukcyjne, licząca cos(x) +# za pomocą podanych funkcji sin_fun, cos_fun +function gen_cos(x, iterations, sin_fun, cos_fun) + # cos(-x) = cos(x) + if x < 0 + return gen_cos(-x, iterations, sin_fun, cos_fun) + end + x = mod2pi(x) + # cos(π + x) = -cos(x) + if x > pi + return -gen_cos(x-pi, iterations, sin_fun, cos_fun) + end + # cos(π/2 + x) = -sin(x) + if x > pi/2 + return -gen_sin(x-pi/2, iterations, sin_fun, cos_fun) + end + # cos(π/2 - x) = sin(x) + if x > pi/4 + return gen_sin(pi/2-x, iterations, sin_fun, cos_fun) + end + return cos_fun(x, iterations) +end + +# sin dla liczb rzeczywistych [Taylor] +function real_sin(r, iterations) + return series(r, 1, -1, iterations) +end + +# cos dla liczb rzeczywistych [Taylor] +function real_cos(r, iterations) + return series(r, 0, -1, iterations) +end + +# sinh [Taylor] +function real_sinh(r, iterations) + # sinh(1000) jest za duży by reprezentować go we Float64 + if r > 1000 + return Inf + end + if r < -1000 + return -Inf + end + if r == 0 + return Float64(0) + end + # dla dużych liczb korzystamy ze wzoru: + # sinh(2r) = 2 * cosh(r) * sinh(r) + if abs(r) > HYPERBOLIC_MAX + return 2*real_sinh(r/2, iterations)*real_cosh(r/2, iterations) + end + return series(r, 1, 1, iterations) +end + +# cosh [Taylor] +function real_cosh(r, iterations) + # cosh(1000) jest za duży by reprezentować go we Float64 + if abs(r) > 1000 + return Inf + end + if r == 1 + return Float64(1) + end + # dla dużych liczb korzystamy ze wzoru: + # cosh(2r) = cosh(r)^2 + sinh(r)^2 + if abs(r) > HYPERBOLIC_MAX + s = real_sinh(r/2, iterations) + c = real_cosh(r/2, iterations) + return s*s+c*c + end + return series(r, 0, 1, iterations) +end + +# sin dla liczb zespolonych [Taylor] +function complex_sin(a, b, iterations) + # sin(a + bi) = sin(a) * cosh(b) + i(cos(a) * sinh(b)) + return (gen_sin(a, iterations, real_sin, real_cos)*real_cosh(b, iterations), + gen_cos(a, iterations, real_sin, real_cos)*real_sinh(b, iterations)) +end + +# cos dla liczb zespolonych [Taylor] +function complex_cos(a, b, iterations) + # cos(a + bi) = cos(a) * cosh(b) - i(sin(a) * sinh(b)) + return (real_cos(a, iterations)*real_cosh(b, iterations), + -real_sin(a, iterations)*real_sinh(b, iterations)) +end + +# funkcja sin dla użytkownika [Taylor] +function taylor_sin(a, b) + return complex_sin(a, b, T_ITERATIONS) +end + +# funkcja cos dla użytkownika [Taylor] +function taylor_cos(a, b) + return complex_cos(a, b, T_ITERATIONS) +end + +# funkcja sinh dla użytkownika [Taylor] +function taylor_sinh(r) + return real_sinh(r, T_ITERATIONS) +end + +# funkcja cosh dla użytkownika [Taylor] +function taylor_cosh(r) + return real_cosh(r, T_ITERATIONS) +end + +# preprocesing [CORDIC] +function preprocess_atan(iterations) + global CORDIC_MUL + atan2pow = Array{Float64}(undef, iterations) + @printf("CORDIC_ATANS = [") + for i in 1:iterations + atan2pow[i] = round(atan(1.0 / Float64(BigInt(2)^(i - 1))) * CORDIC_MUL) + @printf("%d", atan2pow[i]) + if i < iterations + @printf(", ") + end + end + @printf("]\n") +end + + +# preprocesing [CORDIC] +function preprocess_scaling_factor(iterations) + CORDIC_F = 1.0 + for i in 0:iterations + CORDIC_F *= sqrt(1. + 1. / Float64(BigInt(2)^(2 * i))) + end + @printf("CORDIC_F = %d\nCORDIC_F_INV = %d\n", round(CORDIC_F * CORDIC_MUL), round(CORDIC_MUL / CORDIC_F)) +end + + +# funkcja licząca zarówno cosx oraz sinx algorytmem CORDIC +function approx_trig(x, iterations) + global CORDIC_ATANS + global CORDIC_F_INV + X = CORDIC_F_INV + Y = 0 + Z = round(x * CORDIC_MUL) + s = 1 + # Proces iteracyjny algorytmu CORDIC + for i in 0:(iterations - 1) + tempX = X + if Z == 0 + break + end + if Z >= 0 + X -= s * (Y >> i) + Y += s * (tempX >> i) + Z -= s * CORDIC_ATANS[i + 1] + else + X += s * (Y >> i) + Y -= s * (tempX >> i) + Z += s * CORDIC_ATANS[i + 1] + end + end + + return (Float64(X) / CORDIC_MUL, Float64(Y) / CORDIC_MUL) +end + +# wyciąganie sin z approx_trig [CORDIC] +function approx_sin(x, iterations) + return approx_trig(x, iterations)[2] +end + + +# wyciąganie cos z approx_trig [CORDIC] +function approx_cos(x, iterations) + return approx_trig(x, iterations)[1] +end + +# funkcja sin dla użytkownika [CORDIC] +function cordic_sin(x) + return gen_sin(x, C_ITERATIONS, approx_sin, approx_cos) +end + +# funkcja cos dla użytkownika [CORDIC] +function cordic_cos(x) + return gen_cos(x, C_ITERATIONS, approx_sin, approx_cos) +end + +# uruchamianie preprocesingu [CORDIC] +# funkcja wypisuje kod w języku Julia na ekran, który potem po prostu wkleiliśmy do pliku źródłowego +# oblicza stałe potrzebne do obliczania funkcji trygonometrycznych metodą CORDIC +function preprocess_cordic() + println("Preprocessing CORDIC constants.") + preprocess_atan(CORDIC_MUL_POW) + preprocess_scaling_factor(CORDIC_MUL_POW) +end + +# sinh bez stosowania wzorów redukcyjnych [Taylor] +function sinh_no_reduction(x, iterations) + return series(x, 1, 1, iterations) +end + +# cosh bez stosowania wzorów redukcyjnych [Taylor] +function cosh_no_reduction(x, iterations) + return series(x, 0, 1, iterations) +end + +# sin bez stosowania wzorów redukcyjnych [Taylor] +function taylor_sin_no_reduction(x, y) + # sin(a + bi) = sin(a) * cosh(b) + i(cos(a) * sinh(b)) + # wykonujemy odpowiednio (10a + 10), (10b + 10) iteracji - szereg Tylora + # powinien dobrze przybliżać funkcje trygonometryczne dla takiej liczby wyrazów + return (real_sin(x, 10*round(x)+10) * cosh_no_reduction(y, 10*round(y)+10), + real_cos(x, 10*round(x)+10) * sinh_no_reduction(y, 10*round(y)+10)) +end + +# zmiana liczby iteracji [Taylor] +function set_taylor_iterations(x) + global T_ITERATIONS = x +end + +# zmiana liczby iteracji [CORDIC] +function set_cordic_iterations(x) + global C_ITERATIONS = x +end \ No newline at end of file -- cgit v1.2.3