4574 Commits

Author SHA1 Message Date
Glen Whitney
fd88f32073 WIP: "Actual" symbolic evaluation
This PR is not intended for merging as-is, but serves as an
  alternate demonstration (vis-a-vis issue #2437) that essentially all
  the ingredients already exist in mathjs for evaluation in which all
  undefined variables evaluate to symbols, therefore possibly returning
  an expression (Node) rather than a concrete value (while still
  evaluating all the way to concrete values when possible).
  Moreover, mathematical manipulation of symbolic expressions can be
  supported without circularity and without modifying numerous source
  files.

  This PR does however depend on a small addition to typed-function.js,
  see https://github.com/josdejong/typed-function/pull/125.

  See (or run) examples/symbolic_evaluation.mjs for further details on this.
2022-03-09 16:17:17 -08:00
Glen Whitney
399648601c feat(simplifyCore): convert equivalent function calls into operators
Resolves #2415.
2022-03-09 16:17:17 -08:00
Sam Estep
bb9eb4e0ec
Add checks for type declarations (#2448)
* Add overloads for Matrix add and subtract

* Add check for types/index.ts

* Fix type errors in types/index.ts

* Fix a couple execution errors

* Run test:types as part of test:all

* Fix remaining errors

* Replace types/index.ts comments with asserts

* Add tests for narrowed type inference

* Add dual-purpose comment at top of types/index.ts

* Update AUTHORS

* Use Glen's alternate test:types suggestion
2022-03-08 15:59:35 +01:00
Jos de Jong
9ac5a67c71 Publish v10.4.0 v10.4.0 2022-03-07 12:33:07 +01:00
Jos de Jong
3166b7f57b
Gwhitney doctesting (#2471)
* test: Add unit tests for all of the examples in (jsdoc) comments

  Uses the existing extraction of examples from tools/docgenerator.js
  Hence, for now this is limited to documentation of functions, but
  hopefully it can be extended to classes, units (and physical constants),
  and constants as well in the future.

  Exposes numerous errors in the examples, some of which are bugs; these
  are for now put on a known error list to be worked on, so that this
  PR does not change a huge number of source files.

  Also adds a test to check that all symbols are documented (which
  similarly doesn't really pass at the moment, and is patched to a
  hopefully temporary warning).

* refactor: Make doc.test.js into a node test

  The source code is not available in its layout as in the repository in
  the browser tests, so the new doc testing can only occur in the node tests

* Add simplifyCore, symbolicEqual, map, and resolve to the list with functions with known issues in the jsdoc examples

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-03-07 11:50:42 +01:00
Jos de Jong
8f9624b2e6 Update history and authors 2022-03-07 10:59:55 +01:00
Glen Whitney
489c6cf8cd
chore: Update to latest fraction.js (#2467)
Resolves #2427.

  Also adds tests verifying that creating a fraction from two numbers
  requires them both to be integers, and slightly updates documentation.

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-07 10:35:22 +01:00
Abraham
955b596d68
Fix syntax error on format example in documentaion. (#2468) 2022-03-06 19:37:41 -08:00
Jos de Jong
c957d41053
Implement cumsum function for computing cumulative sums (#1870)
Resolves #1633

Co-authored-by: Hjortur Jonasson <hjorturjonasson@gmail.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
2022-03-05 23:06:51 -08:00
Jos de Jong
2dd9e1397c Update history and authors list 2022-03-04 11:05:11 +01:00
NattapongSiri
145c540627
Fix std and variance type definition for #2429 (#2455)
* Fix std and variance type definition

* Fix JSDoc and add overload for var/std of chain

* Fix array type and remove duplicate norm type

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-04 11:03:07 +01:00
Glen Whitney
2f3005a6ef
fix(simplifyCore): make sure simplifyCore recurses through all binary nodes (#2462)
Moves the catchall for an arbitrary binary operator node up one level in the
  code so that it doesn't let any cases slip through.
  Resolves #2461.
2022-03-04 09:40:50 +01:00
Jos de Jong
ab7605006c Enlarge mocha timeout to 60s (needed for IE11) v10.3.0 2022-03-02 11:55:37 +01:00
Jos de Jong
49dd4097e6 Publish v10.3.0 2022-03-02 11:44:37 +01:00
Glen Whitney
b20fb204a5
doc(map): Clarify the arguments to the callback (#2457)
* doc(map): Clarify the arguments to the callback

  Also make the message when there is a type mismatch more detailed.
  Resolves #2436.

* test(map): Add tests relevant to new documentation

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-02 11:40:49 +01:00
Josh Hansen
89bcd4776f
Reflect simplifyCore relocation in Typescript (#2456) 2022-03-02 08:32:05 +01:00
Jos de Jong
f75ea96573 Update history 2022-03-01 15:05:12 +01:00
Jos de Jong
bf241adeb9 Merge remote-tracking branch 'origin/develop' into develop 2022-03-01 14:43:58 +01:00
Glen Whitney
9d4ea92a5a
fix(eigs): Handle matrices with complex entries (#2445)
This change fixes a typing problem in complexEigs.js in which
   real-valued norms were inadvertently being typed as complex numbers.

   Resolves #2439

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-01 14:42:35 +01:00
Jos de Jong
c879b999f9 Merge remote-tracking branch 'origin/develop' into develop 2022-03-01 14:37:07 +01:00
Glen Whitney
dd1d08a175
docs(subset): Improve documentation of indices (#2446)
Incorporates (and supersedes) #2326 and the discussion therein.
  Resolves #2325.

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-01 14:36:42 +01:00
Jos de Jong
07cbc3046b Update history 2022-03-01 14:21:34 +01:00
Glen Whitney
cbcc425c58
feat(FunctionNode): allow function parameters to be called (#2443)
* feat(FunctionNode): allow function parameters to be called

  This change is implemented by checking if a function symbol is in
  the arg list, and if so delaying its analysis until evaluation time,
  at which point it is extracted from the arguments and called as
  appropriate depending on its rawArgs property.

  Also adds a few tests, documents the new facility, and documents the
  handling of free variables in a function definition, which was previously
  left undescribed.

  Resolves #2441.
  Resolves #2442.

* chore: correct lint violations (sorry)

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-03-01 14:21:13 +01:00
Jos de Jong
d6c040ce73 Fix missing imports in embeddedDocs.js 2022-03-01 14:14:04 +01:00
Jos de Jong
cb60996f41 Update history 2022-03-01 14:00:33 +01:00
Jos de Jong
c983008ee2 Merge branch 'symbolic_equal' of https://github.com/gwhitney/mathjs into gwhitney-symbolic_equal
# Conflicts:
#	src/expression/embeddedDocs/embeddedDocs.js
#	src/factoriesAny.js
2022-03-01 13:58:39 +01:00
Jos de Jong
bcdbdaa760 Do not run browserstack tests when pushing a tag 2022-03-01 13:01:42 +01:00
Jos de Jong
bb7f78c023 Update how_to_publish.md 2022-03-01 13:01:05 +01:00
Jos de Jong
8206322d57 Update how_to_publish.md v10.2.0 2022-03-01 12:41:22 +01:00
Jos de Jong
b799e92d4d Publish v10.2.0 2022-03-01 12:40:12 +01:00
Jos de Jong
3650d18c1a Fix linting issue 2022-02-28 14:45:33 +01:00
Jos de Jong
dec94f9526 Revert to webpack@4 and karma-webpack@4 again (see #2433) 2022-02-28 14:40:46 +01:00
Jos de Jong
afecccd681 Add 'karma-browserstack-launcher' to the list with plugins, upgrade to karma@6.3.16 2022-02-28 13:04:32 +01:00
Jos de Jong
1e75f604f1 Merge branch 'feat/migrate-to-webpack-5' of https://github.com/Eternal-Rise/mathjs into Eternal-Rise-feat/migrate-to-webpack-5 2022-02-28 12:42:35 +01:00
Jos de Jong
1c2e54e3d6 Update HISTORY.md and AUTHORS 2022-02-28 12:42:03 +01:00
Jos de Jong
211aceecb2
Merge branch 'develop' into feat/migrate-to-webpack-5 2022-02-28 11:57:36 +01:00
Glen Whitney
1ca208cd6d
fix(simplify): Collect like factors, and cancel like terms, in sums (#2388)
* fix(simplify): Collect like factors in sums and cancel like terms in sums

  Since polynomials like `x*(2x+x^2)` are usually written out as polynomials
  `2x^2+x^3`, adds rules to be more eager to move factors into sums to
  collect like factors. To complement this, adds a rule extracting
  negative powers from a sum. Together, these accomplish canceling
  a common factor in numerator and denominator:
  (a*k + b*k^2)/k^4 -> k^-4*(a*k + b*k^2) -> a*k^-3 + b*k^-2 -> k^-3*(a + k*b)
  -> (a + k*b)/k^3

  Resolves #1423.

* fix(simplify): Adjust for #2394

* chore: Rebase and mark rules with assumptions

  This commit should update this PR to be fully compatible with the
  current development mainline. Will remove 'WIP'.

* chore(simplify): Additional test cases from PR review

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-28 11:05:07 +01:00
Glen Whitney
151926c75b
fix: simplify.resolve detects reference loop and throws error (#2405)
* docs: Enhance generation to pick up functions with a prefix

  For example, prior to this commit, docgenerator.js would miss
  simplify.resolve because it is not a direct key of the math
  object.

  Also incorporates any "throws" attributes in the comments into
  the generated documentation, and uses this to document the
  new error-case behavior of simplify.resolve to be added in the next
  commit.

* fix(resolve): Detect and throw errors for reference loops

  Also extends resolve to work inside all node types. Adds tests
  for both changes.

* docs: Add embedded docs for simplify.resolve et al.

  To support finding the embedded doc from the `math.simplify.resolve`
  function itself, required extending the search for objects with
  documentation one level deeper in the `help()` function. Added test for
  this search.

  Also added support for documenting throws in embedded docs.

* refactor(simplify): Move resolve and simplifyCore to top-level

  Also reverts changes searching for docs and embedded docs one level
  down in the naming hierarchy.
  Also splits tests for resolve and simplifyCore into their own files,
  reflecting their new top-level status.

* fix(resolve): Remaining changes as requested

  Also removed a stray blank line inadvertently introduced in
  docgenerator.js

* refactor: Declare resolve and simplifyCore as dependencies of simplify

  ... rather than explicitly loading them, which is unnecessary now that they
  are at top level.

* fix: Add dependencies to factoriesNumber

  Also register simplifyCore as a dependency to rationalize

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-28 09:58:10 +01:00
yifanwww
15c4254bc9
feat: Make gamma generic (#2416)
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-28 09:15:25 +01:00
Josh Hansen
1b34c580f6
fix(types): Unit Typescript type update (#2450)
Add missing BigNumber parameter type to `math.unit` and add types for Unit.simplify and Unit.units
  Resolves #2353.
2022-02-27 23:45:47 -08:00
Eternal-Rise
20b5f8a2d0 chore: add process package 2022-02-21 08:11:04 +02:00
Eternal-Rise
cd0f34da3d chore: update karma config files to preprocess 2022-02-20 21:47:46 +02:00
Eternal-Rise
997a26eb30 chore: update karma config 2022-02-20 20:48:11 +02:00
Eternal-Rise
94aeaed9ff chore: add assert package 2022-02-20 20:47:52 +02:00
Eternal-Rise
332322749b chore: bump webpack & karma to v5 2022-02-20 20:01:11 +02:00
Glen Whitney
22a12567f8 feat: implement symbolicEqual function
Note for this to work in a broad variety of contexts, has to also allow
  identical expressions to cancel regardless of whether subtraction is
  always defined; but this seems safe in general, that x-x is 0 even if x
  does not generally have an additive inverse (for example, when working
  in the positive context).

  Resolves #1260.
2022-02-16 17:34:26 -08:00
Jos de Jong
c35e0b99c1 Update history 2022-02-16 17:27:41 +01:00
Divya Yeruva
43d4551e7c
add rotate definition to index.d.ts (#2419)
Co-authored-by: Yeruva <Divya.Yeruva@pepsico.com>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-16 12:42:00 +01:00
Glen Whitney
2dbf32548f
fix(combinations): Extend range of exact values (#2414)
Prior to this change, combinations(42,21) did not return an integer,
  despite its value being well below MAX_SAFE_INTEGER. Now the
  multiplications and divisions are balanced to try to keep the
  intermediate results within the safe range.

  Adds a couple of tests for larger values of combinations().

  Resolves #2413.

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-16 12:37:09 +01:00
Jos de Jong
99b546f4ad Update history 2022-02-16 12:14:24 +01:00