diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-05-15 16:21:29 +0200 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-05-15 16:21:29 +0200 |
commit | d917f41beca176b8f2b682ac3a2c25b148752b71 (patch) | |
tree | 7dca0da8e57841f2f8efa31783196888511002cd /t | |
parent | f5cb35b87255ebbe2d322bcedde6bc7d5f6aebae (diff) |
Add syntax form for writing macros
* src/core.lisp (syntax): Change evaluation rules to replace arguments inside
macro expansion.
* src/eval.lisp (tree-eval): Add Evaluation route for chains with a syntax
closure.
* t/test4.chn: New file.
Diffstat (limited to 't')
-rw-r--r-- | t/test3.chn | 4 | ||||
-rw-r--r-- | t/test4.chn | 65 |
2 files changed, 67 insertions, 2 deletions
diff --git a/t/test3.chn b/t/test3.chn index d989187..42a0b97 100644 --- a/t/test3.chn +++ b/t/test3.chn @@ -1,3 +1,3 @@ {@define}{@define-function}{{@syntax}{@name @args @body}{{@define}{@name}{{@lambda}{@args}{@body}}}}% -{@define-function}{@foo}{@a}{hola @a}% -%{@foo}{mundo} +{@define-function}{@foo}{@a @b}{hola @b}% +{@foo}{mundo}{casa} diff --git a/t/test4.chn b/t/test4.chn new file mode 100644 index 0000000..e126091 --- /dev/null +++ b/t/test4.chn @@ -0,0 +1,65 @@ +{@define}{@title}{Method for solving first order and Bernoulli's differential equations} +{@define}{@author}{Thomas Albers Raviola} +{@define}{@date}{2022-10-01} +% +{@template} +{@section}{History} +I came across the method concerning this article in an old math book from Doctor +Granville (Elements of differential and integral calculus - ISBN-13: +978-968-18-1178-5). It doesn't appear to be a popular technique as when using it +for my assignments I always had to explain what I was doing. As of yet, I still +haven't found another text referencing it, which is why I decided to include it +in my website. + +In the original book this procedure is shown but never really explained, it is +left as a sort of "it just works" thing. Here is my attempt to it clear. + +{@section}{Theory} +Throughout this article we'll consider first order differential equations with +function coefficients just as a special case of the Bernoulli's differential +equation with {@eq*}{n = 0}. + +Consider now the following ODE: +{@equation}{ +y' + P(x)y = Q(x)y^n +} + +let {@eq*}{y} be the product of two arbitrary functions {@eq*}{w} and {@eq*}{z} +such that + +{@equation}{ +y &= wz \\ +y' &= w'z + wz' +} + +we now restrict {@eq*}{z} to be the solution of the ODE + +{@equation}{ +z' + P(x)z = 0 +} + +with this it is possible to solve for {@eq*}{z} by integrating + +{@equation}{ +\frac{z'}{z} = - P(x) +} + +using {@eq}{z} we solve for {@eq}{w} by replacing {@eq}{y} inside the original +ODE + +{@align}{ +w'z + wz' + P(x)wz &= Q(x)w^nz^n \\ +w'z + w\left(z' + P(x)z\right) &= Q(x)w^nz^n \\ +w'z &= Q(x)w^nz^n \\ +\frac{w'}{w^n} &= Q(x)z^{n-1} +} + +the general solution to our original ODE can be simply obtained by multiplying +{@eq*}{w} and {@eq*}{z}. + +{@section}{Comments} +This method, while functional, may not always be the most practical. In some +cases the differential equations for $w$ and $z$ may not have closed algebraic +solutions. A more traditional substitution may in some situations also be easier +than this method. Like always it is up to one to know which tool to apply for a +given problem. |