Comments (2)
I'd prefer not to rename physica's eval
because
- Typst's
eval
is not that frequently used, and - I'd like to keep the name short and memorable, especially
eval
is the macro name in the LaTeXphysics
package
As a workaround, you may rename eval
while importing if you would also want to keep access to Typst's eval
at the same time.
#import "@preview/physica:0.9.2": .., eval as evalat
I understand users like doing wildcard imports (that is, import everything: #import "...": *
), so I proposed typst/typst#3068 to optionally hide symbols after discovering they'd like to use some symbols eclipsed by the import (instead of having to delete the *
and write out every symbol they have ever used in the doc -- very bad UX), like the Dart language. But that proposal was "not liked at all" and my reasons were deemed "completely unfounded", so it was closed.
Maybe give a bump to Typst's typst/typst#1639, which proposes another way to access the native Typst symbols that are otherwise eclipsed by imports :)
from typst-physics.
I understand. Is this naming conflict documented somewhere?
This is my use case of typst's eval
.
#import "@preview/cetz:0.2.0": canvas, plot, draw
#let E-hermitepsi = ((0, "1/(calc.sqrt(calc.sqrt(calc.pi)))*(1 * f)"), (1, "1/(calc.sqrt(calc.sqrt(4*calc.pi)))*(2 * y * f)"), (2, "1/(calc.sqrt(calc.sqrt(64*calc.pi)))*(4 * y * y - 2) * f"), (3, "1/(calc.sqrt(calc.sqrt(2304*calc.pi)))*(8 * y * y * y - 12 * y)*f"))
#figure(
grid(
columns: 2, // 2 means 2 auto-sized columns
gutter: 2mm, // space between columns
canvas(length: 1.2cm, {
import draw: *
plot.plot(
size: (5, 10),
x-tick-step: 2,
x-label: [$y$],
// x-ticks: ( (0, $0$), (1, $a$)),
y-label: [$V(x)$, #text([$E$], fill:blue), #text([$psi(y)$], fill:red)],
y-tick-step: none,
y-ticks: ((0.5, $v=0$), (1.5, $v=1$), (2.5, $v=2$), (3.5, $v=3$)),
x-min: -4,
x-max: 4,
y-min: 0,
// y-max: 12,
{
plot.add(style: (stroke: (paint:black)),
domain: (-3, 3), samples: 100, y => 0.5*y*y
)
for (v, hermitepsi) in E-hermitepsi {
let E = v + 1/2
let psi(y) = eval(hermitepsi, scope: (y:y, f: calc.exp(-y*y/2)))
plot.add(style: (stroke: (paint:blue)),
domain: (-4, 4), samples: 10, y => E
)
plot.add(style: (stroke: (paint:red)),
domain: (-4, 4), samples: 100, y => psi(y) + E
)
}
}
)
line(style: (stroke: (thickness: 5pt)), (2.5, 0), (2.5, 10))
}),
canvas(length: 1.2cm, {
import draw: *
plot.plot(
size: (5, 10),
x-tick-step: 2,
x-label: [$y$],
y-label: [$V(x)$, #text([$E$], fill:blue), #text([$psi^2(y)$], fill:red)],
y-tick-step: none,
y-ticks: ( (0.5, $v=0$), (1.5, $v=1$),(2.5, $v=2$),(3.5, $v=3$)),
x-min: -4,
x-max: 4,
y-min: 0,
// y-max: 12,
{
plot.add(style: (stroke: (paint:black)),
domain: (-3, 3), samples: 100, y => 0.5*y*y
)
for (v, hermitepsi) in E-hermitepsi {
let E = v + 1/2
let psi(y) = eval(hermitepsi, scope: (y:y, f: calc.exp(-y*y/2), E: E))
plot.add(style: (stroke: (paint:blue)),
domain: (-4, 4), samples: 10, y => E
)
plot.add(style: (stroke: (paint:red)),
domain: (-4, 4), samples: 100, y => psi(y) * psi(y) + E
)
}
}
)
line(style: (stroke: (thickness: 5pt)), (2.5, 0), (2.5, 10))
})
)
)
from typst-physics.
Related Issues (17)
- Improve braket HOT 1
- Hessian Matrix formula is wrong HOT 2
- Potential error when evaluating pdv HOT 2
- mel needs beautify HOT 3
- Euler symbol HOT 3
- Wrong upright style and spacing for vecrow() and Greek letters HOT 3
- `pdv` with single argument HOT 1
- Unexpected output of iprod() HOT 6
- Add option to make vectors upright (non-italicized) HOT 4
- Match `vecrow` parameters w/ `vec`
- Derivative delimiter matching
- Add option for derivative at a certain point HOT 5
- Match size of brakets HOT 4
- More attractive README needed HOT 1
- Add version / commit hash and link to repo in file? HOT 1
- CI for releases and manual generation? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typst-physics.