Calculator

From Adam Colton
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

Not entirely sure how I want to handle this. By default, everything is just sort of a number. Maybe a big-num, maybe a representative type (keep fractions and some types of irrationals like exponents and factors of special irrationals).

  • Angles
    • degree
    • radian
    • percent
  • Int
  • Double (for faster computation)
  • Matrices
  • Complex

It would also be good to have "unit" type. This would be "family", "type" and "factor". So kg would have a factor of "k" a type of "g" which is in the family "mass".

Core

Operators

 Arithmetic: +, -, *, /
 Modular: //, %
 Exponent: **
 Binary: &, |, ~, ^
 Compare: =, <, >, <>
 Assign: =>

Commands

  • use: switch namespace
  • load: Loads a module into a namespace

Modules

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

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

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.