This release implements the `Apply`, `Subst` and `|` (`Where`) commands.
**Features**
* ui: Allow Shift-SPC to enter `=` in an expression
* Implement `subst` and `where`
* Implement the `Apply` command
* Implement the `EQNLIB` command
* Add `CONSTANTS` as a way to select mathematical constants menu
* Add `CONLIB` as an alias for `ConstantsMenu`.
**Bug fixes**
* solver: Adjust detection of "epsilon" for large values
* ttf2font: Flip x coordinates for dense fonts
**Improvements**
* doc: List commands that will never be implemented
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When entering `Shift-SPC` in the expression mode, enter an `=` sign
instead of a program separator (which makes no sense in an expression)
We also reached the stage where we need to switch back to optimizing
for space instead of speed.
Fixes: #1189
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Implement the `subst` and `where` commands.
The `where` command can also be used as an operator `|` in
expressions, for example `'A+B|A=X-3'` will evaluate as `'X-3+B'`.
The HP syntax with parentheses for multiple substitutions, for example
`'A+B|(A=3;B=2)'`, is not implemented in this commit. It can be
replaced with sequences, like `'A+B|A=3|B=2'`.
Fixes: #1187
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Apply` command builds a function expression from a name and an
argument list. For example, `{ 1 2 3} 'F' APPLY` generates a function
call like `'F(1;2;3)'`.
The DB48X `Apply` command is extended compared to the HP48: it accepts
algebraic functions as names, e.g. `{ 'x+y' } 'sin' APPLY` builds a
`'sin(x+y)'` expression.
Fixes: #1185
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Compute the "epsilon" for X and Y axis as follows:
- For the X axis, use the initial range of X
- For the Y axis, use the first computed value for the function
This fixes the original problem in #1179, where the equation was in
the form `f(x)=0`, and we had a heuristic in that case that would
deduce an incorrect epsilon from the right-hand-side value `0`.
That heuristic was implemented to solve equations with very large
values, such as found in physics when dealing for example with
Avogadro number. A simple example would be something like
`1E45*sin(x)=0.5E45`. But the heuristic was depending on being able to
isolate the left and right hand sides. It would fail for example if
the expresion was initially written as `1E45*sin(x)-0.5E45`.
Instead, the new heuristic computes the epsilon for the Y axis from
the first run of the equation. In that case, if the original epsilon
is `1E-18` (which is the default for a `Precision` of 24 digits and a
`SolverImprecision` value of 6), then the target precision will be in
the order of `1E45*1E-18`.
Fixes: #1179
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
On the HP50G, the `CONSTANTS` menu selects "CAS constants".
This seems to approximately match DB48X mathematical constants menus.
Fixes: #1183
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release adds `DoSubs`, `DoList`, `NSub` and `EndSub` commands, and fixes
related issues that were found with the associated examples in teh HP50G
Advanced Reference Manual.
**Features**
* lists: Implement `DoList`, `DoSubs`, `NSub` and `EndSub`
* units: Add usual "big" units to `Computing` units menu (e.g. KB, MB)
* graphics: Add `Freeze` command
* ui: Make it easier to enter units
* expressions: Accept algebraic forms for `integrate` and `root`
* expressions: Graphical rendering of integrals
**Bug fixes**
* case: Preserve the code for the default case (which was lost before)
* parser: Parse arg-less alegbraic commmands such as `NSub`
* equations: Fix syntax errors in built-in equations, e.g. missing parentheses
* equations: Replace variables that match DB48X command names, e.g. `Re`
* equations: Replace imperial units with SI units, e.g. `in` with `cm`
* units: Reject user-defined functions in unit expressions
* constants: Fix definition for the `qε0` constant
**Improvements**
* Update help about equations with some additional material
* tests: Run through all the builtin equations
* ui: Do not insert an extra space before parentheses in equation
* simulator: Add macOS icons for DB48X and DB50X
* font: Record saved font with `v` update
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The definition of the `qε0` constant contains a space, which is
now reported as a syntax error. Also fix the test that incorrectly
accepted a value without the associated unit.
Fixes: #1173
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Improve entry for units as follows:
* Add a `unit` mode with `U` as the cursor
* Correctly append unit names after numbers and units
* Same with inverse units
* Let `EEX`/`Cycle` key switch prefix units
Fixes: #1170
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Freeze` command preserves some specific areas on the screen.
It takes a numerical value as input, which is a combination of bits:
1: Status area
2: Stack / command area
4: Menu area
Note that the refresh algorithm on DB48X is not exaclty similar to how
things work on HP calculators because it's designed for an always-on
e-Ink screen
Fixes; #1169
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Ensure that we can parse algebraic commands that have no argument.
This is useful for `NSUB` and `ENDSUB`.
Fixes: #1167
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Fix various syntax errors in the built-in equations contributed by
@Wiljea.
Also some changes in units:
* use `Ω` (Unicode 937) character instead of `Ω` (Unicode 8486) for
the Ohm unit. There is a dedicated Unicode codepoint, but since we
don't use special characters for `m` or `s` units, there is no
reason we should make things more difficult for Ohm.
* Use metric units consistently, i.e. replace `_lb` with `_kg`, `_in`
with `_cm`, `_lbf` with `_N` and so on. It might be worth it later
to make a metric and an imperial variant of this file.
* Use degrees for user angles input in equations.
* Rename variables that are reserved words, e.g. `Re` and `vx`.
This is because DB48X is by default case-insensitive.
Note that we could have a prefix character forcing a symbol for
reserved names (much like we have a prefix for constants).
Fixes: #1162
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `SINC` function is quite trivial, and the only special case is 0.
Use `IFTE` to special case 0 out and return 1 in that case.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Fix the units for `I` in several equations.
Signed-off-by: Wiljea <143950411+Wiljea@users.noreply.github.com>
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The focus of this release is on new commands, notably for matrix and vector
operations. This release also ships with a DM48X-specific keymap, which fixes a
problem with teh file selector on the DM32. The equation library has been extended with numerous equations, but they are not fully validated yet.
**Features**
* `con`, `idn` and `ranm` matrix generation commands
* `Array→` and `→Array` commands to convert array to/from stack
* `dot` product and `cross` product commands for vectors
* `DispXY` styled text rendering command
* `DupDup` command duplicating top item twice
* Add a large number of equations to equation library
**Bug fixes**
* Fix `decimal::to_bignum` for small magnitudes
* Return angle unit for `atan2` and `arg` commands
* The `for` loop on lists no longer ends leaving the debugger active
* Interactive stack `DropN` command returns to level 1
* Fix file selector's "New file" on DM32 so that ENTER terminates it
* A few fixes in equations in the equation library
**Improvements**
* Improve graphical rendering of expressions such as multiplication operators
* doc: Update status
* font: Fix `v` glyph vertical placement, add dot and cross glyphs
* ttf2font: Add additional verbose info about source data
* Add `CONSTANTS` as an alias for `ConstantsMenu`
* Replace documentation references to `EEX` with `×10ⁿ`
* Optimize parsing of real numbers in parentheses
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When the decimal value has a negative expoonent, we should not loop
forever building a very large multiplier, and we should not generate a
negative 0 either.
Fixes: #1156Fixes: #1157
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `ranm` command generates a random matrix.
Compared to the HP50G, the DB48X can also generate a random vector
in a way similar to `CON` for constant values.
Fixes: #1155
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `con` command (`ConstantArray`) creates a constant array from
dimensions, another array or vector.
Fixes: #1153
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When running a `for` loop on a list, make sure we cleanup properly on
exit.
Fixes: #1147
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Fix the vertical bearing of the `v` glyph so that it does not appear
to be one pixel above the others.
Also add glyphs for
* dot-product (`⋅`, U8901)
* cross-product (`⨯`, 10799)
These can be used to refer to the `CROSS` and `DOT` commands.
Fixes: #1117
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `DispXY` command on the HP50G takes a font ID that takes 2 values,
1 for small font and 2 for regular font.
In order to implement this in a more easy way, reorder the font IDs so
that they "match", except that 0 gives the even smaller help font and
3 gives the larger editor font.
Fixes: #1146
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When dropping stack items, we need to put the interactive pointer at
the bottom since the stack items have been removed.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add a DM48 keymap that restores correct keybindings in the file
selector dialog.
Fixes: #1002
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add a number of new equations to the equation library, contributed by
Jean Wilson.
Fixes: #1129
Co-authored-by: Jean Wilson <srmjwilson@gmail.com>
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When parsing units or expressions with parentheses, turn ERROR into
SKIP to make sure the higher-level selected expression parsing.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release mostly focuses on issues exposed by the iOS releases.
It's a bug-fixes only release.
***Bug fixes***
* ios: Fix a screen refresh bug delaying the display of computation results
* ios: Increase user-accesssible memory for DB50X to match the DM32
* files: Avoid opening two files when a loaded file contains units/constants
* units: Restrict unit expressions further, e.g. forbid `1_km^s`
* build: Do not add unwanted macOS-specific files in release tar files
* build: Remove irrelevant help file from releae tar file
* constants: Fix numerical value for G constant
* tests: Rename `M` demo helper to `D`, since we use `M` in symbolic tests
* makefile: Add `mv` echo to targets doing image comparison
* units: Use pi constant in definition of radians unit
* parser: Detect syntax error on `(inv(x))` in non-expression mode
* units: Avoid infinite loop for bad unit exponents
* files: Avoid crash in `file_closer` if file does not exist
* tests: Add DMS/HMS operations to math demo
* tests: Add keyboard shortcuts to launch the demos
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The 'M' name is actually used in a number of other tests, where we
expect a symbolic result and get a bug instead.
Renaming to 'D' ensures we don't disrupt those tests if we run them
after a demo.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Since source file evaluation can involve units, constants, etc, we
need to make sure that the file is closed before evaluating it.
Fixes: #1137
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `r` unit is now defined as a function of `pi`.
As a side effect, fix parsing of expressions in units, allowing `inv`
to parse correctly in the definition of radians.
Fixes: #1136
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>