diff --git a/README.md b/README.md
index aba0f29..ab960dd 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
:green_book: The [manual](https://github.com/Leedehai/typst-physics/blob/master/physica-manual.pdf).
-
+
# The physica package for Typst
@@ -21,7 +21,7 @@ natural sciences, including:
* Dirac braket notations,
* Common math functions,
* Differentials and derivatives, including partial derivatives of mixed orders with automatic order summation,
-* Familiar "h-bar", tensor abstract index notations, isotopes,
+* Familiar "h-bar", tensor abstract index notations, isotopes, Taylor series term,
* Signal sequences i.e. digital timing diagrams.
:warning: [Typst](https://typst.app) is in beta and evolving, and this package
diff --git a/background3.png b/background3.png
new file mode 100644
index 0000000..3a4c755
Binary files /dev/null and b/background3.png differ
diff --git a/physica-manual.pdf b/physica-manual.pdf
index 90ae372..6493a4d 100644
Binary files a/physica-manual.pdf and b/physica-manual.pdf differ
diff --git a/physica-manual.typ b/physica-manual.typ
index 0be2ee7..74b26c4 100644
--- a/physica-manual.typ
+++ b/physica-manual.typ
@@ -27,8 +27,8 @@
#align(center)[
Leedehai \
- #linkurl("GitHub repo", "https://github.com/leedehai/typst-physics") |
- #linkurl("Typst index", "https://typst.app/docs/packages/")
+ #linkurl("GitHub", "https://github.com/leedehai/typst-physics") |
+ #linkurl("Typst", "https://typst.app/docs/packages/")
]
#set par(justify: true)
@@ -211,6 +211,14 @@ All symbols need to be used in *math mode* `$...$`.
[`cprod`],
[`a cprod b` #sym.arrow $a cprod b$],
[cross product],
+
+ [`innerproduct`],
+ [`iprod`],
+ [
+ `iprod(u, v)` #sym.arrow $iprod(u, v)$ \
+ `iprod(sum_i a_i, b)` \ #sym.arrow $iprod(sum_i a_i, b)$
+ ],
+ [inner product],
)
== Matrix notations
@@ -399,22 +407,6 @@ xmat(2, 2, #g)`)
],
[ketbra],
- [`innerproduct(`_a_, _b_`)`],
- [`iprod`],
- [
- `iprod(a), iprod(u, v)` \ #sym.arrow $iprod(a), iprod(u, v)$ \
- `iprod(a, vec(1,2))` #sym.arrow $iprod(a, vec(1,2))$
- ],
- [innerproduct\ = braket],
-
- [`outerproduct(`_a_, _b_`)`],
- [`oprod`],
- [
- `oprod(a), oprod(u, v)` \ #sym.arrow $oprod(a), oprod(u, v)$ \
- `oprod(a, vec(1,2))` #sym.arrow $oprod(a, vec(1,2))$
- ],
- [outerproduct\ = ketbra],
-
[`matrixelement(`_n_, _M_, _m_`)`],
[`mel`],
[
@@ -852,6 +844,51 @@ $ isotope("Bi",a:211,z:83) --> isotope("Tl",a:207,z:81) + isotope("He",a:4,z:2)
*(4)* #hl(`isotope("Tl",a:207,z:81) --> isotope("Pb",a:207,z:82) + isotope(e,a:0,z:-1)`)
$ isotope("Tl",a:207,z:81) --> isotope("Pb",a:207,z:82) + isotope(e,a:0,z:-1) $
+=== The n-th term in Taylor series
+
+#v(1em)
+
+Function: `taylorterm(`_func_, _x_, _x0_, _idx_`)`.
+- _func_: the function e.g. `f`, `(f+g)`,
+- _x_: the variable name e.g. `x`,
+- _x0_: the variable value at the expansion point e.g. `x_0`, `(1+a)`,
+- _idx_: the index of the term, e.g. `0`, `1`, `2`, `n`, `(n+1)`.
+If _x0_ or _idx_ is in a parenthesis e.g. `(1+k)`, then the function
+automatically removes the outer parenthesis where appropriate.
+
+#align(center, [*Examples*])
+
+#grid(
+ columns: (50%, 50%),
+ row-gutter: 1em,
+ column-gutter: 2em,
+ [
+ *(1)* #hl(`taylorterm(f,x,x_0,0)`) \
+ $ taylorterm(f,x,x_0,0) $
+ ],
+ [
+ *(2)* #hl(`taylorterm(f,x,x_0,1)`) \
+ $ taylorterm(f,x,x_0,1) $
+ ],
+ [
+ *(3)* #hl(`taylorterm(f,x,(1+a),2)`) \
+ $ taylorterm(f,x,(1+a),2) $
+ ],
+ [
+ *(4)* #hl(`taylorterm(f,x,x_0,n)`) \
+ $ taylorterm(f,x,x_0,n) $
+ ],
+ [
+ *(5)* #hl(`taylorterm(F,x^nu,x^nu_0,n)`) \
+ $ taylorterm(F,x^nu,x^nu_0,n) $
+ ],
+ [
+ *(6)* #hl(`taylorterm(f_p,x,x_0,(n+1))`) \
+ $ taylorterm(f_p,x,x_0,(n+1)) $
+ ],
+)
+
+
=== Signal sequences (digital timing diagrams)
In engineering, people often need to draw digital timing diagrams for signals, like $signals("1|0|1|0")$.
diff --git a/physica.html b/physica.html
new file mode 100644
index 0000000..5b861c1
--- /dev/null
+++ b/physica.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
![](./background3.png)
+
![](./physica_thin.png)
+
+
\ No newline at end of file
diff --git a/physica.typ b/physica.typ
index b4a8271..e895592 100644
--- a/physica.typ
+++ b/physica.typ
@@ -206,6 +206,11 @@
#let crossproduct = $times$
#let cprod = crossproduct
+#let innerproduct(u, v) = {
+ $lr(angle.l #u, #v angle.r)$
+}
+#let iprod = innerproduct
+
// == Matrices
#let matrixdet(..sink) = {
@@ -288,8 +293,8 @@
#let jmat = jacobianmatrix
#let hessianmatrix(fs, xs, delim:"(") = {
- assert(type(fs) == array, message: "expecting a one-element array")
- assert(fs.len() == 1, message: "expecting only one function name")
+ assert(type(fs) == array, message: "usage: hessianmatrix(f; x, y...)")
+ assert(fs.len() == 1, message: "usage: hessianmatrix(f; x, y...)")
let f = fs.at(0)
assert(type(xs) == array, message: "expecting an array of variable names")
let row_arrays = () // array of arrays
@@ -364,11 +369,6 @@
$ lr(bar.v ket#h(0pt)mid(angle.r#h(0pt)angle.l)#h(0pt)bra bar.v) $
})
-#let innerproduct = braket
-#let iprod = innerproduct
-#let outerproduct = ketbra
-#let oprod = outerproduct
-
#let matrixelement(n, M, m) = style(styles => {
$ lr(angle.l #n#h(0pt)mid(bar.v)#h(0pt)#M#h(0pt)mid(bar.v)#h(0pt)#m angle.r) $
})
@@ -663,6 +663,25 @@
math.attach((T,hphantom(sym.zwj)).join(), t: uppers.join(), b: lowers.join())
}
+#let taylorterm(fn, xv, x0, idx) = {
+ let noparen(expr) = {
+ if type(expr) == content and expr.func() == math.lr {
+ let children = expr.at("body").at("children")
+ children.slice(1, children.len() - 1).join()
+ } else {
+ expr
+ }
+ }
+
+ if idx == [0] or idx == 0 {
+ $fn (noparen(x0))$
+ } else if idx == [1] or idx == 1 {
+ $fn^((1)) (noparen(x0))(xv - x0)$
+ } else {
+ $frac(fn^((noparen(idx))) (noparen(x0)), idx !)(xv - x0)^noparen(idx)$
+ }
+}
+
#let isotope(element, /*atomic mass*/a: none, /*atomic number*/z: none) = {
$attach(upright(element), tl: #a, bl: #z)$
}
diff --git a/physica_thin.png b/physica_thin.png
new file mode 100644
index 0000000..f5f699f
Binary files /dev/null and b/physica_thin.png differ