An open API service indexing awesome lists of open source software.

https://github.com/juliaapproximation/framefun.jl

Exploring practical possibilities of approximating functions with frames rather than with a basis
https://github.com/juliaapproximation/framefun.jl

Last synced: 12 months ago
JSON representation

Exploring practical possibilities of approximating functions with frames rather than with a basis

Awesome Lists containing this project

README

          

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![Build Status](https://travis-ci.org/daanhb/FrameFun.jl.svg?branch=master)](https://travis-ci.org/daanhb/FrameFun.jl)\n",
"[![Coverage Status](https://coveralls.io/repos/github/daanhb/FrameFun.jl/badge.svg)](https://coveralls.io/github/daanhb/FrameFun.jl)\n",
"\n",
"FrameFun\n",
"========\n",
"\n",
"Exploring practical possibilities of approximating functions with frames rather than with a basis. The package is heavily inspired by the Chebfun project and the Julia package ApproxFun."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using BasisFunctions, Plots, DomainSets, FrameFun\n",
"gr();"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Frame Approximations in 1D"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After choosing a suitable Basis and Domain, any function can be approximated in the resulting frame:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"B = Fourier(61) → -1..1\n",
"D = -0.5..0.5\n",
"f = x->x\n",
"F = Fun(f,B,D)\n",
"\n",
"P = plot(F,layout = 2)\n",
"plot!(F,f,subplot=2)\n",
"Plots.savefig(P,\"images/lowprecision.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](images/lowprecision.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The bases support any AbstractFloat subtype, so high precision approximations are straightforward:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"B = Fourier(61) → big(-1)..big(1)\n",
"F = Fun(f,B,D)\n",
"\n",
"P = plot(F,layout=2)\n",
"plot!(F,f,subplot=2)\n",
"Plots.savefig(P,\"images/highprecision.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](images/highprecision.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](images/highprecision.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Frame Approximations in 2D"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In higher dimensions, a basis can be any tensorproduct of (scaled) lower dimensional bases:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using StaticArrays\n",
"C = Disk(1.0)\\Disk(0.3,SVector(0.2, 0.5))\n",
"B = (Fourier(31) → -1.3..1.3)^2\n",
"f = (x,y)->exp(x+y)\n",
"F = Fun(f,B,C)\n",
"\n",
"P = heatmap(F,layout=2,aspect_ratio=1)\n",
"plot!(F,f,subplot=2,aspect_ratio=1)\n",
"Plots.savefig(P,\"images/deathstar.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](images/deathstar.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Even fractal domains are not a problem:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"B = (Fourier(31) → -1.0..0.35) ⊗ (Fourier(31) → -0.65..0.65)\n",
"f = (x,y)->cos(10*x*y)\n",
"F = Fun(f, B, mandelbrot())\n",
"\n",
"P = heatmap(F,layout=2,aspect_ratio=1)\n",
"plot!(F,f,aspect_ratio=1,subplot=2)\n",
"Plots.savefig(P,\"images/mandelbrot\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](images/mandelbrot.png)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Julia 1.0.1",
"language": "julia",
"name": "julia-1.0"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.0.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}