├── .gitignore
├── DOCS.md
├── README.md
├── mdlt.gif
├── mdlt.js
├── operations.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .DS_Store
3 | build
4 |
--------------------------------------------------------------------------------
/DOCS.md:
--------------------------------------------------------------------------------
1 | [](https://aunyks.com/metadelta)
2 | # Mdlt Documentation
3 | ______________________________________________
4 | ## Arithmetic
5 | **abs**
6 |
7 | *Get absolute value of a value*
8 | ```
9 | mdlt abs -1
10 | Returns:
11 | 1
12 | ```
13 | Argument(s): The value of which the absolute value will be found
14 |
15 | Return: The absolute value of the given value
16 |
17 | **log**
18 |
19 | *Evaluate a logarithm with given base and argument*
20 | ```
21 | mdlt log 2:8
22 | Returns:
23 | 3
24 | ```
25 | Argument(s): A base value and argument value separated by a colon (':')
26 |
27 | Return: The evaluated logarithm
28 |
29 | **sin**
30 |
31 | *Find the sine of a value*
32 | ```
33 | mdlt sin pi / 2
34 | Returns:
35 | 1
36 | ```
37 | Argument(s): The value of which the corresponding sine value will be found
38 |
39 | Return: The output sine value of the given value
40 |
41 | **cos**
42 |
43 | *Find the cosine of a value*
44 | ```
45 | mdlt cos 0
46 | Returns:
47 | 1
48 | ```
49 | Argument(s): The value of which the corresponding cosine value will be found
50 |
51 | Return: The output cosine value of the given value
52 |
53 | **tan**
54 |
55 | *Find the tangent of a value*
56 | ```
57 | mdlt tan pi/4 // or mdl tan 0.7853981
58 | returns
59 | 1
60 | ```
61 | Argument(s): The value of which the corresponding tangent value will be found
62 |
63 | Return: The output tangent value of the given value
64 |
65 | **arcsin**
66 |
67 | *Find the inverse sine of a value*
68 | ```
69 | mdlt arcsin 1
70 | returns
71 | 1/2 pi
72 | ```
73 | Argument(s): The value of which the corresponding inverse sine value will be found
74 |
75 | Return: The output inverse sine value of the given value
76 |
77 | **arccos**
78 |
79 | *Find the inverse cosine of a value*
80 | ```
81 | mdlt arccos 1
82 | returns
83 | 0
84 | ```
85 | Argument(s): The value of which the corresponding inverse cosine value will be found
86 |
87 | Return: The output inverse cosine value of the given value
88 |
89 | **arctan**
90 |
91 | *Find the inverse tangent of a value*
92 | ```
93 | mdlt arctan 1
94 | returns
95 | 1/4 pi
96 | ```
97 | Argument(s): The value of which the corresponding inverse tangent value will be found
98 |
99 | Return: The output inverse tangent value of the given value
100 |
101 | ## Algebra
102 |
103 | **simplify**
104 |
105 | *Simplify the given expression*
106 | ```
107 | mdlt simplify x + x + 2 * 8
108 | returns
109 | 2x + 16
110 | ```
111 | Argument(s): The expression that is to be simplified
112 |
113 | Return: The simplified expression
114 |
115 | **factor**
116 |
117 | *Factor the given expression*
118 | ```
119 | mdlt factor x^2 - 1
120 | returns
121 | (x - 1) (x + 1)
122 | ```
123 | Argument(s): The expression that is to be factored
124 |
125 | Return: The factored expression
126 |
127 | **zeroes**
128 |
129 | *Find the x values at which the function expression is equal to 0*
130 | ```
131 | mdlt zeroes x^2 - 1
132 | returns
133 | [1, -1]
134 | ```
135 | Argument(s): a string representation of the function of which the zeroes are to be found
136 |
137 | Return: An array of the zeroes of the function
138 |
139 | **solve**
140 |
141 | *Solve the given expression (of a single variable)*
142 | ```
143 | mdlt solve 35 = 7x
144 | returns
145 | 'x = 5'
146 | ```
147 | Argument(s): a string representation of the expression to be solved
148 |
149 | Return: The value that the variable equals (see example above)
150 |
151 | ## Calculus
152 |
153 | **derive**
154 |
155 | *Find the first derivative of the function expression*
156 | ```
157 | mdlt derive x^2
158 | returns
159 | 2 x
160 | ```
161 | Argument(s): The function to be differentiated
162 |
163 | Return: The first derivative of the given function expression
164 |
165 | **integrate**
166 |
167 | *Find an integral of the function expression*
168 | ```
169 | mdlt integrate x^2
170 | returns
171 | 1/3 x^3
172 | ```
173 | Argument(s): The function to be integrated
174 |
175 | Return: An integral of the given function expression
176 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # mdlt - Metadelta CLI
2 | **A command-line utility for quick math.**
3 | ### What is it?
4 | Mdlt is a lightweight command line tool that lets you perform arithmetic and symbolic math operations right from the terminal.
5 | 
6 | ### Why this?
7 | Well, nobody wants to boot Python, import SymPy, and type extraneous commands just to find a derivative. And, finding a decent website for math is quite a pain. *Mdlt just makes it too easy to do math!*
8 |
9 | ### How do I get started?
10 | To install mdlt, simply run:
11 | ```
12 | npm i -g mdlt
13 | ```
14 | That's it! Now you can begin implementing Metadelta's powerful functionality right from the terminal!
15 |
16 | ### Okay and how do I use it?
17 | Commands are formatted as such:
18 | ```
19 | mdlt [operation] [expression]
20 | ```
21 | Which means that you'd like metadelta to perform the given operation on the following expression.
22 | An example of this is:
23 | ```
24 | mdlt derive x^2
25 | ```
26 | which returns: `2 x`.
27 | *Note:* for more reliable processing, wrap the expression in double quotes.
28 | For more commands, Mdlt's documentation can be found [here](https://github.com/metadelta/mdlt/blob/master/DOCS.md).
29 | ______________________________________________
30 | Like mdlt? [Donate Bitcoin](http://www.aunyks.com/bitcoin/) to support development!
31 |
32 | Built using [metadelta](https://github.com/metadelta/metadelta-core)
33 | Licensed under the GNU GPLv3 license.
34 |
35 | Copyright (C) 2017 Gerald Nash
36 |
37 | This program is free software: you can redistribute it and/or modify
38 | it under the terms of the GNU General Public License as published by
39 | the Free Software Foundation, either version 3 of the License, or
40 | (at your option) any later version.
41 |
42 | This program is distributed in the hope that it will be useful,
43 | but WITHOUT ANY WARRANTY; without even the implied warranty of
44 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 | GNU General Public License for more details.
46 |
47 | You should have received a copy of the GNU General Public License
48 | along with this program. If not, see .
49 |
--------------------------------------------------------------------------------
/mdlt.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/metadelta/mdlt/41f0c9b0806fe29f52cb2aa7ea7b90233075d584/mdlt.gif
--------------------------------------------------------------------------------
/mdlt.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var operations = require('./operations.js');
3 | const DEBUG = false;
4 |
5 | var operation = process.argv[2];
6 | var input = '';
7 | for(var i = 3; i < process.argv.length; i++){
8 | input += ' ' + process.argv[i];
9 | }
10 |
11 | if(DEBUG){
12 | console.log(process.argv);
13 | console.log('Operation: '+operation);
14 | console.log('Input: '+input);
15 | }
16 |
17 | try {
18 | console.log(operations[operation](input));
19 | }catch(err){
20 | if(DEBUG)
21 | console.log(err);
22 | console.log('Improper format.\n\nUsage:\nmdlt [operation] [expression]\nOR\nmdlt [operation] "[expression]"');
23 | }
24 |
--------------------------------------------------------------------------------
/operations.js:
--------------------------------------------------------------------------------
1 | var metadelta = require('@metadelta/core');
2 |
3 | // Define the operation map,
4 | // an object that maps mdlt subcommands
5 | // to metadelta functions
6 | module.exports = {
7 | simplify: metadelta.simplify,
8 | factor: metadelta.factor,
9 | zeroes: metadelta.zeroes,
10 | integrate: metadelta.integrate,
11 | derive: metadelta.derive,
12 | cos: metadelta.cos,
13 | sin: metadelta.sin,
14 | tan: metadelta.tan,
15 | arccos: metadelta.arccos,
16 | arcsin: metadelta.arcsin,
17 | arctan: metadelta.arcsin,
18 | abs: metadelta.abs,
19 | log: function(expression){
20 | var base = expression.split(':')[0];
21 | var arg = expression.split(':')[1];
22 | if(isNaN(metadelta.log(base, arg)))
23 | throw new Error('Logarithm only given one argument.');
24 | else
25 | return metadelta.log(base, arg);
26 | },
27 | tangent: function(expression){
28 | var data = expression.split('|');
29 | var at = parseInt(data[0]);
30 | var f = data[1];
31 | return metadelta.tangent(f, at);
32 | },
33 | area: function(expression){
34 | var split = expression.split('|');
35 | var f = split[1];
36 | var from = split[0].split(':')[0];
37 | var to = split[0].split(':')[1];
38 | return '' + metadelta.areaUnder(f, { start: from, finish: to });
39 | }
40 | };
41 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mdlt",
3 | "version": "0.0.4",
4 | "description": "A command-line utility for quick math.",
5 | "main": "mdlt.js",
6 | "scripts": {
7 | "test": "node mdlt.js derive x^2",
8 | "package": "pkg -t node6-macos-x64,node6-linux-x86,node6-win-x86 --out-dir build mdlt.js"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/metadelta/mdlt.git"
13 | },
14 | "keywords": [
15 | "metadelta",
16 | "cas",
17 | "calculus",
18 | "math",
19 | "algebra",
20 | "trigonometry",
21 | "science"
22 | ],
23 | "author": "Gerald Nash (aunyks.com) ",
24 | "license": "GPL-3.0",
25 | "bugs": {
26 | "url": "https://github.com/metadelta/mdlt/issues"
27 | },
28 | "preferGlobal": true,
29 | "bin": {
30 | "mdlt": "mdlt.js"
31 | },
32 | "homepage": "https://github.com/metadelta/mdlt#readme",
33 | "dependencies": {
34 | "@metadelta/core": "^1.1.1"
35 | },
36 | "devDependencies": {
37 | "pkg": "^3.0.0"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------