You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://gitter.im/JuliaApproximation/ApproxFun.jl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
12
12
13
13
14
-
15
14
ApproxFun is a package for approximating functions. It is in a similar vein to the Matlab
16
15
package [`Chebfun`](http://www.chebfun.org) and the Mathematica package [`RHPackage`](https://github.com/dlfivefifty/RHPackage).
17
16
18
-
The [`ApproxFun Documentation`](https://JuliaApproximation.github.io/ApproxFun.jl/latest) contains detailed information, or read on for a brief overview of the package.
17
+
The [`ApproxFun Documentation`](https://JuliaApproximation.github.io/ApproxFun.jl/latest) contains detailed information, or read on for a brief overview of the package. The documentation contains examples of usage, such as solving ordinary and partial differential equations.
19
18
20
-
The [`ApproxFun Examples`](https://github.com/JuliaApproximation/ApproxFunExamples) contains many examples of
21
-
using this package, in Jupyter notebooks and Julia scripts.
19
+
The [`ApproxFun Examples`](https://github.com/JuliaApproximation/ApproxFunExamples)repo contains many examples of
20
+
using this package, in Jupyter notebooks and Julia scripts. Note that this is independently maintained, so it might not always be in sync with the latest version of `ApproxFun`. We recommend checking the examples in the documentation first, as these will always be compatible with the latest version of the package.
22
21
23
22
## Introduction
24
23
24
+
### Approximating Functions
25
25
26
26
Take your two favourite functions on an interval and create approximations to them as simply as:
Notice from above that to find the extrema, we used `'` overridden for the `differentiate` function. Several other `Julia`
57
-
base functions are overridden for the purposes of calculus. Because the exponential is its own
58
-
derivative, the `norm` is small:
57
+
base functions are overridden for the purposes of calculus. We may check that the exponential is its own derivative, by evaluating the norm of the difference and checking that it is small:
59
58
60
59
```julia
61
-
f =Fun(x->exp(x), -1..1)
60
+
f =Fun(exp, -1..1)
62
61
norm(f-f') # 4.4391656415701095e-14
63
62
```
64
63
@@ -70,7 +69,7 @@ g = g + f(-1)
70
69
norm(f-g) # 3.4989733283850415e-15d
71
70
```
72
71
73
-
Algebraic and differential operations are also implemented where possible, and most of Julia's built-in functions are overridden to accept `Fun`s:
72
+
Algebraic and differential operations are also implemented where possible, and most of Julia's built-in functions (and special functions from [`SpecialFunctions.jl`](https://github.com/JuliaMath/SpecialFunctions.jl)) are overridden to accept `Fun`s:
74
73
75
74
```julia
76
75
x =Fun()
@@ -79,188 +78,9 @@ g = besselj(3,exp(f))
79
78
h =airyai(10asin(f)+2g)
80
79
```
81
80
81
+
## Examples of Usage
82
82
83
-
## Solving ordinary differential equations
84
-
85
-
86
-
We can also solve differential equations. Consider the Airy ODE `u'' - x u = 0` as a boundary value problem on `[-1000,200]` with conditions `u(-1000) = 1` and `u(200) = 2`. The unique solution is a linear combination of Airy functions. We can calculate it as follows:
87
-
88
-
```julia
89
-
x =Fun(identity, -1000..200) # the function x on the interval -1000..200
90
-
D =Derivative() # The derivative operator
91
-
B =Dirichlet() # Dirichlet conditions
92
-
L = D^2- x # the Airy operator
93
-
u = [B;L] \ [[1,2],0] # Calculate u such that B*u == [1,2] and L*u == 0
Solve a nonlinear boundary value problem satisfying the ODE `0.001u'' + 6*(1-x^2)*u' + u^2 = 1` with boundary conditions `u(-1)==1`, `u(1)==-0.5` on `[-1,1]`:
103
-
104
-
```julia
105
-
x =Fun()
106
-
u₀ =0.0x # initial guess
107
-
N = u -> [u(-1)-1, u(1)+0.5, 0.001u''+6*(1-x^2)*u'+ u^2-1]
108
-
u =newton(N, u₀) # perform Newton iteration in function space
0 commit comments