{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "1127f968-1a32-41a3-aa5d-d071615ca752", "metadata": {}, "outputs": [], "source": [ "using QuadGK" ] }, { "cell_type": "code", "execution_count": 2, "id": "8c6fd18f-375f-41d8-977e-9deb382cd985", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 3.615248 seconds (102.46 M allocations: 1.682 GiB, 6.61% gc time, 31.70% compilation time)\n", " 2.071347 seconds (99.33 M allocations: 1.502 GiB, 1.69% gc time)\n", " 2.042287 seconds (99.33 M allocations: 1.502 GiB, 1.54% gc time)\n" ] }, { "data": { "text/plain": [ "(3.143368529490813, 0.1453072535439617)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = 1.0\n", "f = x -> sin(a*x)/(a*x)\n", "@time quadgk(f, -1e8, 0, 1e8)\n", "@time quadgk(f, -1e8, 0, 1e8)\n", "@time quadgk(f, -1e8, 0, 1e8)" ] }, { "cell_type": "code", "execution_count": 3, "id": "ae693cdd-7d03-48ae-b9f8-827bfaf1f1aa", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "#1 (function of type var\"#1#2\")\n" ] } ], "source": [ "dump(f)" ] }, { "cell_type": "code", "execution_count": 4, "id": "2ab1df01-b2cb-4965-b8c9-7fef2a3f5958", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.825576 seconds (7.15 M allocations: 165.328 MiB, 4.23% gc time, 25.27% compilation time)\n", " 0.752624 seconds (6.67 M allocations: 139.071 MiB, 16.41% gc time)\n", " 0.561307 seconds (6.67 M allocations: 131.071 MiB, 1.08% gc time)\n" ] }, { "data": { "text/plain": [ "(3.143368529490813, 0.1453072535439617)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = 1.0\n", "g = let a = a; x -> sin(a*x)/(a*x) end\n", "@time quadgk(g, -1e8, 0, 1e8)\n", "@time quadgk(g, -1e8, 0, 1e8)\n", "@time quadgk(g, -1e8, 0, 1e8)" ] }, { "cell_type": "code", "execution_count": 5, "id": "2ed1dc88-9846-458c-8541-29478c72b141", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "#3 (function of type var\"#3#4\"{Float64})\n", " a: Float64 1.0\n" ] } ], "source": [ "dump(g)" ] }, { "cell_type": "code", "execution_count": 6, "id": "3e3e70cc-cee7-4c31-9a8f-8205e5d44f5c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.760919 seconds (6.68 M allocations: 139.744 MiB, 3.36% gc time, 23.61% compilation time)\n", " 0.684874 seconds (6.67 M allocations: 139.071 MiB, 15.97% gc time)\n", " 0.560951 seconds (6.67 M allocations: 131.071 MiB, 1.20% gc time)\n" ] }, { "data": { "text/plain": [ "(3.143368529490813, 0.1453072535439617)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function F(a = 1.0)\n", " quadgk(x -> sin(a*x)/(a*x), -1e8, 0, 1e8)\n", "end\n", "\n", "@time F()\n", "@time F()\n", "@time F()" ] }, { "cell_type": "code", "execution_count": null, "id": "57dc8bde-8cae-42c4-b478-4343a252eac7", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "jupytext": { "formats": "ipynb,auto:hydrogen" }, "kernelspec": { "display_name": "Julia 1.6.2", "language": "julia", "name": "julia-1.6" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.6.2" } }, "nbformat": 4, "nbformat_minor": 5 }