Calculator

From Adam Colton
Revision as of 14:31, 23 August 2016 by Adamcolton (talk | contribs) (→Need to Support)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I've never found an online calculator I like. I've never really found a decent replacement for my TI graphing calculator. In a terminal, I generally use something like Python.

I'd like to make an online math terminal. The user can enter basic expressions and see their evaluation. Users can define functions and evaluate them at points, or open them as a graph in a new window.

I'd like to include a whole host of common equations divided into namespaces.

Users can also have their own namespaces. By default, these will be kept in local storage. I'll add someway to do manual syncing (or possibly WebRTC), but users with a State Transition account will get something like 20M/year.

Functions

Basic

 Sum(a,b) => a+b

Named

 Triangle(l length, b base) => 0.5*l*b

Namespaces

Breaks up working areas. Namespaces should be lazy loaded.

There are a few special namespaces setup by default.

settings

Stores parameters for defaults. One of the special parameters is the auto-load, which determines which modules are loaded.

com

Stores common values and functions.

  • Pi
  • sin
  • cos
  • log
  • ln

Types

Values

The most basic value is an expression. This is just a reference to the unevaluated parse tree. An expression can be simplified, actually it can be "simplified" or "deepSimplified". Simplification will just perform any actions that are guaranteed to work. Things like adding integers or performing modulus. Invoking "deepSiplify" will attempt any call that may return an exact. For instance, sin will often return an approximation, but for certain values, it can return an exact.

The evaluation of an expression is either an "exact" or an "approximation", functions and operators are responsible for correctly defining the type.

Modules can define value types like complex, matrix.

Units of Quantity

  • Units (g,m)
  • Fundamental Quantity
  • Derived Quantity
  • Factors (may not be necessary)

Units are attached to values, so you can have something like complex length or a matrix of kilograms. Need to figure out how to deal with that.

Operators

Operators are defined in modules on types. Only uniary and binary operators are defined. Attempting to redefine an operator for a given unit will throw an error.

Core

The core is the type system and the ability to define modules and define operators.

Modules

Written in JavaScript (duh). They are imported as namespaces.

Structures are value types. Basic structures are expressions, integers, exacts and approximates. Standard structures will also include complex and matrix.

A module function needs to provide an interface. This defines how it is called (the arguments, which are optional, their types and so forth). The response needs to define if the output values will be exact or approximate or either, what the structure will be.

Graphing

To consider

  • setting the range
  • setting the height (or auto-setting)

Other graphs

  • Parametric
  • Polar
  • Statistical
    • bar
    • box

For performance, it may be worth generating the graph in passes, producing a usable graph quickly, but increasing the precision over a few seconds.

Need to Support

  • Basic algebra/arithmatic
  • Graphing; basic 2d/3d and color for higher dimensions
  • Geometry
    • Trig funcs
    • area (namespace)
    • volume (namespace)
  • Find roots: given a function, find the roots
  • Statistics
  • matricies

Appearance

A text-box across the top for input. As you type, it will attempt validation. If it can evaluate without invoking non-functional commands it will update the output in real time. When the user hits enter, two lines will be added to the log, one with the input, one with the output.