mathjava

mathjs java edition

License

License

GroupId

GroupId

com.zx5435
ArtifactId

ArtifactId

mathjava
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

mathjava
mathjs java edition
Project URL

Project URL

https://github.com/zx5435/mathjava
Source Code Management

Source Code Management

https://github.com/zx5435/mathjava

Download mathjava

Dependencies

runtime (2)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.8.6
org.junit.jupiter : junit-jupiter jar 5.4.2

Project Modules

There are no modules declared in this project.

mathjava

mathjs.org json parse via java

Install

<dependency>
  <groupId>com.zx5435</groupId>
  <artifactId>mathjava</artifactId>
  <version>1.0</version>
</dependency>
implementation 'com.zx5435:mathjava:1.0'

How to use it

String a = "{'value': 3, 'mathjs': 'ConstantNode'}";
Double x = Mathjs.compileString(a).evaluate();
// output 3.0
String a = "{\"fn\": \"multiply\", \"op\": \"*\", \"args\": [{\"value\": 2, \"mathjs\": \"ConstantNode\"}, {\"name\": \"x\", \"mathjs\": \"SymbolNode\"}], \"mathjs\": \"OperatorNode\", \"implicit\": false}";
Double x = Mathjs.compileString(a).evaluate(new HashMap<String, Double>() {{
    put("x", 123.0);
}});
// output 2 * x = 246.0

Mathjs supported nodes

  • ConstantNode
  • FunctionNode sin cos
  • OperatorNode + - * /
  • ParenthesisNode ()
  • SymbolNode x

Versions

Version
1.0