{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "280489f9-b194-48d2-8614-7b1bfecfb705",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using Plots\n",
"\n",
"f(k) = √(k+1) - √(k-1)\n",
"g(k) = 2/(√(k+1) + √(k-1))\n",
"h(k) = 1/√k\n",
"\n",
"k = (10^9-1000):10^9\n",
"plot(k, f; label=\"√(k+1) - √(k-1)\", alpha=0.5, lw=0.7)\n",
"plot!(k, g; label=\"2/(√(k+1) + √(k-1))\", ls=:dash)\n",
"plot!(k, h; label=\"1/√k\", ls=:dashdot)\n",
"plot!(rightmargin=5Plots.mm)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3d7f077f-7d65-4c8e-bedb-78594b39efa8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"f(1000000000) = 3.162277789670043e-5\n",
"g(1000000000) = 3.1622776601683795e-5\n",
"h(1000000000) = 3.1622776601683795e-5\n"
]
}
],
"source": [
"k = 10^9\n",
"@eval @show f($k) g($k) h($k);"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "dd603595-c261-4240-a184-a2099c3b07d2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"f(1000000000) = 3.162277660168379332394178251953765950392353891919764888393048074577188547896907e-05\n",
"g(1000000000) = 3.162277660168379332394178251953765950392353891919764888393048074577180873944593e-05\n",
"h(1000000000) = 3.162277660168379331998893544432718533719555139325216826857504852792594438639224e-05\n"
]
}
],
"source": [
"k = big(10^9)\n",
"@eval @show f($k) g($k) h($k);"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "09cb580a-76a0-4e4f-8f1c-b1ebc8f26fe6",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using Plots\n",
"\n",
"F(a, b, c) = (-b + √(b^2 - 4a*c))/(2a)\n",
"G(a, b, c) = (2c)/(-b - √(b^2 - 4a*c))\n",
"\n",
"b, c = 1, 1\n",
"a = range(-3e-8, 3e-8, 2001)\n",
"plot(a, a -> F(a, b, c); label=\"(-b + √(b^2 - 4a*c))/(2a)\", lw=0.7)\n",
"plot!(a, a -> G(a, b, c); label=\"(2c)/(-b - √(b^2 - 4a*c))\", ls=:dash)\n",
"plot!(rightmargin=4Plots.mm)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "3ed212a9-fcd0-40b2-a824-dd836dc7b823",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"F(1 / 1000000000, 1, 1) = -1.0000000272292198\n",
"G(1 / 1000000000, 1, 1) = -1.000000001\n"
]
}
],
"source": [
"n = 10^9\n",
"@eval @show F(1/$n, 1, 1) G(1/$n, 1, 1);"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "7b49308c-254c-4512-b40a-5cdba27ccd4f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"F(1 / 1000000000, 1, 1) = -1.000000001000000002000000005000000014000000042000000132000000429000000655609063\n",
"G(1 / 1000000000, 1, 1) = -1.000000001000000002000000005000000014000000042000000132000000429000001429999996\n"
]
}
],
"source": [
"n = big(10^9)\n",
"@eval @show F(1/$n, 1, 1) G(1/$n, 1, 1);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "059c6870-6339-4483-b349-4b2d73eba49a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"jupytext": {
"encoding": "# -*- coding: utf-8 -*-",
"formats": "ipynb,jl:hydrogen"
},
"kernelspec": {
"display_name": "Julia 1.8.2",
"language": "julia",
"name": "julia-1.8"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}