@classytic/stage 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +5 -1
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/assets/index.mjs +0 -1
- package/dist/atomic/aufbau.d.mts +144 -0
- package/dist/atomic/aufbau.mjs +384 -0
- package/dist/atomic/elements.d.mts +67 -0
- package/dist/atomic/elements.mjs +785 -0
- package/dist/atomic/emission.d.mts +112 -0
- package/dist/atomic/emission.mjs +179 -0
- package/dist/atomic/index.d.mts +8 -0
- package/dist/atomic/index.mjs +9 -0
- package/dist/atomic/periodic.d.mts +82 -0
- package/dist/atomic/periodic.mjs +231 -0
- package/dist/atomic/properties.d.mts +100 -0
- package/dist/atomic/properties.mjs +574 -0
- package/dist/atomic/shells.d.mts +137 -0
- package/dist/atomic/shells.mjs +170 -0
- package/dist/atomic/trends.d.mts +148 -0
- package/dist/atomic/trends.mjs +225 -0
- package/dist/builder/Palette.mjs +50 -89
- package/dist/builder/SceneBuilder.mjs +15 -73
- package/dist/chem/chromatography.d.mts +66 -0
- package/dist/chem/chromatography.mjs +63 -0
- package/dist/chem/complex.d.mts +114 -0
- package/dist/chem/complex.mjs +234 -0
- package/dist/chem/cycle.d.mts +75 -0
- package/dist/chem/cycle.mjs +145 -0
- package/dist/chem/equation.d.mts +86 -0
- package/dist/chem/equation.mjs +168 -0
- package/dist/chem/formula.d.mts +90 -0
- package/dist/chem/formula.mjs +201 -0
- package/dist/chem/functional-groups.d.mts +31 -0
- package/dist/chem/functional-groups.mjs +187 -0
- package/dist/chem/hazard.d.mts +94 -0
- package/dist/chem/hazard.mjs +329 -0
- package/dist/chem/index.d.mts +34 -33
- package/dist/chem/index.mjs +34 -28
- package/dist/chem/ionic.d.mts +98 -0
- package/dist/chem/ionic.mjs +156 -0
- package/dist/chem/layout.d.mts +46 -0
- package/dist/chem/layout.mjs +342 -0
- package/dist/chem/lewis.d.mts +79 -0
- package/dist/chem/lewis.mjs +163 -0
- package/dist/chem/molecular-orbital.d.mts +114 -0
- package/dist/chem/molecular-orbital.mjs +201 -0
- package/dist/chem/molecule.d.mts +154 -0
- package/dist/chem/molecule.mjs +282 -0
- package/dist/chem/nmr.d.mts +153 -0
- package/dist/chem/nmr.mjs +165 -0
- package/dist/chem/polymer.d.mts +65 -0
- package/dist/chem/polymer.mjs +179 -0
- package/dist/chem/redox.d.mts +138 -0
- package/dist/chem/redox.mjs +328 -0
- package/dist/chem/relations.d.mts +183 -0
- package/dist/chem/relations.mjs +299 -0
- package/dist/chem/skeleton.d.mts +51 -0
- package/dist/chem/skeleton.mjs +186 -0
- package/dist/chem/solution.d.mts +116 -0
- package/dist/chem/solution.mjs +186 -0
- package/dist/chem/species.d.mts +47 -0
- package/dist/chem/species.mjs +128 -0
- package/dist/chem/stereo.d.mts +108 -0
- package/dist/chem/stereo.mjs +286 -0
- package/dist/chem/stoichiometry.d.mts +95 -0
- package/dist/chem/stoichiometry.mjs +145 -0
- package/dist/chem/synthesis.d.mts +113 -0
- package/dist/chem/synthesis.mjs +281 -0
- package/dist/chem/vsepr.d.mts +80 -0
- package/dist/chem/vsepr.mjs +247 -0
- package/dist/circuit/ac.d.mts +163 -0
- package/dist/circuit/ac.mjs +452 -0
- package/dist/circuit/dc.d.mts +92 -0
- package/dist/circuit/dc.mjs +333 -0
- package/dist/circuit/index.d.mts +5 -92
- package/dist/circuit/index.mjs +5 -332
- package/dist/circuit/network.d.mts +99 -0
- package/dist/circuit/network.mjs +440 -0
- package/dist/circuit/topology.d.mts +102 -0
- package/dist/circuit/topology.mjs +143 -0
- package/dist/colour/absorption.d.mts +79 -0
- package/dist/colour/absorption.mjs +137 -0
- package/dist/colour/index.d.mts +6 -0
- package/dist/colour/index.mjs +7 -0
- package/dist/colour/name.d.mts +14 -0
- package/dist/colour/name.mjs +76 -0
- package/dist/colour/observer.d.mts +31 -0
- package/dist/colour/observer.mjs +46 -0
- package/dist/colour/spectrum.d.mts +61 -0
- package/dist/colour/spectrum.mjs +108 -0
- package/dist/colour/srgb.d.mts +49 -0
- package/dist/colour/srgb.mjs +108 -0
- package/dist/core/constants.d.mts +138 -0
- package/dist/core/constants.mjs +139 -0
- package/dist/core/index.d.mts +4 -1
- package/dist/core/index.mjs +4 -1
- package/dist/core/math.d.mts +26 -0
- package/dist/core/math.mjs +37 -0
- package/dist/core/vec3.d.mts +94 -0
- package/dist/core/vec3.mjs +123 -0
- package/dist/core/worked.d.mts +35 -0
- package/dist/core/worked.mjs +44 -0
- package/dist/electro/cell.d.mts +102 -0
- package/dist/electro/cell.mjs +170 -0
- package/dist/electro/conductivity.d.mts +157 -0
- package/dist/electro/conductivity.mjs +156 -0
- package/dist/electro/couples.d.mts +114 -0
- package/dist/electro/couples.mjs +334 -0
- package/dist/electro/electrolysis.d.mts +96 -0
- package/dist/electro/electrolysis.mjs +274 -0
- package/dist/electro/faraday.d.mts +150 -0
- package/dist/electro/faraday.mjs +118 -0
- package/dist/electro/index.d.mts +6 -0
- package/dist/electro/index.mjs +7 -0
- package/dist/finance/accounting/adjustments.d.mts +17 -0
- package/dist/finance/accounting/adjustments.mjs +202 -0
- package/dist/finance/accounting/analysis.d.mts +8 -0
- package/dist/finance/accounting/analysis.mjs +205 -0
- package/dist/finance/accounting/clubs.d.mts +21 -0
- package/dist/finance/accounting/clubs.mjs +217 -0
- package/dist/finance/accounting/company-statements.d.mts +7 -0
- package/dist/finance/accounting/company-statements.mjs +150 -0
- package/dist/finance/accounting/harness.d.mts +7 -0
- package/dist/finance/accounting/harness.mjs +45 -0
- package/dist/finance/accounting/index.d.mts +18 -0
- package/dist/finance/accounting/index.mjs +18 -0
- package/dist/finance/accounting/journalize.d.mts +16 -0
- package/dist/finance/accounting/journalize.mjs +128 -0
- package/dist/finance/accounting/manufacturing.d.mts +8 -0
- package/dist/finance/accounting/manufacturing.mjs +236 -0
- package/dist/finance/accounting/partnership.d.mts +7 -0
- package/dist/finance/accounting/partnership.mjs +152 -0
- package/dist/finance/accounting/period-case.d.mts +6 -0
- package/dist/finance/accounting/period-case.mjs +71 -0
- package/dist/finance/accounting/post.d.mts +9 -0
- package/dist/finance/accounting/post.mjs +84 -0
- package/dist/finance/accounting/precision.d.mts +9 -0
- package/dist/finance/accounting/precision.mjs +15 -0
- package/dist/finance/accounting/rules.d.mts +21 -0
- package/dist/finance/accounting/rules.mjs +37 -0
- package/dist/finance/accounting/solve.d.mts +28 -0
- package/dist/finance/accounting/solve.mjs +92 -0
- package/dist/finance/accounting/statements.d.mts +7 -0
- package/dist/finance/accounting/statements.mjs +142 -0
- package/dist/finance/accounting/types.d.mts +649 -0
- package/dist/finance/accounting/validate.d.mts +7 -0
- package/dist/finance/accounting/validate.mjs +67 -0
- package/dist/finance/accounting/verification.d.mts +24 -0
- package/dist/finance/accounting/verification.mjs +386 -0
- package/dist/finance/bizsim.d.mts +75 -0
- package/dist/finance/bizsim.mjs +296 -0
- package/dist/finance/index.d.mts +95 -0
- package/dist/finance/index.mjs +145 -0
- package/dist/finance/investment-math.d.mts +7 -0
- package/dist/finance/investment-math.mjs +18 -0
- package/dist/finance/management-accounting/budgeting.d.mts +7 -0
- package/dist/finance/management-accounting/budgeting.mjs +189 -0
- package/dist/finance/management-accounting/cash-budget.d.mts +7 -0
- package/dist/finance/management-accounting/cash-budget.mjs +154 -0
- package/dist/finance/management-accounting/costing.d.mts +8 -0
- package/dist/finance/management-accounting/costing.mjs +175 -0
- package/dist/finance/management-accounting/decisions.d.mts +8 -0
- package/dist/finance/management-accounting/decisions.mjs +164 -0
- package/dist/finance/management-accounting/index.d.mts +13 -0
- package/dist/finance/management-accounting/index.mjs +13 -0
- package/dist/finance/management-accounting/integrated-budget.d.mts +8 -0
- package/dist/finance/management-accounting/integrated-budget.mjs +67 -0
- package/dist/finance/management-accounting/inventory-costing.d.mts +7 -0
- package/dist/finance/management-accounting/inventory-costing.mjs +173 -0
- package/dist/finance/management-accounting/investment-appraisal.d.mts +7 -0
- package/dist/finance/management-accounting/investment-appraisal.mjs +148 -0
- package/dist/finance/management-accounting/management-case.d.mts +8 -0
- package/dist/finance/management-accounting/management-case.mjs +91 -0
- package/dist/finance/management-accounting/master-budget.d.mts +7 -0
- package/dist/finance/management-accounting/master-budget.mjs +137 -0
- package/dist/finance/management-accounting/production-costing.d.mts +8 -0
- package/dist/finance/management-accounting/production-costing.mjs +214 -0
- package/dist/finance/management-accounting/types.d.mts +644 -0
- package/dist/finance/management-accounting/variances.d.mts +7 -0
- package/dist/finance/management-accounting/variances.mjs +150 -0
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +5 -5
- package/dist/interaction/MovableDot.mjs +19 -0
- package/dist/interaction/useDraggable.mjs +24 -4
- package/dist/math/analysis.d.mts +61 -0
- package/dist/math/analysis.mjs +187 -0
- package/dist/math/answer-check.d.mts +50 -0
- package/dist/math/answer-check.mjs +106 -0
- package/dist/math/calculus.d.mts +17 -1
- package/dist/math/calculus.mjs +365 -2
- package/dist/math/complex.d.mts +93 -0
- package/dist/math/complex.mjs +239 -0
- package/dist/math/expr.d.mts +23 -0
- package/dist/math/expr.mjs +36 -0
- package/dist/math/index.d.mts +9 -23
- package/dist/math/index.mjs +9 -38
- package/dist/math/latex.mjs +10 -1
- package/dist/math/parse.mjs +1 -1
- package/dist/math/poly.d.mts +55 -0
- package/dist/math/poly.mjs +273 -0
- package/dist/math/rearrange.d.mts +14 -0
- package/dist/math/rearrange.mjs +125 -0
- package/dist/math/solve.d.mts +21 -0
- package/dist/math/solve.mjs +75 -0
- package/dist/networking/addressing.d.mts +26 -0
- package/dist/networking/addressing.mjs +33 -0
- package/dist/networking/cloud/access.d.mts +36 -0
- package/dist/networking/cloud/access.mjs +95 -0
- package/dist/networking/cloud/containers.d.mts +43 -0
- package/dist/networking/cloud/containers.mjs +54 -0
- package/dist/networking/cloud/edge.d.mts +17 -0
- package/dist/networking/cloud/edge.mjs +31 -0
- package/dist/networking/cloud/failure-domains.d.mts +19 -0
- package/dist/networking/cloud/failure-domains.mjs +22 -0
- package/dist/networking/cloud/geo-routing.d.mts +22 -0
- package/dist/networking/cloud/geo-routing.mjs +64 -0
- package/dist/networking/cloud/index.d.mts +18 -0
- package/dist/networking/cloud/index.mjs +19 -0
- package/dist/networking/cloud/inference-reliability.d.mts +30 -0
- package/dist/networking/cloud/inference-reliability.mjs +76 -0
- package/dist/networking/cloud/inference.d.mts +118 -0
- package/dist/networking/cloud/inference.mjs +179 -0
- package/dist/networking/cloud/infrastructure.d.mts +45 -0
- package/dist/networking/cloud/infrastructure.mjs +96 -0
- package/dist/networking/cloud/observability.d.mts +24 -0
- package/dist/networking/cloud/observability.mjs +34 -0
- package/dist/networking/cloud/orchestration.d.mts +32 -0
- package/dist/networking/cloud/orchestration.mjs +38 -0
- package/dist/networking/cloud/recovery.d.mts +21 -0
- package/dist/networking/cloud/recovery.mjs +27 -0
- package/dist/networking/cloud/releases.d.mts +42 -0
- package/dist/networking/cloud/releases.mjs +135 -0
- package/dist/networking/cloud/scaling.d.mts +25 -0
- package/dist/networking/cloud/scaling.mjs +65 -0
- package/dist/networking/cloud/secrets.d.mts +39 -0
- package/dist/networking/cloud/secrets.mjs +68 -0
- package/dist/networking/cloud/server-deployment.d.mts +29 -0
- package/dist/networking/cloud/server-deployment.mjs +72 -0
- package/dist/networking/cloud/storage.d.mts +16 -0
- package/dist/networking/cloud/storage.mjs +58 -0
- package/dist/networking/cloud/vpc.d.mts +18 -0
- package/dist/networking/cloud/vpc.mjs +100 -0
- package/dist/networking/delivery.d.mts +34 -0
- package/dist/networking/delivery.mjs +52 -0
- package/dist/networking/index.d.mts +47 -0
- package/dist/networking/index.mjs +47 -0
- package/dist/networking/ipv6.d.mts +28 -0
- package/dist/networking/ipv6.mjs +17 -0
- package/dist/networking/journeys.d.mts +83 -0
- package/dist/networking/journeys.mjs +161 -0
- package/dist/networking/models/airtime.d.mts +87 -0
- package/dist/networking/models/airtime.mjs +130 -0
- package/dist/networking/models/cellular.d.mts +157 -0
- package/dist/networking/models/cellular.mjs +252 -0
- package/dist/networking/models/encapsulation.d.mts +98 -0
- package/dist/networking/models/encapsulation.mjs +132 -0
- package/dist/networking/models/handover.d.mts +116 -0
- package/dist/networking/models/handover.mjs +209 -0
- package/dist/networking/models/handshake.d.mts +90 -0
- package/dist/networking/models/handshake.mjs +122 -0
- package/dist/networking/models/index.d.mts +14 -0
- package/dist/networking/models/index.mjs +15 -0
- package/dist/networking/models/media.d.mts +82 -0
- package/dist/networking/models/media.mjs +188 -0
- package/dist/networking/models/satellite.d.mts +86 -0
- package/dist/networking/models/satellite.mjs +121 -0
- package/dist/networking/models/spectrum.d.mts +83 -0
- package/dist/networking/models/spectrum.mjs +235 -0
- package/dist/networking/models/switch.d.mts +80 -0
- package/dist/networking/models/switch.mjs +155 -0
- package/dist/networking/models/vlan.d.mts +62 -0
- package/dist/networking/models/vlan.mjs +100 -0
- package/dist/networking/models/vpn.d.mts +66 -0
- package/dist/networking/models/vpn.mjs +125 -0
- package/dist/networking/models/wifi-privacy.d.mts +82 -0
- package/dist/networking/models/wifi-privacy.mjs +130 -0
- package/dist/networking/models/wifi.d.mts +240 -0
- package/dist/networking/models/wifi.mjs +562 -0
- package/dist/networking/nat-traversal.d.mts +24 -0
- package/dist/networking/nat-traversal.mjs +38 -0
- package/dist/networking/protocols.d.mts +17 -0
- package/dist/networking/protocols.mjs +57 -0
- package/dist/networking/queue.d.mts +12 -0
- package/dist/networking/queue.mjs +18 -0
- package/dist/networking/route-learning.d.mts +23 -0
- package/dist/networking/route-learning.mjs +43 -0
- package/dist/networking/routing.d.mts +11 -0
- package/dist/networking/routing.mjs +25 -0
- package/dist/networking/signals.d.mts +26 -0
- package/dist/networking/signals.mjs +35 -0
- package/dist/networking/subnet.d.mts +49 -0
- package/dist/networking/subnet.mjs +89 -0
- package/dist/networking/tcp-reliability.d.mts +24 -0
- package/dist/networking/tcp-reliability.mjs +38 -0
- package/dist/networking/topology/contract.d.mts +123 -0
- package/dist/networking/topology/index.d.mts +4 -0
- package/dist/networking/topology/index.mjs +4 -0
- package/dist/networking/topology/presets.d.mts +7 -0
- package/dist/networking/topology/presets.mjs +302 -0
- package/dist/networking/topology/simulation.d.mts +8 -0
- package/dist/networking/topology/simulation.mjs +179 -0
- package/dist/networking/wireless.d.mts +11 -0
- package/dist/networking/wireless.mjs +17 -0
- package/dist/optics/imaging.d.mts +218 -0
- package/dist/optics/imaging.mjs +276 -0
- package/dist/optics/index.d.mts +7 -0
- package/dist/optics/index.mjs +8 -0
- package/dist/optics/laws.d.mts +70 -0
- package/dist/optics/laws.mjs +195 -0
- package/dist/optics/prism.d.mts +148 -0
- package/dist/optics/prism.mjs +197 -0
- package/dist/optics/refraction.d.mts +201 -0
- package/dist/optics/refraction.mjs +270 -0
- package/dist/optics/wave-optics.d.mts +171 -0
- package/dist/optics/wave-optics.mjs +259 -0
- package/dist/physics/ac/index.d.mts +183 -0
- package/dist/physics/ac/index.mjs +203 -0
- package/dist/physics/dynamics/forces.d.mts +98 -0
- package/dist/physics/dynamics/forces.mjs +153 -0
- package/dist/physics/dynamics/friction.d.mts +76 -0
- package/dist/physics/dynamics/friction.mjs +119 -0
- package/dist/physics/dynamics/system.d.mts +68 -0
- package/dist/physics/dynamics/system.mjs +125 -0
- package/dist/physics/electrostatics/index.d.mts +169 -0
- package/dist/physics/electrostatics/index.mjs +249 -0
- package/dist/physics/energy/centre-of-mass.d.mts +115 -0
- package/dist/physics/energy/centre-of-mass.mjs +180 -0
- package/dist/physics/energy/conservation.d.mts +81 -0
- package/dist/physics/energy/conservation.mjs +129 -0
- package/dist/physics/energy/power.d.mts +90 -0
- package/dist/physics/energy/power.mjs +167 -0
- package/dist/physics/energy/spring.d.mts +73 -0
- package/dist/physics/energy/spring.mjs +129 -0
- package/dist/physics/energy/store.d.mts +63 -0
- package/dist/physics/energy/store.mjs +108 -0
- package/dist/physics/energy/theorem.d.mts +65 -0
- package/dist/physics/energy/theorem.mjs +113 -0
- package/dist/physics/energy/work.d.mts +114 -0
- package/dist/physics/energy/work.mjs +219 -0
- package/dist/physics/gravitation/body.d.mts +85 -0
- package/dist/physics/gravitation/body.mjs +168 -0
- package/dist/physics/gravitation/kepler.d.mts +127 -0
- package/dist/physics/gravitation/kepler.mjs +216 -0
- package/dist/physics/gravitation/law.d.mts +117 -0
- package/dist/physics/gravitation/law.mjs +175 -0
- package/dist/physics/gravitation/orbit.d.mts +119 -0
- package/dist/physics/gravitation/orbit.mjs +202 -0
- package/dist/physics/gravitation/potential.d.mts +114 -0
- package/dist/physics/gravitation/potential.mjs +202 -0
- package/dist/physics/gravitation/variation.d.mts +97 -0
- package/dist/physics/gravitation/variation.mjs +175 -0
- package/dist/physics/index.d.mts +35 -0
- package/dist/physics/index.mjs +36 -0
- package/dist/physics/integral-sweep.d.mts +63 -0
- package/dist/physics/integral-sweep.mjs +126 -0
- package/dist/physics/kinematics/equations.d.mts +47 -0
- package/dist/physics/kinematics/equations.mjs +126 -0
- package/dist/physics/kinematics/free-fall.d.mts +53 -0
- package/dist/physics/kinematics/free-fall.mjs +71 -0
- package/dist/physics/kinematics/given.d.mts +16 -0
- package/dist/physics/kinematics/given.mjs +55 -0
- package/dist/physics/kinematics/roots.d.mts +41 -0
- package/dist/physics/kinematics/roots.mjs +72 -0
- package/dist/physics/kinematics/solve.d.mts +52 -0
- package/dist/physics/kinematics/solve.mjs +172 -0
- package/dist/physics/magnetism/biot-savart.d.mts +161 -0
- package/dist/physics/magnetism/biot-savart.mjs +353 -0
- package/dist/physics/magnetism/flux.d.mts +94 -0
- package/dist/physics/magnetism/flux.mjs +313 -0
- package/dist/physics/magnetism/geomagnetism.d.mts +151 -0
- package/dist/physics/magnetism/geomagnetism.mjs +184 -0
- package/dist/physics/magnetism/index.d.mts +12 -0
- package/dist/physics/magnetism/index.mjs +74 -0
- package/dist/physics/magnetism/lorentz.d.mts +28 -0
- package/dist/physics/magnetism/lorentz.mjs +88 -0
- package/dist/physics/magnetism/magnetic-force.d.mts +102 -0
- package/dist/physics/magnetism/magnetic-force.mjs +169 -0
- package/dist/physics/momentum/collide.d.mts +77 -0
- package/dist/physics/momentum/collide.mjs +115 -0
- package/dist/physics/momentum/impulse.d.mts +89 -0
- package/dist/physics/momentum/impulse.mjs +159 -0
- package/dist/physics/momentum/planar.d.mts +60 -0
- package/dist/physics/momentum/planar.mjs +110 -0
- package/dist/physics/projectile.d.mts +107 -0
- package/dist/physics/projectile.mjs +185 -0
- package/dist/physics/rotation/angular.d.mts +85 -0
- package/dist/physics/rotation/angular.mjs +130 -0
- package/dist/physics/rotation/circular.d.mts +79 -0
- package/dist/physics/rotation/circular.mjs +131 -0
- package/dist/physics/rotation/inertia.d.mts +164 -0
- package/dist/physics/rotation/inertia.mjs +332 -0
- package/dist/physics/rotation/torque.d.mts +65 -0
- package/dist/physics/rotation/torque.mjs +134 -0
- package/dist/physics/vectors.d.mts +64 -0
- package/dist/physics/vectors.mjs +114 -0
- package/dist/primitives/Dot.d.mts +2 -15
- package/dist/primitives/Dot.mjs +6 -4
- package/dist/primitives/Grid.d.mts +33 -17
- package/dist/primitives/Grid.mjs +89 -17
- package/dist/primitives/Label.d.mts +1 -14
- package/dist/primitives/Label.mjs +3 -2
- package/dist/primitives/Lines.d.mts +4 -32
- package/dist/primitives/Lines.mjs +10 -8
- package/dist/primitives/Shapes.d.mts +5 -43
- package/dist/primitives/Shapes.mjs +12 -10
- package/dist/primitives/index.d.mts +2 -2
- package/dist/primitives/index.mjs +2 -2
- package/dist/primitives/props.mjs +31 -0
- package/dist/quantity/index.d.mts +119 -0
- package/dist/quantity/index.mjs +417 -0
- package/dist/relation/derive.d.mts +74 -0
- package/dist/relation/derive.mjs +73 -0
- package/dist/relation/index.d.mts +56 -0
- package/dist/relation/index.mjs +234 -0
- package/dist/scene/Scene.d.mts +6 -1
- package/dist/scene/Scene.mjs +15 -40
- package/dist/scene/evaluators.mjs +1 -1
- package/dist/sim/thermal.mjs +45 -20
- package/dist/thermo/calorimetry.d.mts +207 -0
- package/dist/thermo/calorimetry.mjs +345 -0
- package/dist/thermo/cycles.d.mts +142 -0
- package/dist/thermo/cycles.mjs +256 -0
- package/dist/thermo/entropy.d.mts +87 -0
- package/dist/thermo/entropy.mjs +140 -0
- package/dist/thermo/expansion.d.mts +130 -0
- package/dist/thermo/expansion.mjs +178 -0
- package/dist/thermo/gas.d.mts +197 -0
- package/dist/thermo/gas.mjs +279 -0
- package/dist/thermo/heat-transfer.d.mts +164 -0
- package/dist/thermo/heat-transfer.mjs +217 -0
- package/dist/thermo/index.d.mts +9 -82
- package/dist/thermo/index.mjs +9 -132
- package/dist/thermo/processes.d.mts +95 -0
- package/dist/thermo/processes.mjs +154 -0
- package/dist/thermo/temperature.d.mts +174 -0
- package/dist/thermo/temperature.mjs +236 -0
- package/dist/view/Stage.mjs +4 -11
- package/dist/waves/damping.d.mts +224 -0
- package/dist/waves/damping.mjs +317 -0
- package/dist/waves/doppler.d.mts +72 -0
- package/dist/waves/doppler.mjs +125 -0
- package/dist/waves/index.d.mts +10 -0
- package/dist/waves/index.mjs +10 -0
- package/dist/waves/pendulum.d.mts +130 -0
- package/dist/waves/pendulum.mjs +211 -0
- package/dist/waves/pitch.d.mts +125 -0
- package/dist/waves/pitch.mjs +158 -0
- package/dist/waves/shm.d.mts +170 -0
- package/dist/waves/shm.mjs +279 -0
- package/dist/waves/springs.d.mts +103 -0
- package/dist/waves/springs.mjs +176 -0
- package/dist/waves/superposition.d.mts +124 -0
- package/dist/waves/superposition.mjs +196 -0
- package/dist/waves/wave.d.mts +154 -0
- package/dist/waves/wave.mjs +178 -0
- package/package.json +103 -23
- package/styles.css +125 -8
- package/dist/assets/kit/index.mjs +0 -4
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/math/complex.ts
|
|
4
|
+
var complex_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
DEG2RAD: () => DEG2RAD,
|
|
6
|
+
I: () => I,
|
|
7
|
+
MAX_POW: () => MAX_POW,
|
|
8
|
+
MAX_ROOTS: () => 360,
|
|
9
|
+
ONE: () => ONE,
|
|
10
|
+
RAD2DEG: () => RAD2DEG,
|
|
11
|
+
TWO_PI: () => TWO_PI,
|
|
12
|
+
ZERO: () => ZERO,
|
|
13
|
+
abs: () => abs,
|
|
14
|
+
add: () => add,
|
|
15
|
+
arg: () => arg,
|
|
16
|
+
argDeg: () => argDeg,
|
|
17
|
+
conj: () => conj,
|
|
18
|
+
cx: () => cx,
|
|
19
|
+
div: () => div,
|
|
20
|
+
eq: () => eq,
|
|
21
|
+
fromPolar: () => fromPolar,
|
|
22
|
+
iPow: () => iPow,
|
|
23
|
+
isFiniteC: () => isFiniteC,
|
|
24
|
+
mul: () => mul,
|
|
25
|
+
neg: () => neg,
|
|
26
|
+
nthRoots: () => nthRoots,
|
|
27
|
+
omega: () => omega,
|
|
28
|
+
powInt: () => powInt,
|
|
29
|
+
rootsOfUnity: () => rootsOfUnity,
|
|
30
|
+
scale: () => scale,
|
|
31
|
+
sub: () => sub,
|
|
32
|
+
toPolar: () => toPolar,
|
|
33
|
+
toStr: () => toStr,
|
|
34
|
+
toTex: () => toTex
|
|
35
|
+
});
|
|
36
|
+
const TWO_PI = Math.PI * 2;
|
|
37
|
+
const RAD2DEG = 180 / Math.PI;
|
|
38
|
+
const DEG2RAD = Math.PI / 180;
|
|
39
|
+
/** Hard caps so an authored value can never blow memory or hang a loop. */
|
|
40
|
+
const MAX_POW = 1024;
|
|
41
|
+
const MAX_ROOTS = 360;
|
|
42
|
+
const cx = (re, im = 0) => ({
|
|
43
|
+
re,
|
|
44
|
+
im
|
|
45
|
+
});
|
|
46
|
+
const ZERO = {
|
|
47
|
+
re: 0,
|
|
48
|
+
im: 0
|
|
49
|
+
};
|
|
50
|
+
const ONE = {
|
|
51
|
+
re: 1,
|
|
52
|
+
im: 0
|
|
53
|
+
};
|
|
54
|
+
const I = {
|
|
55
|
+
re: 0,
|
|
56
|
+
im: 1
|
|
57
|
+
};
|
|
58
|
+
const isFiniteC = (z) => Number.isFinite(z.re) && Number.isFinite(z.im);
|
|
59
|
+
const add = (a, b) => ({
|
|
60
|
+
re: a.re + b.re,
|
|
61
|
+
im: a.im + b.im
|
|
62
|
+
});
|
|
63
|
+
const sub = (a, b) => ({
|
|
64
|
+
re: a.re - b.re,
|
|
65
|
+
im: a.im - b.im
|
|
66
|
+
});
|
|
67
|
+
const neg = (a) => ({
|
|
68
|
+
re: -a.re,
|
|
69
|
+
im: -a.im
|
|
70
|
+
});
|
|
71
|
+
const conj = (a) => ({
|
|
72
|
+
re: a.re,
|
|
73
|
+
im: -a.im
|
|
74
|
+
});
|
|
75
|
+
const scale = (a, k) => ({
|
|
76
|
+
re: a.re * k,
|
|
77
|
+
im: a.im * k
|
|
78
|
+
});
|
|
79
|
+
/** (a+bi)(c+di) = (ac − bd) + (ad + bc)i. */
|
|
80
|
+
const mul = (a, b) => ({
|
|
81
|
+
re: a.re * b.re - a.im * b.im,
|
|
82
|
+
im: a.re * b.im + a.im * b.re
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Complex division via Smith's algorithm: divide through by the LARGER of the
|
|
86
|
+
* denominator's components so the intermediate ratio stays in [−1, 1] (no
|
|
87
|
+
* overflow when |b| is huge, no underflow when tiny). Returns an ∞/NaN complex
|
|
88
|
+
* for a (near-)zero denominator rather than throwing.
|
|
89
|
+
*/
|
|
90
|
+
function div(a, b) {
|
|
91
|
+
const { re: c, im: d } = b;
|
|
92
|
+
if (c === 0 && d === 0) return {
|
|
93
|
+
re: a.re / 0,
|
|
94
|
+
im: a.im / 0
|
|
95
|
+
};
|
|
96
|
+
if (Math.abs(c) >= Math.abs(d)) {
|
|
97
|
+
const r = d / c, den = c + d * r;
|
|
98
|
+
return {
|
|
99
|
+
re: (a.re + a.im * r) / den,
|
|
100
|
+
im: (a.im - a.re * r) / den
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const r = c / d, den = c * r + d;
|
|
104
|
+
return {
|
|
105
|
+
re: (a.re * r + a.im) / den,
|
|
106
|
+
im: (a.im * r - a.re) / den
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** Modulus |z| = √(re² + im²), via hypot so large components don't overflow. */
|
|
110
|
+
const abs = (z) => Math.hypot(z.re, z.im);
|
|
111
|
+
/** Argument arg(z) in RADIANS, in (−π, π]. arg(0) = 0 by convention. */
|
|
112
|
+
const arg = (z) => z.re === 0 && z.im === 0 ? 0 : Math.atan2(z.im, z.re);
|
|
113
|
+
/** Argument in DEGREES, in (−180, 180]. */
|
|
114
|
+
const argDeg = (z) => arg(z) * RAD2DEG;
|
|
115
|
+
/** Polar → rectangular: r·e^{iθ} = r(cosθ + i sinθ), θ in radians. */
|
|
116
|
+
const fromPolar = (r, theta) => ({
|
|
117
|
+
re: r * Math.cos(theta),
|
|
118
|
+
im: r * Math.sin(theta)
|
|
119
|
+
});
|
|
120
|
+
/** Rectangular → polar { r, theta(rad) }. */
|
|
121
|
+
const toPolar = (z) => ({
|
|
122
|
+
r: abs(z),
|
|
123
|
+
theta: arg(z)
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* iⁿ for any integer n, EXACTLY (no De Moivre float drift): the 4-cycle
|
|
127
|
+
* 1, i, −1, −i. Negative n handled by the (n mod 4 + 4) mod 4 normalisation.
|
|
128
|
+
*/
|
|
129
|
+
function iPow(n) {
|
|
130
|
+
if (!Number.isInteger(n)) return {
|
|
131
|
+
re: NaN,
|
|
132
|
+
im: NaN
|
|
133
|
+
};
|
|
134
|
+
switch ((n % 4 + 4) % 4) {
|
|
135
|
+
case 0: return {
|
|
136
|
+
re: 1,
|
|
137
|
+
im: 0
|
|
138
|
+
};
|
|
139
|
+
case 1: return {
|
|
140
|
+
re: 0,
|
|
141
|
+
im: 1
|
|
142
|
+
};
|
|
143
|
+
case 2: return {
|
|
144
|
+
re: -1,
|
|
145
|
+
im: 0
|
|
146
|
+
};
|
|
147
|
+
default: return {
|
|
148
|
+
re: 0,
|
|
149
|
+
im: -1
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* zⁿ for an INTEGER n via exponentiation-by-squaring (negative n inverts).
|
|
155
|
+
* |n| is capped at MAX_POW; an overflowing magnitude returns an explicit ∞
|
|
156
|
+
* complex (finite check) instead of looping into garbage.
|
|
157
|
+
*/
|
|
158
|
+
function powInt(z, n) {
|
|
159
|
+
if (!Number.isInteger(n)) return {
|
|
160
|
+
re: NaN,
|
|
161
|
+
im: NaN
|
|
162
|
+
};
|
|
163
|
+
if (Math.abs(n) > 1024) return {
|
|
164
|
+
re: Infinity,
|
|
165
|
+
im: Infinity
|
|
166
|
+
};
|
|
167
|
+
if (n === 0) return { ...ONE };
|
|
168
|
+
let base = n < 0 ? div(ONE, z) : z;
|
|
169
|
+
let e = Math.abs(n);
|
|
170
|
+
let acc = { ...ONE };
|
|
171
|
+
while (e > 0) {
|
|
172
|
+
if (e & 1) acc = mul(acc, base);
|
|
173
|
+
e >>= 1;
|
|
174
|
+
if (e > 0) base = mul(base, base);
|
|
175
|
+
if (!isFiniteC(acc)) return {
|
|
176
|
+
re: Infinity,
|
|
177
|
+
im: Infinity
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return acc;
|
|
181
|
+
}
|
|
182
|
+
/** Clamp an nth-root count to a safe, sane range [1, MAX_ROOTS]. */
|
|
183
|
+
const safeN = (n) => Number.isInteger(n) && n >= 1 ? Math.min(n, 360) : 1;
|
|
184
|
+
/**
|
|
185
|
+
* The n nth-roots of UNITY: e^{2πik/n}, k = 0…n−1 (so ω = roots[1] is the
|
|
186
|
+
* primitive root). For n = 2 → {1, −1}; n = 3 → {1, ω, ω²}; n = 4 → {1, i, −1, −i}.
|
|
187
|
+
* n is clamped to [1, MAX_ROOTS]. The k = n/2 (real −1) and k = 0 (real 1) entries
|
|
188
|
+
* are snapped to exact values so labels read cleanly.
|
|
189
|
+
*/
|
|
190
|
+
function rootsOfUnity(n) {
|
|
191
|
+
const m = safeN(n);
|
|
192
|
+
return Array.from({ length: m }, (_, k) => {
|
|
193
|
+
if (k === 0) return {
|
|
194
|
+
re: 1,
|
|
195
|
+
im: 0
|
|
196
|
+
};
|
|
197
|
+
if (m % 2 === 0 && k === m / 2) return {
|
|
198
|
+
re: -1,
|
|
199
|
+
im: 0
|
|
200
|
+
};
|
|
201
|
+
return fromPolar(1, TWO_PI * k / m);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/** The n nth-roots of any z: |z|^{1/n} · e^{i(arg z + 2πk)/n}, k = 0…n−1. */
|
|
205
|
+
function nthRoots(z, n) {
|
|
206
|
+
const m = safeN(n);
|
|
207
|
+
const { r, theta } = toPolar(z);
|
|
208
|
+
const root = Math.pow(r, 1 / m);
|
|
209
|
+
return Array.from({ length: m }, (_, k) => fromPolar(root, (theta + TWO_PI * k) / m));
|
|
210
|
+
}
|
|
211
|
+
/** The primitive nth root of unity ω (default the CUBE root, n = 3): e^{2πi/n}.
|
|
212
|
+
* For n = 3: ω = −½ + (√3/2)i, with ω³ = 1 and 1 + ω + ω² = 0. */
|
|
213
|
+
const omega = (n = 3) => fromPolar(1, TWO_PI / safeN(n));
|
|
214
|
+
/** Equal within a tolerance (default 1e-9), on both components. */
|
|
215
|
+
const eq = (a, b, eps = 1e-9) => Math.abs(a.re - b.re) <= eps && Math.abs(a.im - b.im) <= eps;
|
|
216
|
+
const numStr = (n, dp) => {
|
|
217
|
+
if (!Number.isFinite(n)) return n > 0 ? "∞" : "−∞";
|
|
218
|
+
const r = Math.round(n * 10 ** dp) / 10 ** dp;
|
|
219
|
+
return Object.is(r, -0) ? "0" : String(r).replace(/^-/, "−");
|
|
220
|
+
};
|
|
221
|
+
/** Plain string, e.g. "3 − 2i", "i", "−1", "0", "2i". */
|
|
222
|
+
function toStr(z, dp = 2) {
|
|
223
|
+
if (!isFiniteC(z)) return "∞";
|
|
224
|
+
const re = Math.round(z.re * 10 ** dp) / 10 ** dp;
|
|
225
|
+
const im = Math.round(z.im * 10 ** dp) / 10 ** dp;
|
|
226
|
+
if (im === 0) return numStr(re, dp);
|
|
227
|
+
const imPart = im === 1 ? "i" : im === -1 ? "−i" : `${numStr(Math.abs(im), dp)}i`;
|
|
228
|
+
if (re === 0) return im < 0 && im !== -1 ? `−${imPart}` : im === -1 ? "−i" : imPart;
|
|
229
|
+
const sign = im < 0 ? "−" : "+";
|
|
230
|
+
const mag = Math.abs(im) === 1 ? "i" : `${numStr(Math.abs(im), dp)}i`;
|
|
231
|
+
return `${numStr(re, dp)} ${sign} ${mag}`;
|
|
232
|
+
}
|
|
233
|
+
/** LaTeX form for <Tex> (uses real minus signs, "i"). */
|
|
234
|
+
function toTex(z, dp = 2) {
|
|
235
|
+
return toStr(z, dp).replace(/−/g, "-");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
//#endregion
|
|
239
|
+
export { ONE, ZERO, abs, add, complex_exports, cx, div, fromPolar, isFiniteC, mul, sub, toStr };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Node } from "./ast.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/math/expr.d.ts
|
|
4
|
+
interface CompiledExpr {
|
|
5
|
+
/** Evaluate against a scope of variable values (unknown vars → NaN). */
|
|
6
|
+
readonly fn: (scope: Record<string, number>) => number;
|
|
7
|
+
/** Free variables referenced (excludes constants & functions), e.g. `['x','a']`. */
|
|
8
|
+
readonly vars: string[];
|
|
9
|
+
/** The parsed syntax tree, for differentiation, LaTeX, or analysis. */
|
|
10
|
+
readonly ast: Node;
|
|
11
|
+
readonly error?: undefined;
|
|
12
|
+
}
|
|
13
|
+
interface ExprError {
|
|
14
|
+
readonly error: string;
|
|
15
|
+
readonly fn?: undefined;
|
|
16
|
+
readonly vars?: undefined;
|
|
17
|
+
readonly ast?: undefined;
|
|
18
|
+
}
|
|
19
|
+
type ExprResult = CompiledExpr | ExprError;
|
|
20
|
+
/** Compile a formula string. Returns `{ fn, vars, ast }` or `{ error }`, never throws. */
|
|
21
|
+
declare function compileExpr(src: string): ExprResult;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CompiledExpr, ExprError, ExprResult, compileExpr };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { evaluate, freeVars } from "./ast.mjs";
|
|
2
|
+
import { parse } from "./parse.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/math/expr.ts
|
|
5
|
+
/**
|
|
6
|
+
* compileExpr, the stable entry point to the engine: a formula string in, a fast evaluator plus
|
|
7
|
+
* the free variables and the parsed AST out.
|
|
8
|
+
*
|
|
9
|
+
* It NEVER THROWS. `parse` throws on bad input, which is correct for a parser and wrong for the
|
|
10
|
+
* call site that matters here: an author or a student typing into a field, where a thrown error
|
|
11
|
+
* would take the lab down mid-keystroke. So the result is a union, `{ fn, vars, ast }` or
|
|
12
|
+
* `{ error }`, discriminated by an optional `error` on both arms so `if (c.error)` narrows without
|
|
13
|
+
* a type guard.
|
|
14
|
+
*
|
|
15
|
+
* This lived in `index.ts` until the answer checker needed it, which would have made the barrel
|
|
16
|
+
* import a file that imports the barrel. Implementation in a barrel is a circular import waiting
|
|
17
|
+
* for its second consumer.
|
|
18
|
+
*/
|
|
19
|
+
/** Compile a formula string. Returns `{ fn, vars, ast }` or `{ error }`, never throws. */
|
|
20
|
+
function compileExpr(src) {
|
|
21
|
+
if (!src || !src.trim()) return { error: "Empty expression" };
|
|
22
|
+
let ast;
|
|
23
|
+
try {
|
|
24
|
+
ast = parse(src);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
return { error: e instanceof Error ? e.message : "Parse error" };
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
fn: (scope) => evaluate(ast, scope),
|
|
30
|
+
vars: [...freeVars(ast)],
|
|
31
|
+
ast
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { compileExpr };
|
package/dist/math/index.d.mts
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { BinOp, Node, compileNode, evaluate, freeVars } from "./ast.mjs";
|
|
2
2
|
import { parse } from "./parse.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { isolate, occurrences } from "./rearrange.mjs";
|
|
4
|
+
import { definiteIntegral, differentiate, integrate, simplify } from "./calculus.mjs";
|
|
4
5
|
import { CompiledFn, compile } from "./compile.mjs";
|
|
5
6
|
import { toLatex } from "./latex.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** The parsed syntax tree, for differentiation, LaTeX, or analysis. */
|
|
14
|
-
readonly ast: Node;
|
|
15
|
-
readonly error?: undefined;
|
|
16
|
-
}
|
|
17
|
-
interface ExprError {
|
|
18
|
-
readonly error: string;
|
|
19
|
-
readonly fn?: undefined;
|
|
20
|
-
readonly vars?: undefined;
|
|
21
|
-
readonly ast?: undefined;
|
|
22
|
-
}
|
|
23
|
-
type ExprResult = CompiledExpr | ExprError;
|
|
24
|
-
/** Compile a formula string. Returns `{ fn, vars, ast }` or `{ error }`, never throws. */
|
|
25
|
-
declare function compileExpr(src: string): ExprResult;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { type BinOp, CompiledExpr, type CompiledFn, ExprError, ExprResult, type Node, compile, compileExpr, compileNode, differentiate, evaluate, freeVars, parse, simplify, toLatex };
|
|
7
|
+
import { CompiledExpr, ExprError, ExprResult, compileExpr } from "./expr.mjs";
|
|
8
|
+
import { Complex, complex_d_exports } from "./complex.mjs";
|
|
9
|
+
import { Poly, PolyRoots, allRoots, deflate, degree, deriv, evalC, evalPoly, factorTex, fromAst, polyRoots, polyTex, poly_d_exports, solveEquation, trim } from "./poly.mjs";
|
|
10
|
+
import { PolySolution, polyCoeffs, solutionTex, solvePoly } from "./solve.mjs";
|
|
11
|
+
import { Fn1, Line, areaBetween, intersections, normalAt, quadrature, roots, tangentAt } from "./analysis.mjs";
|
|
12
|
+
import { AnswerSpec, ExprCheckOpts, checkAnswer, checkExpression, checkNumber, normalizeMathInput, parseValue } from "./answer-check.mjs";
|
|
13
|
+
export { type AnswerSpec, type BinOp, type CompiledExpr, type CompiledFn, type Complex, type ExprCheckOpts, type ExprError, type ExprResult, type Fn1, type Line, type Node, type Poly, type PolyRoots, type PolySolution, allRoots, areaBetween, checkAnswer, checkExpression, checkNumber, compile, compileExpr, compileNode, complex_d_exports as complex, definiteIntegral, deflate, degree, deriv, differentiate, evalC, evalPoly, evaluate, factorTex, freeVars, fromAst, integrate, intersections, isolate, normalAt, normalizeMathInput, occurrences, parse, parseValue, poly_d_exports as poly, polyCoeffs, polyRoots, polyTex, quadrature, roots, simplify, solutionTex, solveEquation, solvePoly, tangentAt, toLatex, trim };
|
package/dist/math/index.mjs
CHANGED
|
@@ -1,43 +1,14 @@
|
|
|
1
1
|
import { compileNode, evaluate, freeVars } from "./ast.mjs";
|
|
2
2
|
import { parse } from "./parse.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { isolate, occurrences } from "./rearrange.mjs";
|
|
4
|
+
import { definiteIntegral, differentiate, integrate, simplify } from "./calculus.mjs";
|
|
4
5
|
import { compile } from "./compile.mjs";
|
|
5
6
|
import { toLatex } from "./latex.mjs";
|
|
7
|
+
import { compileExpr } from "./expr.mjs";
|
|
8
|
+
import { complex_exports } from "./complex.mjs";
|
|
9
|
+
import { allRoots, deflate, degree, deriv, evalC, evalPoly, factorTex, fromAst, polyRoots, polyTex, poly_exports, solveEquation, trim } from "./poly.mjs";
|
|
10
|
+
import { polyCoeffs, solutionTex, solvePoly } from "./solve.mjs";
|
|
11
|
+
import { areaBetween, intersections, normalAt, quadrature, roots, tangentAt } from "./analysis.mjs";
|
|
12
|
+
import { checkAnswer, checkExpression, checkNumber, normalizeMathInput, parseValue } from "./answer-check.mjs";
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* expr, a tiny, safe, dependency-free symbolic math engine.
|
|
10
|
-
*
|
|
11
|
-
* Pipeline: `tokenize → parse (AST) → evaluate`. On top of the AST it offers
|
|
12
|
-
* exact `differentiate`, `simplify`, and `toLatex`, so the same typed formula
|
|
13
|
-
* can be plotted, differentiated for an exact tangent, and rendered beautifully.
|
|
14
|
-
* No `eval`/`new Function`.
|
|
15
|
-
*
|
|
16
|
-
* `compileExpr(src)` is the stable, simple entry point (returns a fast `fn` plus
|
|
17
|
-
* the free `vars` and the parsed `ast`); the lower-level pieces are exported for
|
|
18
|
-
* widgets that need the tree (derivative explorers, LaTeX labels, step-by-step).
|
|
19
|
-
*
|
|
20
|
-
* Supports: numbers (incl. `1.5e3`), variable `x` + named params, constants
|
|
21
|
-
* (`pi`/`e`/`tau`), operators `+ - * / % ^` (^ right-assoc) and unary minus,
|
|
22
|
-
* implicit multiplication (`2x`, `3sin(x)`), and functions `sin cos tan cot sec
|
|
23
|
-
* csc asin acos atan sinh cosh tanh sqrt cbrt abs exp ln log log2 log10 floor
|
|
24
|
-
* ceil round sign` (+ 2-arg `pow atan2 min max mod hypot`).
|
|
25
|
-
*/
|
|
26
|
-
/** Compile a formula string. Returns `{ fn, vars, ast }` or `{ error }`, never throws. */
|
|
27
|
-
function compileExpr(src) {
|
|
28
|
-
if (!src || !src.trim()) return { error: "Empty expression" };
|
|
29
|
-
let ast;
|
|
30
|
-
try {
|
|
31
|
-
ast = parse(src);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
return { error: e instanceof Error ? e.message : "Parse error" };
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
fn: (scope) => evaluate(ast, scope),
|
|
37
|
-
vars: [...freeVars(ast)],
|
|
38
|
-
ast
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
export { compile, compileExpr, compileNode, differentiate, evaluate, freeVars, parse, simplify, toLatex };
|
|
14
|
+
export { allRoots, areaBetween, checkAnswer, checkExpression, checkNumber, compile, compileExpr, compileNode, complex_exports as complex, definiteIntegral, deflate, degree, deriv, differentiate, evalC, evalPoly, evaluate, factorTex, freeVars, fromAst, integrate, intersections, isolate, normalAt, normalizeMathInput, occurrences, parse, parseValue, poly_exports as poly, polyCoeffs, polyRoots, polyTex, quadrature, roots, simplify, solutionTex, solveEquation, solvePoly, tangentAt, toLatex, trim };
|
package/dist/math/latex.mjs
CHANGED
|
@@ -81,8 +81,9 @@ function texP(node) {
|
|
|
81
81
|
prec: 2
|
|
82
82
|
};
|
|
83
83
|
const sep = node.right.type === "num" ? " \\cdot " : "";
|
|
84
|
+
const right = node.right.type === "neg" ? `\\left(${texP(node.right).s}\\right)` : wrap(node.right, 2);
|
|
84
85
|
return {
|
|
85
|
-
s: `${wrap(node.left, 2)}${sep}${
|
|
86
|
+
s: `${wrap(node.left, 2)}${sep}${right}`,
|
|
86
87
|
prec: 2
|
|
87
88
|
};
|
|
88
89
|
}
|
|
@@ -103,6 +104,14 @@ function texCall(node) {
|
|
|
103
104
|
if (node.fn === "cbrt") return `\\sqrt[3]{${wrap(a0, 0)}}`;
|
|
104
105
|
if (node.fn === "abs") return `\\left|${wrap(a0, 0)}\\right|`;
|
|
105
106
|
if (node.fn === "exp") return `e^{${wrap(a0, 0)}}`;
|
|
107
|
+
/**
|
|
108
|
+
* `ln|x|`, not `ln(|x|)`.
|
|
109
|
+
*
|
|
110
|
+
* The modulus bars already delimit the argument, so the usual parentheses double up. Every
|
|
111
|
+
* textbook and mark scheme writes the integral of 1/x as ln|x|, and that is the form a learner
|
|
112
|
+
* has to reproduce, so it is the form to show.
|
|
113
|
+
*/
|
|
114
|
+
if ((node.fn === "ln" || node.fn === "log") && a0.type === "call" && a0.fn === "abs" && a0.args[0]) return `\\${node.fn}\\left|${wrap(a0.args[0], 0)}\\right|`;
|
|
106
115
|
const args = node.args.map((a) => wrap(a, 0)).join(", ");
|
|
107
116
|
return `${NAMED_FN.has(node.fn) ? `\\${node.fn}` : `\\operatorname{${node.fn}}`}\\left(${args}\\right)`;
|
|
108
117
|
}
|
package/dist/math/parse.mjs
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Node } from "./ast.mjs";
|
|
2
|
+
import { Complex } from "./complex.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/math/poly.d.ts
|
|
5
|
+
declare namespace poly_d_exports {
|
|
6
|
+
export { Poly, PolyRoots, add, allRoots, deflate, degree, deriv, evalC, evalPoly, factorTex, fromAst, mul, polyRoots, polyTex, solveEquation, trim };
|
|
7
|
+
}
|
|
8
|
+
type Poly = number[];
|
|
9
|
+
declare const trim: (p: Poly) => Poly;
|
|
10
|
+
declare const degree: (p: Poly) => number;
|
|
11
|
+
/** Horner evaluation (real). */
|
|
12
|
+
declare function evalPoly(p: Poly, x: number): number;
|
|
13
|
+
/** Horner evaluation (complex). */
|
|
14
|
+
declare function evalC(p: Poly, z: Complex): Complex;
|
|
15
|
+
/** Derivative polynomial. */
|
|
16
|
+
declare const deriv: (p: Poly) => Poly;
|
|
17
|
+
declare function add(a: Poly, b: Poly): Poly;
|
|
18
|
+
declare function mul(a: Poly, b: Poly): Poly;
|
|
19
|
+
/** Synthetic division of p by (x − r); returns the quotient (assumes r is a root,
|
|
20
|
+
* i.e. drops the remainder). The "divide out a found factor" step. */
|
|
21
|
+
declare function deflate(p: Poly, r: number): Poly;
|
|
22
|
+
/** LaTeX of a polynomial in descending order, e.g. [−6,11,−6,1] → "x^{3} - 6x^{2} + 11x - 6". */
|
|
23
|
+
declare function polyTex(p0: Poly, x?: string): string;
|
|
24
|
+
/** Coefficients of `node` as a polynomial in `x` (other vars from `params`), or
|
|
25
|
+
* null if it isn't a polynomial in x (sin(x), 1/x, fractional power, …). */
|
|
26
|
+
declare function fromAst(node: Node, x?: string, params?: Record<string, number>): Poly | null;
|
|
27
|
+
/**
|
|
28
|
+
* All complex roots of `p` via Durand–Kerner simultaneous iteration (then snapped).
|
|
29
|
+
* For a degree-n polynomial returns n roots; real roots come back with im = 0.
|
|
30
|
+
*/
|
|
31
|
+
declare function allRoots(p0: Poly): Complex[];
|
|
32
|
+
interface PolyRoots {
|
|
33
|
+
poly: Poly;
|
|
34
|
+
degree: number;
|
|
35
|
+
roots: Complex[];
|
|
36
|
+
realRoots: number[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Solve p = 0 for ALL roots (any degree up to MAX_DEG). null if degenerate.
|
|
40
|
+
*
|
|
41
|
+
* Named `polyRoots` because `solve` alone said nothing about which roots of what: labs exported
|
|
42
|
+
* three of them (closed-form polynomial, these numeric ones, and the circuit solver).
|
|
43
|
+
*/
|
|
44
|
+
declare function polyRoots(p0: Poly): PolyRoots | null;
|
|
45
|
+
/** Solve an expression-AST equation `expr = 0` for x, any degree. null if not a
|
|
46
|
+
* polynomial in x. (Linear/quadratic also flow through here, exactly.) */
|
|
47
|
+
declare function solveEquation(node: Node, x?: string, params?: Record<string, number>): PolyRoots | null;
|
|
48
|
+
/**
|
|
49
|
+
* Factored form of the polynomial over the reals: leading coefficient × linear
|
|
50
|
+
* factors (real roots, with multiplicity) × irreducible quadratics (complex
|
|
51
|
+
* conjugate pairs). e.g. x³−6x²+11x−6 → "(x − 1)(x − 2)(x − 3)".
|
|
52
|
+
*/
|
|
53
|
+
declare function factorTex(p0: Poly, x?: string): string;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Poly, PolyRoots, allRoots, deflate, degree, deriv, evalC, evalPoly, factorTex, fromAst, polyRoots, polyTex, poly_d_exports, solveEquation, trim };
|