├── .gitignore ├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── lib └── mathomatic-master │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── COPYING │ ├── INSTALL.txt │ ├── NEWS │ ├── README.txt │ ├── VERSION │ ├── altproto.h │ ├── am.c │ ├── am.h │ ├── blt.h │ ├── changes.txt │ ├── changes_series_15.txt │ ├── cmds.c │ ├── compile.mingw │ ├── compile.secure │ ├── complex.c │ ├── complex.h │ ├── complex_lib.c │ ├── diff.c │ ├── doc │ ├── README.txt │ ├── am.html │ ├── doc.css │ ├── favicon.ico │ ├── fdl-1.3-standalone.html │ ├── gnu-fdl.png │ ├── greenfade.png │ ├── index.html │ ├── led_circle_green.png │ ├── manual.html │ ├── matho-mult.1.html │ ├── matho-pascal.1.html │ ├── matho-primes.1.html │ ├── matho-sum.1.html │ ├── matho-sumsq.1.html │ ├── mathomatic.1.html │ ├── mathomatic16x16.png │ ├── open_book_nae_02.png │ ├── primorial.1.html │ ├── quickrefcard.html │ └── rmath.1.html │ ├── examples │ ├── README.txt │ ├── compile.limits │ ├── compile.roots │ ├── fact.c │ ├── fact.py │ ├── factorial │ ├── intfact.c │ ├── limits.c │ ├── roots.c │ └── testprimes │ ├── externs.h │ ├── factor.c │ ├── factor_int.c │ ├── gcd.c │ ├── globals.c │ ├── help.c │ ├── icons │ ├── README.txt │ ├── icon.rc │ ├── mathomatic.desktop │ ├── mathomatic.icns │ ├── mathomatic.ico │ ├── mathomatic.png │ ├── mathomatic.svg │ ├── mathomatic.xpm │ └── mathomatic32x32.png │ ├── includes.h │ ├── integrate.c │ ├── lib │ ├── README.txt │ ├── altproto.h │ ├── am.h │ ├── blt.h │ ├── emscripten.c │ ├── example.c │ ├── externs.h │ ├── includes.h │ ├── lib.c │ ├── license.h │ ├── makefile │ ├── math.js │ ├── mathomatic.h │ ├── proto.h │ ├── standard.h │ └── testmain.c │ ├── license.h │ ├── list.c │ ├── m4 │ ├── README.txt │ ├── degrees.m4 │ ├── file_id.diz │ ├── functions.m4 │ ├── gradians.m4 │ ├── matho │ ├── matho-install │ ├── matho-install-degrees │ ├── matho-uninstall │ └── rmath │ ├── main.c │ ├── makefile │ ├── makehtmlcard.awk │ ├── makehtmlcard.sh │ ├── makenews.sh │ ├── makepdfsheet.sh │ ├── mathomatic.1 │ ├── menu │ ├── README.txt │ ├── mathomatic │ └── mathomatic-primes │ ├── misc │ ├── README.txt │ ├── ideas.txt │ ├── identities.in │ ├── john.in │ ├── known_bugs.txt │ └── linear4.in │ ├── parse.c │ ├── poly.c │ ├── primes │ ├── README.txt │ ├── bigtwins.out │ ├── lsqrt.c │ ├── makefile │ ├── matho-mult │ ├── matho-mult.1 │ ├── matho-pascal.1 │ ├── matho-pascal.c │ ├── matho-primes.1 │ ├── matho-primes.c │ ├── matho-sum │ ├── matho-sum.1 │ ├── matho-sumsq.1 │ ├── matho-sumsq.c │ ├── primorial │ ├── primorial.1 │ ├── t │ └── twins.out │ ├── proto.h │ ├── rmath.1 │ ├── simplify.c │ ├── solve.c │ ├── standard.h │ ├── super.c │ ├── t │ ├── tests │ ├── README.txt │ ├── all.in │ ├── all.out │ ├── batman_gnuplot_bug.in │ ├── batman_plot │ ├── circles.in │ ├── collatz.in │ ├── cubic.in │ ├── cubic2.in │ ├── demo │ ├── demo.in │ ├── demo_sub │ ├── distance.in │ ├── electronics.in │ ├── ellipse.in │ ├── examples.in │ ├── fibonacci.in │ ├── finance.in │ ├── fix1.in │ ├── fix2.in │ ├── fix5.in │ ├── fix7.in │ ├── fix8.in │ ├── fix9.in │ ├── fraction.in │ ├── heart.in │ ├── heron.in │ ├── how_limit_works.in │ ├── hypertrig.in │ ├── limits.in │ ├── linear.in │ ├── pie.in │ ├── points.in │ ├── poly.in │ ├── pyth3d.in │ ├── quadratic.in │ ├── quartic.in │ ├── radius.in │ ├── simplify.in │ ├── t │ ├── test.in │ ├── test1.in │ ├── test2.in │ ├── test3.in │ ├── test6.in │ ├── trig │ └── trig.in │ ├── unfactor.c │ ├── update │ └── zipsrc ├── nodewebkit_fetch └── README ├── screenshot.png └── src ├── beancounter.html ├── components ├── bower_components │ ├── platform │ │ ├── .bower.json │ │ ├── README.md │ │ ├── bower.json │ │ ├── build.log │ │ ├── platform.js │ │ └── platform.js.map │ ├── polymer │ │ ├── .bower.json │ │ ├── LICENSE.txt │ │ ├── bower.json │ │ ├── build.log │ │ ├── polymer-micro.html │ │ ├── polymer-mini.html │ │ └── polymer.html │ └── webcomponentsjs │ │ ├── .bower.json │ │ ├── CustomElements.js │ │ ├── CustomElements.min.js │ │ ├── HTMLImports.js │ │ ├── HTMLImports.min.js │ │ ├── MutationObserver.js │ │ ├── MutationObserver.min.js │ │ ├── README.md │ │ ├── ShadowDOM.js │ │ ├── ShadowDOM.min.js │ │ ├── bower.json │ │ ├── build.log │ │ ├── package.json │ │ ├── webcomponents-lite.js │ │ ├── webcomponents-lite.min.js │ │ ├── webcomponents.js │ │ └── webcomponents.min.js ├── index.html ├── lorem-element.html └── mathview │ ├── latex_generator.js │ ├── mathml.css │ ├── mathml_generator.js │ ├── mspace.js │ └── x-mathview.html ├── css ├── beancounter.css ├── bootstrap-theme.css ├── bootstrap-theme.css.map ├── bootstrap-theme.min.css ├── bootstrap-tour.css ├── bootstrap.css ├── bootstrap.css.map ├── bootstrap.min.css ├── jumbotron-narrow.css ├── math.css └── mathml.css ├── img └── bean.svg ├── js ├── beancounter.js ├── bootstrap-tour.js ├── bootstrap.js ├── bootstrap.min.js ├── evaluator.js ├── head.core.js ├── head.load.js ├── jquery.min.js ├── latex_generator.js ├── math.js ├── mathml_generator.js ├── parsers │ ├── calculator.js │ ├── latex_generator.js │ └── mathml_generator.js ├── plugins │ ├── beancounter.js │ ├── calculus.js │ ├── converter.js │ ├── elementary_stats.js │ ├── firstrun.js │ ├── help.js │ ├── plot.js │ ├── primality.js │ ├── prime.js │ ├── quantities.js │ ├── solve.js │ ├── variables.js │ └── visualize.js └── require.js ├── licenses └── material-design-icons ├── package.json └── sources ├── ast.lex ├── calculator.lex ├── latex_generator.lex └── mathml_generator.lex /.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | nodewebkit_fetch/*.tar.gz 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/.gitmodules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joseph 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | MATHOMATIC_DIR=lib/mathomatic-master/lib 2 | JS_DIR=src/js 3 | OUTPUT_DOC=output/README 4 | 5 | #nodewebkit stuff, we'll try not to hit the servers too much 6 | NW_DIR=nodewebkit_fetch 7 | NW_VERSION=v0.11.5 8 | NW_FETCH_PATH=http://dl.node-webkit.org/$(NW_VERSION) 9 | 10 | NW_LINUX_64_TAR=node-webkit-$(NW_VERSION)-linux-x64.tar.gz 11 | NW_LINUX_64=$(NW_FETCH_PATH)/$(NW_LINUX_64_TAR) 12 | NW_WIN_64=$(NW_FETCH_PATH)/node-webkit-$(NW_VERSION)-win-x64.tar.gz 13 | NW_osx_64=$(NW_FETCH_PATH)/node-webkit-$(NW_VERSION)-osx-x64.tar.gz 14 | 15 | .PHONY: clean all 16 | 17 | all: mathomatic_js output/package.nw output/linux_x64 output/web output/linux_x64_patched bc_windows bc_mac 18 | 19 | # requires a set up and running emscripten environment 20 | mathomatic_js: 21 | $(MAKE) -C $(MATHOMATIC_DIR) 22 | cp $(MATHOMATIC_DIR)/math.js $(JS_DIR)/math.js 23 | 24 | output: 25 | mkdir -p output 26 | 27 | # 28 | output/package.nw: output 29 | rm -f $@ 30 | cd src/ && zip -r ../output/package.nw * 31 | 32 | output/web: output src/ parsers 33 | rm -rf $@ 34 | cp -R src/ output/web/ 35 | mv output/web/beancounter.html output/web/index.html 36 | echo "web/ - put this on a webserver to run beancounter there" >> $(OUTPUT_DOC) 37 | 38 | output/linux_x64: output output/package.nw 39 | rm -rf $@ 40 | wget $(NW_LINUX_64) -nc --directory-prefix $(NW_DIR) 41 | cp $(NW_DIR)/$(NW_LINUX_64_TAR) output/$(NW_LINUX_64_TAR) 42 | tar -C output -xvzf output/$(NW_LINUX_64_TAR) 43 | rm output/$(NW_LINUX_64_TAR) 44 | mv output/node-webkit-v0.11.5-linux-x64 output/linux_x64 45 | cp output/package.nw output/linux_x64/ 46 | mv output/linux_x64/nw output/linux_x64/beancounter 47 | 48 | echo "linux_x64/ - an x86_64 build of beancounter for linux" >> $(OUTPUT_DOC) 49 | 50 | output/linux_x64_patched: output output/linux_x64 51 | rm -rf $@ 52 | # patch to run on modern linux distributions, temporary fix 53 | cp -R output/linux_x64 output/linux_64_patched 54 | sed -i 's/udev\.so\.0/udev.so.1/g' output/linux_64_patched/beancounter 55 | echo "linux_x64/ - an x86_64 build of beancounter for linux, patched to work on modern systems" >> $(OUTPUT_DOC) 56 | 57 | 58 | bc_windows: bc 59 | 60 | 61 | bc_mac: bc 62 | 63 | 64 | clean: 65 | rm -rf output 66 | $(MAKE) -C $(MATHOMATIC_DIR) clean 67 | 68 | webclean: 69 | rm -rf nodewebkit_fetch/*.tar.gz 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BeanCounter 2 | =========== 3 | 4 | BeanCounter is an entirely web-based computer algebra system with a clean user 5 | interface similar to WolframAlpha. It supports feature addition through a simple 6 | plugin system making it adaptable to a wide variety of operations. 7 | 8 | ![](https://raw.githubusercontent.com/josephlewis42/beancounter/master/screenshot.png) 9 | 10 | Out of the box it supports: 11 | 12 | * expression evaluation 13 | * integration/differentiation 14 | * formatting expressions with LaTeX 15 | * solving for different variables 16 | * simplification 17 | 18 | Live demo is [available here](http://josephlewis.net/apps/BeanCounter/). 19 | 20 | 21 | Environment 22 | ----------- 23 | 24 | This application can run in modern web-browsers or as a standalone app on the 25 | desktop through node-webkit. 26 | 27 | 28 | Technology 29 | ---------- 30 | 31 | The entire system is built on top of JavaScript, using an `emscripten` compiled 32 | libmathomatic as the backend CAS. 33 | 34 | Running Time 35 | ------------ 36 | 37 | The execution speed of mathomatic in the browser is fairly good, it takes about 38 | as much time as WolframAlpha does to return results. 39 | 40 | Contributing 41 | ------------ 42 | 43 | Patches/Addons would be welcomed, a list of potential projects (from least 44 | difficult to most) would be: 45 | 46 | * Unit Conversion 47 | * Mortgage Calculator 48 | * A better tutorial 49 | * Optionally show the steps for solving 50 | * Typeahead suggestions based on the plugins 51 | * Plotting Functions 52 | * A console for Mathomatic 53 | * Adding support for trig functions in Mathomatic through an integrated M4 replacer (regex stuff) 54 | * Replace the Mathomatic with something that works better or is native 55 | * Anything else you choose and have interest in! 56 | 57 | License 58 | ======= 59 | 60 | Copyright (c) 2015, Joseph Lewis III 61 | 62 | The BeanCounter code is licensed under an LGPL and MIT license. This project 63 | uses several libraries that have their own licenses: 64 | 65 | * Mathomatic - LGPL 66 | * nodewebkit - MIT 67 | * Bootstrap - MIT 68 | * JQuery - MIT 69 | -------------------------------------------------------------------------------- /lib/mathomatic-master/AUTHORS: -------------------------------------------------------------------------------- 1 | George Gesslein II 2 | Chief Mathomatic creator, author, maintainer, and copyright holder. 3 | http://www.mathomatic.org 4 | 5 | There are many individuals maintaining Mathomatic ports. Thank you very much 6 | for creating, supporting, and sponsoring the Mathomatic ports for all these 7 | years. 8 | 9 | Thanks to all people who have contributed code and time to the Mathomatic 10 | project: 11 | 2010 Simon Geard for better and more readable code command code. :-) 12 | 2010 Michael Pogue of Sun Microsystems for help on compiling under Solaris. 13 | 2010 Jonathan Stark for the original cmake file "CMakeLists.txt". 14 | 2011 Doug Snead for the MinGW color mode code for cmd.exe and command.com. 15 | 2012 Doug Snead creates and sells a fancy Android version with a GUI. 16 | 17 | Thanks to all the wonderful people that have been testing, contributing, and 18 | donating to the Mathomatic project and encouraging me on; many are not listed 19 | here. If you think you belong in this list, please let George Gesslein II 20 | know. I will mention anyone that has contributed to or guided the Mathomatic 21 | project, that wishes to be mentioned here. Please indicate how you would like 22 | your entry to appear (website?, email address?). 23 | 24 | And late thanks to Dennis M. Ritchie, whose work to design and create the 25 | original C language and compiler made Mathomatic and our life possible. I 26 | even learned C from his book. 27 | 28 | Sincerely, 29 | George Gesslein II 30 | -------------------------------------------------------------------------------- /lib/mathomatic-master/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # cmake build file for Mathomatic and the Symbolic Math Library, 2 | # originally contributed by Jonathan Stark. 3 | # Produces the normal version of Mathomatic with readline support. 4 | # If you need the Symbolic Math Library as a shared library, 5 | # change the line "add_library(mathomatic_cmake" to: 6 | # "add_library(mathomatic_cmake SHARED" below. 7 | # This is all untested! It is recommended to use "makefile" instead! 8 | # To use cmake instead of "makefile", type: 9 | # 10 | # cmake . 11 | # make -f Makefile 12 | # 13 | # Please note that cmake makes an unfixable mess of the Mathomatic 14 | # source distribution directory, so make a copy, first. 15 | 16 | cmake_minimum_required(VERSION 2.6) 17 | 18 | project(mathomatic) 19 | 20 | file(READ VERSION FV) 21 | string(STRIP ${FV} MATHOMATIC_VERSION) 22 | message(STATUS VERSION: ${MATHOMATIC_VERSION}) 23 | add_definitions(-O3 -Wall -Wshadow -Wno-char-subscripts -fexceptions -DVERSION="${MATHOMATIC_VERSION}") 24 | 25 | add_library(mathomatic_cmake 26 | includes.h 27 | standard.h 28 | am.h 29 | altproto.h 30 | externs.h 31 | blt.h 32 | license.h 33 | complex.h 34 | proto.h 35 | lib/mathomatic.h 36 | lib/lib.c 37 | globals.c 38 | complex.c 39 | poly.c 40 | super.c 41 | am.c 42 | factor.c 43 | help.c 44 | list.c 45 | unfactor.c 46 | complex_lib.c 47 | factor_int.c 48 | simplify.c 49 | cmds.c 50 | diff.c 51 | gcd.c 52 | integrate.c 53 | parse.c 54 | solve.c 55 | ) 56 | 57 | add_executable(testmain 58 | lib/mathomatic.h 59 | lib/testmain.c 60 | ) 61 | 62 | add_dependencies(testmain 63 | mathomatic_cmake 64 | ) 65 | 66 | add_executable(mathomatic 67 | includes.h 68 | standard.h 69 | am.h 70 | altproto.h 71 | externs.h 72 | blt.h 73 | license.h 74 | complex.h 75 | proto.h 76 | globals.c 77 | complex.c 78 | poly.c 79 | super.c 80 | am.c 81 | factor.c 82 | help.c 83 | list.c 84 | unfactor.c 85 | complex_lib.c 86 | factor_int.c 87 | main.c 88 | simplify.c 89 | cmds.c 90 | diff.c 91 | gcd.c 92 | integrate.c 93 | parse.c 94 | solve.c 95 | ) 96 | 97 | set_target_properties(mathomatic_cmake PROPERTIES COMPILE_FLAGS "-DLIBRARY") 98 | set_target_properties(mathomatic PROPERTIES COMPILE_FLAGS "-DREADLINE -DUNIX") 99 | target_link_libraries(mathomatic -lm -lreadline) 100 | target_link_libraries(testmain mathomatic_cmake) 101 | target_link_libraries(mathomatic_cmake -lm) 102 | -------------------------------------------------------------------------------- /lib/mathomatic-master/VERSION: -------------------------------------------------------------------------------- 1 | 16.0.5 2 | -------------------------------------------------------------------------------- /lib/mathomatic-master/altproto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Alternate global C function prototypes for Mathomatic. 3 | * 4 | * Copyright (C) 1987-2012 George Gesslein II. 5 | */ 6 | 7 | /* command function list */ 8 | int clear_cmd(), quit_cmd(), list_cmd(), simplify_cmd(), help_cmd(), eliminate_cmd(); 9 | int fraction_cmd(), unfactor_cmd(), compare_cmd(), extrema_cmd(); 10 | int read_cmd(), display_cmd(), calculate_cmd(), solve_cmd(); 11 | int factor_cmd(), derivative_cmd(), replace_cmd(), approximate_cmd(); 12 | int save_cmd(), taylor_cmd(), limit_cmd(), echo_cmd(), plot_cmd(); 13 | int copy_cmd(), divide_cmd(), pause_cmd(), version_cmd(); 14 | int edit_cmd(), real_cmd(), imaginary_cmd(), tally_cmd(); 15 | int roots_cmd(), set_cmd(), variables_cmd(), code_cmd(), optimize_cmd(), push_cmd(), push_en(); 16 | int sum_cmd(), product_cmd(), for_cmd(), integrate_cmd(), nintegrate_cmd(), laplace_cmd(); 17 | 18 | /* various functions that don't return int */ 19 | char *dirname_win(); 20 | char *skip_space(), *skip_comma_space(), *skip_param(); 21 | char *get_string(); 22 | char *parse_equation(), *parse_section(), *parse_var(), *parse_var2(), *parse_expr(); 23 | char *list_expression(), *list_equation(), *flist_equation_string(); 24 | double gcd(), gcd_verified(), my_round(), multiply_out_unique(); 25 | long decstrtol(), max_memory_usage(); 26 | 27 | void fphandler(int sig); 28 | void inthandler(int sig); 29 | void alarmhandler(int sig); 30 | void exithandler(int sig); 31 | void resizehandler(int sig); 32 | -------------------------------------------------------------------------------- /lib/mathomatic-master/blt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * blt(), also know as memmove(3), include file for Mathomatic. 3 | * 4 | * Copyright (C) 1987-2012 George Gesslein II. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | The chief copyright holder can be contacted at gesslein@mathomatic.org, or 21 | George Gesslein II, P.O. Box 224, Lansing, NY 14882-0224 USA. 22 | 23 | */ 24 | 25 | #if 1 26 | #define blt(dest, src, cnt) memmove((dest), (src), (cnt)) /* memory copy function; must allow overlapping of src and dest */ 27 | #else 28 | /* If no fast or working memmove(3) routine exists use this one. */ 29 | static inline char * 30 | blt(dest, src, cnt) 31 | char *dest; 32 | const char *src; 33 | int cnt; 34 | { 35 | char *tdest; 36 | const char *tsrc; 37 | int tcnt; 38 | 39 | if (cnt <= 0) { 40 | if (cnt == 0) { 41 | return dest; 42 | } else { 43 | error_bug("blt() cnt < 0"); 44 | } 45 | } 46 | if (src == dest) { 47 | return dest; 48 | } 49 | 50 | tdest = dest; 51 | tsrc = src; 52 | tcnt = cnt; 53 | 54 | if (tdest > tsrc) { 55 | tdest += tcnt; 56 | tsrc += tcnt; 57 | while (--tcnt >= 0) 58 | *--tdest = *--tsrc; 59 | } else { 60 | while (--tcnt >= 0) 61 | *tdest++ = *tsrc++; 62 | } 63 | return dest; 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/mathomatic-master/compile.mingw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Shell script for creating the Windows 32-bit executables "mathomatic.exe" and Prime Number Tools. 3 | # In Debian or its derivatives, install the MinGW cross-compiler package mingw32 (tested; 4 | # run "sudo apt-get install mingw32"). MinGW doesn't recognize long longs or 5 | # long doubles, and the 64-bit version doesn't appear to work yet. 6 | # 7 | # The 32-bit executables created here are very capable, work standalone or with Cygwin, 8 | # and do not require readline or editline to recall and edit command-line history, 9 | # this already works in the Windows console (cmd.exe and command.com). 10 | # 11 | # To compile everything with MinGW, just type: 12 | # ./compile.mingw 13 | # This file may require editing if you are not using Debian or a derivative distro. 14 | # 15 | 16 | # Abort on any errors: 17 | set -e 18 | 19 | # Define the C cross-compiler and flags we are using here: 20 | export CC=i586-mingw32msvc-cc 21 | export CFLAGS="-O3 -Wall -DMINGW -DWIN32_CONSOLE_COLORS -DBOLD_COLOR $CFLAGS" 22 | 23 | echo Compiling Windows 32-bit Mathomatic... 24 | make clean 25 | cd icons 26 | i586-mingw32msvc-windres icon.rc icon.o 27 | cd .. 28 | AOUT=mathomatic.exe MATHOMATIC_OBJECTS="icons/icon.o" make -j 29 | make clean 30 | 31 | echo 32 | echo Compiling the 32-bit Prime Number Tools... 33 | cd primes 34 | make flush 35 | CFLAGS="-DUSE_DOUBLES $CFLAGS" make -j 36 | make clean 37 | echo 38 | mv matho-primes matho-primes.exe 39 | mv matho-pascal matho-pascal.exe 40 | mv matho-sumsq matho-sumsq.exe 41 | echo Prime Number Tools executables had .exe appended to the filenames. 42 | cd .. 43 | 44 | exit 0 # 64-bits isn't completely supported by MinGW yet. 45 | 46 | export CC=amd64-mingw32msvc-cc 47 | 48 | echo Compiling Windows 64-bit Mathomatic... 49 | make clean 50 | cd icons 51 | amd64-mingw32msvc-windres icon.rc icon.o 52 | cd .. 53 | AOUT=mathomatic64.exe MATHOMATIC_OBJECTS="icons/icon.o" make -j 54 | make clean 55 | -------------------------------------------------------------------------------- /lib/mathomatic-master/compile.secure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Shell script for creating the executable "mathomatic_secure", 3 | # which lacks the code for file I/O and shelling out. 4 | # The result can safely be used as an application on open public servers. 5 | # The Mathomatic run-time option -s4 performs exactly the same function, 6 | # so this script that makes a separate executable is no longer necessary. 7 | 8 | # You will need to install the libeditline-dev package to run this. 9 | 10 | echo Compiling Secure Mathomatic... 11 | set -v 12 | gcc -O3 -Wall -Wshadow -Wno-char-subscripts -fexceptions $CFLAGS $CPPFLAGS -DEDITLINE -DUNIX -DVERSION=\"`cat VERSION`\" -DSECURE -DTIMEOUT_SECONDS=3600 $LDFLAGS *.c -lm -leditline $LDLIBS -o mathomatic_secure && echo ./mathomatic_secure created. 13 | make clean # for any subsequent makes 14 | -------------------------------------------------------------------------------- /lib/mathomatic-master/complex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Include file for the double precision floating point complex number 3 | * arithmetic functions in "complex_lib.c". 4 | * 5 | * Copyright (C) 1987-2012 George Gesslein II. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | The chief copyright holder can be contacted at gesslein@mathomatic.org, or 22 | George Gesslein II, P.O. Box 224, Lansing, NY 14882-0224 USA. 23 | 24 | */ 25 | 26 | typedef struct complexs { /* complex number structure */ 27 | double re; /* real part */ 28 | double im; /* imaginary part */ 29 | } complexs; 30 | 31 | /* 32 | * Complex number arithmetic function prototypes 33 | */ 34 | int complex_fixup(complexs *ap); 35 | complexs complex_add(complexs a, complexs b); 36 | complexs complex_negate(complexs a); 37 | complexs complex_mult(complexs a, complexs b); 38 | complexs complex_div(complexs a, complexs b); 39 | complexs complex_log(complexs a); 40 | complexs complex_exp(complexs a); 41 | complexs complex_pow(complexs a, complexs b); 42 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/README.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory contains the complete Mathomatic user documentation in HTML. 3 | Everything in this documentation directory is copyrighted and licensed under 4 | the GNU Free Documentation License version 1.3. The full text of this license 5 | is contained in file "fdl-1.3-standalone.html". 6 | 7 | To read or print the Mathomatic user documentation, point your web browser to 8 | the file "index.html". If the PDF documentation was created, it is in the 9 | file "../manual.pdf". This PDF document is made by the htmldoc program by 10 | typing "make pdf" in the parent directory. 11 | 12 | When copying the Mathomatic documentation, please copy this entire directory, 13 | not just selected HTML files from it. 14 | 15 | To view online the most recent documentation, visit 16 | http://mathomatic.org/math/doc/ with your web browser. 17 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/doc.css: -------------------------------------------------------------------------------- 1 | /* George Gesslein II's CSS for HTML documentation */ 2 | 3 | /* Commonly used classes: */ 4 | .clear { clear: both; } 5 | .right { float: right; } 6 | .left { float: left; } 7 | .center { text-align: center; } 8 | .middle { vertical-align: middle; } 9 | .indent { margin-left: 2em; margin-right: 2em; } 10 | .large { font-size: larger; } 11 | .small { font-size: x-small; } 12 | 13 | .sample { 14 | border-style: solid; border-width: 1px; border-color: black; 15 | border-radius: 7px; 16 | color: black; 17 | background-color: #FFFAF0; 18 | padding: 10px; 19 | } 20 | 21 | a img { border: none; } /* don't draw borders around images that are links */ 22 | 23 | body { 24 | font-family: sans-serif; 25 | /* font-size: large; */ 26 | color: black; 27 | background-color: white; 28 | } 29 | 30 | tt { 31 | color: brown; 32 | } 33 | 34 | a:link { 35 | color: blue; 36 | } 37 | 38 | a:visited { 39 | color: purple; 40 | } 41 | 42 | a:hover { 43 | color: green; 44 | } 45 | 46 | a:active { 47 | color: red; 48 | } 49 | 50 | caption { 51 | color: orange; 52 | font-weight: bold; 53 | } 54 | 55 | @media print 56 | { 57 | a { text-decoration: none; } /* no underlined links when printing */ 58 | /* h2 { page-break-before: always; } Uncomment this to page break at the beginning of every section. */ 59 | } 60 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/doc/favicon.ico -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/gnu-fdl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/doc/gnu-fdl.png -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/greenfade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/doc/greenfade.png -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Official Mathomatic user documentation, top level 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |

outline of book Official Documentation for Mathomatic

31 | 32 |

HTML User Guides:

33 | 34 |
35 | button 36 | The Mathomatic User Guide 37 |
38 | button 39 | The Mathomatic Command Reference 40 |
41 | button 42 | The Unix/Linux man page for Mathomatic 43 |
44 | button 45 | The rmath application man page (m4 Mathomatic) 46 |
47 | button 48 | The matho-primes utility man page 49 |
50 | button 51 | The primorial utility man page 52 |
53 | 54 |

55 | This HTML format documentation is easily viewed and printed using your web browser. 56 | 57 |

PDF User Guides:

58 |

59 | For the PDFs, see the online 60 | Mathomatic User Guide and Command Reference PDF file in a file called "manual.pdf", 61 | or all Unix/Linux man pages for Mathomatic in one PDF file called "bookman.pdf". 62 | PDFs are generally used when you want to print out a hardcopy 8.5-inch by 11-inch manual, but they can be browsed 63 | with a PDF document viewer and saved to disk easily, too. 64 | 65 |


66 | 67 |

68 | GFDL logo 69 | Mathomatic documentation copyright © 1987-2012 George Gesslein II 70 |

71 | Permission is granted to copy, distribute and/or modify this document 72 | under the terms of the GNU Free Documentation License, Version 1.3 73 | or any later version published by the Free Software Foundation; 74 | with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. 75 | A copy of the license is included here 76 | in the Mathomatic documentation directory. 77 | 78 |
79 |
80 |


81 | 82 |
83 | 84 | Mathomatic icon www.mathomatic.org 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/led_circle_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/doc/led_circle_green.png -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/matho-mult.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | MATHO-MULT(1) manual page 11 | 12 | 13 | 14 | Table of Contents 15 | 16 |

Name

matho-mult - 17 | multiply large integers 18 | 19 |

Synopsis

matho-mult [integers] 21 | 22 |

Description

This 23 | command-line utility is optionally part of the mathomatic(1) package. It uses 25 | Python to multiply many large integers separated by spaces or 26 | newlines. The size of the integers is only limited by the 27 | available memory of the computer. The single integer result is 28 | output to standard output, followed by a newline. 29 | 30 |

The integers to multiply may be specified on the command line 31 | or read from standard input.

32 | 33 |

Author

George Gesslein 34 | II (gesslein@mathomatic.org) at "http://www.mathomatic.org ". 36 | 37 |

Reporting Bugs

If you 38 | find a bug, please report it to the author or at "https://launchpad.net/mathomatic 40 | ". 41 | 42 |

See Also

mathomatic(1) , primorial(1) , matho-sum(1) 46 |
47 | 48 |

Table of Contents

49 | 50 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/matho-pascal.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | MATHO-PASCAL(1) manual page 11 | 12 | 13 | 14 | Table of Contents 15 | 16 |

Name

matho-pascal - display Pascal’s 18 | triangle 19 | 20 |

Synopsis

matho-pascal [number-of-lines] 22 | 23 |

Description

This command-line utility is 25 | optionally part of the mathomatic(1) package. It 27 | calculates up to 1000 lines of Pascal’s triangle using 28 | floating point arithmetic, dumping the lines to standard output. 29 | The default is to center one screen full. 30 | 31 |

Every number inside Pascal’s triangle is the sum of the 32 | two numbers immediately above it.

33 | 34 |

Each line of Pascal’s triangle is the same as the 35 | binomial coefficients for a given power.

36 | 37 |

The sum of all numbers in each line of Pascal’s triangle 38 | is a power of 2.

39 | 40 |

Author

George 41 | Gesslein II (gesslein@mathomatic.org) at "http://www.mathomatic.org ". 43 | 44 |

Reporting 45 | Bugs

If you find a bug, please report it to the author or 46 | at "https://launchpad.net/mathomatic 48 | ". 49 | 50 |

See 51 | Also

mathomatic(1) 52 | , matho-primes(1) , 53 | matho-sumsq(1) 54 |
55 | 56 |

Table of Contents

57 | 58 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/matho-sum.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | MATHO-SUM(1) manual page 11 | 12 | 13 | 14 | Table of Contents 15 | 16 |

Name

matho-sum - sum 17 | large integers 18 | 19 |

Synopsis

matho-sum [integers] 21 | 22 |

Description

This 23 | command-line utility is optionally part of the mathomatic(1) package. It uses 25 | Python to sum many large integers separated by spaces or 26 | newlines. The size of the integers is only limited by the 27 | available memory of the computer. The single integer result is 28 | output to standard output, followed by a newline. 29 | 30 |

The integers to sum may be specified on the command line or 31 | read from standard input.

32 | 33 |

Author

George Gesslein 34 | II (gesslein@mathomatic.org) at "http://www.mathomatic.org ". 36 | 37 |

Reporting Bugs

If you 38 | find a bug, please report it to the author or at "https://launchpad.net/mathomatic 40 | ". 41 | 42 |

See Also

mathomatic(1) , primorial(1) , matho-mult(1) 46 |
47 | 48 |

Table of Contents

49 | 50 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/matho-sumsq.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | MATHO-SUMSQ(1) manual page 11 | 12 | 13 | 14 | Table of Contents 15 | 16 |

Name

matho-sumsq - Find 17 | the minimum sum of the squares for integers 18 | 19 |

Synopsis

matho-sumsq [numbers] 21 | 22 |

Description

This 23 | command-line utility is optionally part of the mathomatic(1) package. It finds 25 | the minimum number of positive integers that when squared and 26 | added together, equal the given number. There is a proof that no 27 | more than 4 squares summed together are required to represent any 28 | positive integer. 29 | 30 |

The command-line may contain positive integers to find the 31 | minimum squares of, they must be less than 2147483648 (2^31) on 32 | 32-bit systems or less than 9223372036854775808 (2^63) on 64-bit 33 | systems. If "+" is appended to the given number, the program 34 | counts up from the given number. If the minimum number of squares 35 | is 2, this program displays all possible combinations with 2 36 | squares for the given number, otherwise it just displays the 37 | first combination it finds.

38 | 39 |

If no command-line arguments are given, the programs reads the 40 | numbers from standard input.

41 | 42 |

Author

George Gesslein 43 | II (gesslein@mathomatic.org) at "http://www.mathomatic.org ". 45 | 46 |

Reporting Bugs

If you 47 | find a bug, please report it to the author or at "https://launchpad.net/mathomatic 49 | ". 50 | 51 |

See Also

mathomatic(1) , matho-pascal(1) , matho-primes(1) 55 |
56 | 57 |

Table of Contents

58 | 59 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/mathomatic16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/doc/mathomatic16x16.png -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/open_book_nae_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/doc/open_book_nae_02.png -------------------------------------------------------------------------------- /lib/mathomatic-master/doc/primorial.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | PRIMORIAL(1) manual page 11 | 12 | 13 | 14 | Table of Contents 15 | 16 |

Name

primorial - 17 | calculate large primorials 18 | 19 |

Synopsis

primorial integers 21 | 22 |

Description

This 23 | command-line utility is optionally part of the mathomatic(1) package. It uses 25 | Python and matho-primes(1) and matho-mult(1) to calculate and 28 | display large primorials. 29 | 30 |

A primorial is the product of all primes up to the given 31 | integer. The integers to show the primorials of are given on the 32 | command line.

33 | 34 |

The calculated primorials are output to standard output. The 35 | size is limited by the amount of computer memory available.

36 | 37 |

Author

George Gesslein 38 | II (gesslein@mathomatic.org) at "http://www.mathomatic.org ". 40 | 41 |

Reporting Bugs

If you 42 | find a bug, please report it to the author or at "https://launchpad.net/mathomatic 44 | ". 45 | 46 |

See Also

mathomatic(1) , matho-mult(1) , matho-primes(1) 50 |
51 | 52 |

Table of Contents

53 | 54 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/README.txt: -------------------------------------------------------------------------------- 1 | 2 | examples/README.txt 3 | ------------------- 4 | 5 | See directory ../tests for example, tutorial, and test scripts for 6 | Mathomatic. 7 | 8 | This directory is where example source code goes for a binary distribution. 9 | 10 | ----------------------------------------------------------------------------- 11 | 12 | limits.c - C program to display current C data type limits and sizes. 13 | Mathomatic is limited to double precision floating point. 14 | Use "./compile.limits" to compile. 15 | 16 | roots.c - Nice GSL example of a numerical polynomial equation solver utility. 17 | Compile with "./c", requires the libgsl development files. 18 | Like Mathomatic, uses complex number double precision output. 19 | Use "./compile.roots" to compile. 20 | 21 | testprimes - A parallel, brute force test of the prime number generator. 22 | Checks the first 50,000,000 primes for gaps or errors. 23 | Requires matho-primes and BSD Games primes to be installed. 24 | It simply compares their output up to 1,000,000,000. 25 | 26 | ----------------------------------------------------------------------------- 27 | 28 | This directory also contains factorial functions "factorial()" in various 29 | computer languages are for use with output from the Mathomatic code command, 30 | which converts factorial expressions like x! to factorial(x). 31 | 32 | Type "./factorial" followed by integers or integer expressions to compute 33 | large factorials with Python and test "fact.py". 34 | 35 | ----------------------------------------------------------------------------- 36 | 37 | These files do not have any man page, because I think they are not ready or 38 | are not made for packaging. They are just example programs. Any requests to 39 | make man pages for these files will be honored by the author of this 40 | document: George Gesslein II. Please specify which utilities you think should 41 | be installable with a man page. 42 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/compile.limits: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Compile limits.c and create the executable in ~/bin if it exists. 3 | # limits is a standalone program that nicely 4 | # displays current C data type limits and sizes. 5 | # Works with any C compiler, compiles with the C compiler you set CC to. 6 | 7 | CC=${CC-cc} 8 | 9 | if [ -d ~/bin ] 10 | then 11 | LIMITS=~/bin/limits 12 | else 13 | LIMITS=./limits 14 | fi 15 | echo Compiling limits.c 16 | set -e 17 | set -x 18 | $CC -Wall $CFLAGS $CPPFLAGS $LDFLAGS -o $LIMITS limits.c 19 | echo limits.c compiled and installed as $LIMITS 20 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/compile.roots: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Compile roots.c and create the executable in ~/bin if it exists. 3 | # roots is a command-line numerical polynomial equation solver. 4 | # Requires the GNU Scientific Library (GSL) development files. 5 | 6 | if [ -d ~/bin ] 7 | then 8 | ROOTS=~/bin/roots 9 | else 10 | ROOTS=roots 11 | fi 12 | echo Compiling roots.c 13 | gcc -O3 -Wall $CFLAGS $CPPFLAGS $LDFLAGS -o $ROOTS roots.c `pkg-config --cflags --libs gsl` && echo Done, executable installed in $ROOTS 14 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/fact.c: -------------------------------------------------------------------------------- 1 | 2 | #if 0 3 | #define _REENTRANT 1 /* Should be defined before including math.h for Mac OS X. */ 4 | /* Do not use with iOS. Disabled by default and unnecessary. */ 5 | #endif 6 | 7 | #include 8 | 9 | /* 10 | * General factorial function in C for double precision floating point. 11 | * Uses the threadsafe lgamma_r(3) function, if _REENTRANT is defined. 12 | * Works for any floating point value. 13 | * Recommend using tgamma(3) (true gamma) function instead, if available. 14 | * 15 | * Link with -lm 16 | * 17 | * Returns (arg!) (same as gamma(arg+1)). 18 | * Sets "errno" external variable on overflow or error. 19 | */ 20 | double 21 | factorial(double arg) 22 | { 23 | double d; 24 | 25 | #if USE_TGAMMA 26 | d = tgamma(arg + 1.0); 27 | return d; 28 | #else 29 | #if _REENTRANT 30 | int sign; 31 | 32 | d = exp(lgamma_r(arg + 1.0, &sign)); 33 | return(d * sign); 34 | #else 35 | d = exp(lgamma(arg + 1.0)) * signgam; 36 | return d; 37 | #endif 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/fact.py: -------------------------------------------------------------------------------- 1 | # This is a general factorial function written in Python. 2 | # A factorial is the product of all positive integers <= a given number. 3 | # Works transparently with integers and floating point; 4 | # that is, it returns the same type as its single argument. 5 | # Gives an error for negative or non-integer input values. 6 | 7 | def factorial(x): 8 | "Return x! (x factorial)." 9 | if (x < 0 or (x % 1.0) != 0.0): 10 | raise ValueError, "Factorial argument must be a positive integer." 11 | if (x == 0): 12 | return x + 1 13 | d = x 14 | while (x > 2): 15 | x -= 1 16 | temp = d * x 17 | if (temp <= d): 18 | raise ValueError, "Factorial result too large." 19 | d = temp 20 | return d 21 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/factorial: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This is a Python program to display large factorials and test "fact.py". 4 | 5 | from fact import factorial 6 | import sys 7 | import os 8 | import string 9 | 10 | def usage(): 11 | print "This program calculates large factorials." 12 | print "Requires and tests \"fact.py\"." 13 | print 14 | print "Usage: %s integer_expressions" % os.path.basename(sys.argv[0]) 15 | print 16 | print "The integer expressions should be separated by spaces." 17 | print "A factorial is the product of all positive integers <= a given integer." 18 | sys.exit(2) 19 | 20 | args = sys.argv[1:] 21 | if (args == []): 22 | usage() 23 | else: 24 | try: 25 | num = eval(string.join(args)) 26 | print "factorial(", num, ") =", factorial(num) 27 | except: 28 | for arg in args: 29 | num = eval(arg) 30 | print "factorial(", num, ") =", factorial(num) 31 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/intfact.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Factorial function in C for positive integers. 3 | * 4 | * Return (arg!). 5 | * Returns -1 on error. 6 | */ 7 | int 8 | factorial(int arg) 9 | { 10 | int result; 11 | 12 | if (arg < 0) 13 | return -1; 14 | for (result = 1; result > 0 && arg > 1; arg--) { 15 | result *= arg; 16 | } 17 | if (result <= 0) /* return -1 on overflow */ 18 | return -1; 19 | return result; 20 | } 21 | -------------------------------------------------------------------------------- /lib/mathomatic-master/examples/testprimes: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Test matho-primes by comparing output with the BSD Games primes utility. 3 | # Only run this if matho-primes and the bsdgames package are installed. 4 | # The comparison is performed in parallel, to save time. 5 | # The whole test takes 30 seconds on a fast, dual-core computer. 6 | # 7 | # Checks the first 50,000,000 primes for gaps or errors. 8 | # It simply compares their output up to 1,000,000,000. 9 | # 10 | # Usage: testprimes [ primes_utility_name ] 11 | 12 | echo Testing matho-primes by comparing output with bsdgames primes... 13 | if ! matho-primes 0 0 14 | then 15 | echo Mathomatic Prime Number Tools not installed. 16 | echo Cannot find matho-primes 17 | exit 1 18 | fi 19 | 20 | PRIMES=${1-primes} 21 | if ! $PRIMES 0 0 22 | then 23 | PRIMES=/usr/games/primes 24 | if $PRIMES 0 0 25 | then 26 | echo Using $PRIMES 27 | else 28 | echo bsdgames package not installed. 29 | echo Cannot find primes utility. 30 | exit 1 31 | fi 32 | fi 33 | 34 | TESTOUT1=`mktemp /tmp/test.XXXXXXXXXX` || exit 1 35 | TESTOUT2=`mktemp /tmp/test.XXXXXXXXXX` || exit 1 36 | echo Starting and timing matho-primes 37 | time -p matho-primes 1 1000000000 >$TESTOUT1 & 38 | echo Starting $PRIMES 39 | $PRIMES 1 1000000000 >$TESTOUT2 && echo -n Word count: && wc $TESTOUT2 & 40 | wait 41 | echo Output files to compare, 42 | echo matho-primes output: 43 | ls -l $TESTOUT1 44 | echo primes output: 45 | ls -l $TESTOUT2 46 | echo Comparing: 47 | diff -uq --strip-trailing-cr $TESTOUT1 $TESTOUT2 && echo Files are identical. && echo "Test passed 100% correctly." && rm $TESTOUT1 $TESTOUT2 && exit 0 48 | echo 49 | echo Test failed. 50 | rm -f $TESTOUT1 $TESTOUT2 51 | exit 1 52 | -------------------------------------------------------------------------------- /lib/mathomatic-master/externs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mathomatic global variable extern definitions, from file "globals.c". 3 | * 4 | * Copyright (C) 1987-2012 George Gesslein II. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | The chief copyright holder can be contacted at gesslein@mathomatic.org, or 21 | George Gesslein II, P.O. Box 224, Lansing, NY 14882-0224 USA. 22 | 23 | */ 24 | 25 | extern int n_tokens; 26 | extern int n_equations; 27 | extern int cur_equation; 28 | 29 | extern token_type *lhs[N_EQUATIONS]; 30 | extern token_type *rhs[N_EQUATIONS]; 31 | 32 | extern int n_lhs[N_EQUATIONS]; 33 | extern int n_rhs[N_EQUATIONS]; 34 | 35 | extern token_type *tlhs; 36 | extern token_type *trhs; 37 | extern token_type *tes; 38 | 39 | extern int n_tlhs; 40 | extern int n_trhs; 41 | extern int n_tes; 42 | 43 | extern token_type *scratch; 44 | 45 | extern token_type zero_token; 46 | extern token_type one_token; 47 | 48 | extern int precision; 49 | extern int case_sensitive_flag; 50 | extern int factor_int_flag; 51 | extern int display2d; 52 | extern int fractions_display; 53 | extern int approximate_roots; 54 | extern int preserve_surds; 55 | extern int rationalize_denominators; 56 | extern int modulus_mode; 57 | extern volatile int screen_columns; 58 | extern volatile int screen_rows; 59 | extern int finance_option; 60 | extern int autosolve; 61 | extern int autocalc; 62 | extern int autodelete; 63 | extern int autoselect; 64 | extern char special_variable_characters[256]; 65 | extern char plot_prefix[256]; 66 | extern int factor_out_all_numeric_gcds; 67 | extern int right_associative_power; 68 | extern int power_starstar; 69 | #if !SILENT 70 | extern int debug_level; 71 | #endif 72 | extern int domain_check; 73 | extern int color_flag; 74 | extern int bold_colors; 75 | extern int text_color; 76 | extern int cur_color; 77 | extern int html_flag; 78 | extern int readline_enabled; 79 | extern int partial_flag; 80 | extern int symb_flag; 81 | extern int symblify; 82 | extern int high_prec; 83 | extern int input_column; 84 | extern int sign_cmp_flag; 85 | extern double small_epsilon; 86 | extern double epsilon; 87 | 88 | extern char *prog_name; 89 | extern char *var_names[MAX_VAR_NAMES]; 90 | extern char var_str[MAX_VAR_LEN+80]; 91 | extern char prompt_str[MAX_PROMPT_LEN]; 92 | #if !SECURE 93 | extern char rc_file[MAX_CMD_LEN]; 94 | #endif 95 | 96 | #if CYGWIN || MINGW 97 | extern char *dir_path; 98 | #endif 99 | #if READLINE || EDITLINE 100 | extern char *last_history_string; 101 | #endif 102 | #if READLINE 103 | extern char *history_filename; 104 | extern char history_filename_storage[MAX_CMD_LEN]; 105 | #endif 106 | 107 | extern double unique[]; 108 | extern int ucnt[]; 109 | extern int uno; 110 | 111 | extern int previous_return_value; 112 | extern sign_array_type sign_array; 113 | extern FILE *default_out; 114 | extern FILE *gfp; 115 | extern char *gfp_filename; 116 | extern int gfp_append_flag; 117 | extern jmp_buf jmp_save; 118 | extern int eoption; 119 | extern int test_mode; 120 | extern int demo_mode; 121 | extern int quiet_mode; 122 | extern int echo_input; 123 | extern volatile int abort_flag; 124 | extern int pull_number; 125 | extern int security_level; 126 | extern int repeat_flag; 127 | extern int show_usage; 128 | extern int point_flag; 129 | 130 | extern char *result_str; 131 | extern int result_en; 132 | extern const char *error_str; 133 | extern const char *warning_str; 134 | 135 | extern char *vscreen[TEXT_ROWS]; 136 | extern int current_columns; 137 | -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/README.txt: -------------------------------------------------------------------------------- 1 | 2 | Mathomatic icons for your desktop go here. 3 | 4 | icon.rc - Windows resource compiler file used to link icon with .exe file 5 | mathomatic.desktop - Unix and Linux desktop entry 6 | mathomatic.icns - Mathomatic icons for Mac OS X 7 | mathomatic.ico - 32x32 and 64x64 pixels icons for Microsoft Windows 8 | mathomatic.png - generic 64x64 Mathomatic icon 9 | mathomatic.svg - The new resizeable Mathomatic logo and icon 10 | mathomatic.xpm - X-Windows pixmap 32x32 Mathomatic icon 11 | mathomatic32x32.png - generic 32x32 Mathomatic icon 12 | 13 | These icons/logos are free to use for anything Mathomatic related. 14 | -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/icon.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * icon.rc - Windows resource compiler input file used to link 3 | * the Mathomatic icon with the mathomatic.exe file. 4 | * 5 | * To compile, run: 6 | * 7 | * windres icon.rc icon.o 8 | * 9 | * then link mathomatic.exe with icon.o, 10 | * so that mathomatic.exe will have an nice icon in Windows Explorer! 11 | */ 12 | icon1 ICON "mathomatic.ico" 13 | -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/mathomatic.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Mathomatic 3 | GenericName=Computer Algebra System 4 | Comment=Do symbolic mathematics and quick calculations 5 | Exec=mathomatic 6 | Icon=mathomatic 7 | Terminal=true 8 | Type=Application 9 | Categories=Education;Science;Math; 10 | StartupNotify=false 11 | -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/mathomatic.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/icons/mathomatic.icns -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/mathomatic.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/icons/mathomatic.ico -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/mathomatic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/icons/mathomatic.png -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/mathomatic.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char *mathomatic[] = { 3 | /* columns rows colors chars-per-pixel */ 4 | "32 32 4 1", 5 | " c #000000", 6 | ". c #FFFF00", 7 | "X c #0000BF", 8 | "o c None", 9 | /* pixels */ 10 | "o oo", 11 | " o", 12 | " ....XX...XXXXX.....XX...X o", 13 | " ......XXX.XXXXX..XX..XXX.XX o", 14 | " ..XX..X...XXXXX..XX..X...XX o", 15 | " ..XX..X.XXXXXXX..XX..X.XXXX o", 16 | " ......X...X.XXX.....XX...XX o", 17 | " ......XXXXX.XXX..XX..XXXXXX o", 18 | " ..XX..XXX.....X..XX..XXXXXX o", 19 | " ..XX..XXXXX.XXX..XX..XXXXXX o", 20 | " ..XX..XXXXX.XXX.....XXXXXXX o", 21 | " XXXXXXXXXXXXXXXXXXXXXXXXXXX o", 22 | " XXXXXXXXXXXXXXXXXXXXXXXX... o", 23 | " XXXXXXXXXXXXXXXXXX.....XXX. o", 24 | " XXXXXXXXXXXXXXXXXX.....X... o", 25 | " XXXXXXXXXXXXXXXXXX..XXXX.XX o", 26 | " XXXXXXXXXX......XX..XXXX... o", 27 | " XXXXXXXXXXXXXXXXXX..XXXXXXX o", 28 | " XXXXXXXXXX......XX..XXXXXXX o", 29 | " XXXXXXXXXXXXXXXXXX..XXXXXXX o", 30 | " XXXXXXXXXXXXXXXXXX.....XXXX o", 31 | " XXXXXXXXXXXXXXXXXX.....XXXX o", 32 | " XXXXXXXXXXXXXXXXXXXXXXXXX o", 33 | " o", 34 | "o oo", 35 | "oooooooooooooo ooooooooooooooo", 36 | "oooooooooooooo ooooooooooooooo", 37 | "ooooooooooooo oooooooooooooo", 38 | "ooooooooooooo oooooooooooooo", 39 | "ooooooooooo oooooooooooo", 40 | "ooooooo oooooooo", 41 | "ooo oooo" 42 | }; 43 | -------------------------------------------------------------------------------- /lib/mathomatic-master/icons/mathomatic32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/lib/mathomatic-master/icons/mathomatic32x32.png -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/altproto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Alternate global C function prototypes for Mathomatic. 3 | * 4 | * Copyright (C) 1987-2012 George Gesslein II. 5 | */ 6 | 7 | /* command function list */ 8 | int clear_cmd(), quit_cmd(), list_cmd(), simplify_cmd(), help_cmd(), eliminate_cmd(); 9 | int fraction_cmd(), unfactor_cmd(), compare_cmd(), extrema_cmd(); 10 | int read_cmd(), display_cmd(), calculate_cmd(), solve_cmd(); 11 | int factor_cmd(), derivative_cmd(), replace_cmd(), approximate_cmd(); 12 | int save_cmd(), taylor_cmd(), limit_cmd(), echo_cmd(), plot_cmd(); 13 | int copy_cmd(), divide_cmd(), pause_cmd(), version_cmd(); 14 | int edit_cmd(), real_cmd(), imaginary_cmd(), tally_cmd(); 15 | int roots_cmd(), set_cmd(), variables_cmd(), code_cmd(), optimize_cmd(), push_cmd(), push_en(); 16 | int sum_cmd(), product_cmd(), for_cmd(), integrate_cmd(), nintegrate_cmd(), laplace_cmd(); 17 | 18 | /* various functions that don't return int */ 19 | char *dirname_win(); 20 | char *skip_space(), *skip_comma_space(), *skip_param(); 21 | char *get_string(); 22 | char *parse_equation(), *parse_section(), *parse_var(), *parse_var2(), *parse_expr(); 23 | char *list_expression(), *list_equation(), *flist_equation_string(); 24 | double gcd(), gcd_verified(), my_round(), multiply_out_unique(); 25 | long decstrtol(), max_memory_usage(); 26 | 27 | void fphandler(int sig); 28 | void inthandler(int sig); 29 | void alarmhandler(int sig); 30 | void exithandler(int sig); 31 | void resizehandler(int sig); 32 | -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/blt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * blt(), also know as memmove(3), include file for Mathomatic. 3 | * 4 | * Copyright (C) 1987-2012 George Gesslein II. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | The chief copyright holder can be contacted at gesslein@mathomatic.org, or 21 | George Gesslein II, P.O. Box 224, Lansing, NY 14882-0224 USA. 22 | 23 | */ 24 | 25 | #if 1 26 | #define blt(dest, src, cnt) memmove((dest), (src), (cnt)) /* memory copy function; must allow overlapping of src and dest */ 27 | #else 28 | /* If no fast or working memmove(3) routine exists use this one. */ 29 | static inline char * 30 | blt(dest, src, cnt) 31 | char *dest; 32 | const char *src; 33 | int cnt; 34 | { 35 | char *tdest; 36 | const char *tsrc; 37 | int tcnt; 38 | 39 | if (cnt <= 0) { 40 | if (cnt == 0) { 41 | return dest; 42 | } else { 43 | error_bug("blt() cnt < 0"); 44 | } 45 | } 46 | if (src == dest) { 47 | return dest; 48 | } 49 | 50 | tdest = dest; 51 | tsrc = src; 52 | tcnt = cnt; 53 | 54 | if (tdest > tsrc) { 55 | tdest += tcnt; 56 | tsrc += tcnt; 57 | while (--tcnt >= 0) 58 | *--tdest = *--tsrc; 59 | } else { 60 | while (--tcnt >= 0) 61 | *tdest++ = *tsrc++; 62 | } 63 | return dest; 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/example.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Real quick and dirty example of usage of the Mathomatic Symbolic Math Library. 3 | * Designed to be as simple as possible, yet work. 4 | * Just displays: "x = 2*sign". 5 | */ 6 | #include 7 | #include 8 | #include "mathomatic.h" 9 | 10 | int 11 | main() 12 | { 13 | #if WANT_LEAKS /* Causes memory leaks, wrong code to use, but will work in a pinch. */ 14 | char *output; 15 | 16 | matho_init(); 17 | matho_parse("x^2=4", NULL); 18 | matho_process("solve x", &output); 19 | printf("%s\n", output); 20 | #else /* right code to use */ 21 | char *output; 22 | int rv; 23 | 24 | if (!matho_init()) { 25 | printf("Not enough memory.\n"); 26 | exit(1); 27 | } 28 | matho_parse((char *) "x^2=4", NULL); 29 | rv = matho_process((char *) "solve x", &output); 30 | if (output) { 31 | printf("%s\n", output); 32 | if (rv) { 33 | free(output); 34 | } else { 35 | printf("Error return.\n"); 36 | } 37 | } 38 | #endif 39 | 40 | exit(0); 41 | } 42 | -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/license.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This Mathomatic include file contains the current license notice. 3 | */ 4 | 5 | /* The following is the Mathomatic license notice, stored in a string. */ 6 | /* It is displayed by the "help copyright" command. */ 7 | char *license_string = 8 | " Mathomatic computer algebra system\n" 9 | " Copyright (C) 1987-2012 George Gesslein II\n\n" 10 | 11 | "This library is free software; you can redistribute it and/or\n" 12 | "modify it under the terms of the GNU Lesser General Public\n" 13 | "License as published by the Free Software Foundation; either\n" 14 | "version 2.1 of the License, or (at your option) any later version.\n\n" 15 | 16 | "This library is distributed in the hope that it will be useful,\n" 17 | "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 18 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" 19 | "Lesser General Public License for more details.\n\n" 20 | 21 | "You should have received a copy of the GNU Lesser General Public\n" 22 | "License along with this library; if not, write to the Free Software\n" 23 | "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n\n" 24 | 25 | "The full text of this license with details is contained in the file \"COPYING\"\n" 26 | "in the Mathomatic source distribution, obtainable from \"www.mathomatic.org\";\n" 27 | "All Mathomatic software and associated files (except for the documentation)\n" 28 | "are published under this license. The Mathomatic documentation is licensed\n" 29 | "under the GNU Free Documentation License (GFDL) version 1.3,\n" 30 | "with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts,\n" 31 | "so it can be easily published, corrected, and translated by anyone.\n\n" 32 | 33 | "Chief author and copyright holder contact information:\n\n" 34 | 35 | " email:\n" 36 | " gesslein@mathomatic.org or\n" 37 | " georgegesslein@gmail.com\n\n" 38 | 39 | " postal address:\n" 40 | " George Gesslein II\n" 41 | " P.O. Box 224\n" 42 | " Lansing, New York 14882-0224\n" 43 | " USA\n\n" 44 | 45 | "Most others who have kindly contributed working code or good ideas to\n" 46 | "Mathomatic are listed in the files \"AUTHORS\" and \"changes.txt\".\n" 47 | "Great merit is given to people that report bugs, in the file \"changes.txt\".\n" 48 | "This means you will also show up in the file \"NEWS\".\n" 49 | "To report a bug, simply email the author, or use the bug reporting facility\n" 50 | "shown with \"help bugs\".\n"; 51 | -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/makefile: -------------------------------------------------------------------------------- 1 | # Makefile for the Mathomatic symbolic math library and its test program. 2 | # See file README.txt for instructions. 3 | 4 | CC=emcc 5 | VERSION=`cat ../VERSION` 6 | CFLAGS=-I../ -DLIBRARY -DVERSION=\"$(VERSION)\" # necessary C compiler flags 7 | 8 | HEADERS=mathomatic.h ../includes.h ../license.h ../standard.h ../am.h \ 9 | ../externs.h ../blt.h ../complex.h ../proto.h ../altproto.h 10 | 11 | MATHOMATIC_OBJECTS += globals.bc am.bc solve.bc help.bc parse.bc cmds.bc simplify.bc \ 12 | factor.bc super.bc unfactor.bc poly.bc diff.bc integrate.bc \ 13 | complex.bc complex_lib.bc list.bc gcd.bc factor_int.bc 14 | 15 | MATHOMATIC_SOURCES=../factor.c ../globals.c ../am.c ../solve.c ../help.c ../parse.c ../cmds.c ../simplify.c ../super.c ../unfactor.c ../poly.c ../diff.c ../integrate.c ../complex.c ../complex_lib.c ../list.c ../gcd.c ../factor_int.c lib.c emscripten.c 16 | 17 | EMSCRIPTEN_ARGS=-s ALLOW_MEMORY_GROWTH=1 -s VERBOSE=1 -s EXPORTED_FUNCTIONS='["_matho_init", "_matho_process", "_matho_parse", "_matho_clear", "_free_mem", "_solve_function", "_init"]' 18 | 19 | .PHONY: math.js 20 | 21 | all: math.js 22 | 23 | math.js: $(MATHOMATIC_SOURCES) 24 | $(CC) $(CFLAGS) $(CPPFLAGS) $(EMSCRIPTEN_ARGS) $^ -o $@ 25 | 26 | clean: 27 | rm -f *.o *.bc *.js 28 | -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/mathomatic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Include file for user programs using the Mathomatic symbolic math library API. 3 | */ 4 | 5 | extern int matho_init(void); /* one-time Mathomatic initialization */ 6 | extern int matho_process(char *input, char **outputp); /* Mathomatic command or expression input */ 7 | extern int matho_parse(char *input, char **outputp); /* Mathomatic expression or equation input */ 8 | extern void matho_clear(void); /* Restart Mathomatic quickly and cleanly, replaces clear_all(). */ 9 | 10 | extern void free_mem(void); /* Free all allocated memory before quitting Mathomatic, if operating system doesn't when done. */ 11 | /* Mathomatic becomes unusable after free_mem(), until matho_init() is called again. */ 12 | /* Only Symbian OS is known to need a call to free_mem() before quitting. */ 13 | 14 | extern int load_rc(int return_true_if_no_file, FILE *ofp); /* Load Mathomatic startup set options from ~/.mathomaticrc, should allow "set save" to work. */ 15 | 16 | extern int cur_equation; /* current equation space number (origin 0) */ 17 | 18 | extern int result_en; /* Equation number of the API's returned result, */ 19 | /* if the result is also stored in an equation space, */ 20 | /* otherwise -1 for no equation number associated with result. */ 21 | /* Set by the last call to matho_parse() or matho_process(). */ 22 | /* Useful if you want to know where the result string is from, */ 23 | /* to act on it with further commands. */ 24 | 25 | extern const char *warning_str; /* optional warning message generated by the last command */ 26 | -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/standard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A standard include file for all math programs written in C. 3 | * 4 | * Copyright (C) 1987-2012 George Gesslein II. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | The chief copyright holder can be contacted at gesslein@mathomatic.org, or 21 | George Gesslein II, P.O. Box 224, Lansing, NY 14882-0224 USA. 22 | 23 | */ 24 | 25 | #ifndef M_EULER 26 | #define M_EULER 0.57721566490153286060651209008 /* Euler-Mascheroni constant (from GSL) */ 27 | #endif 28 | #ifndef M_PI 29 | #define M_PI 3.14159265358979323846 /* pi */ 30 | #endif 31 | #ifndef M_E 32 | #define M_E 2.7182818284590452354 /* e */ 33 | #endif 34 | 35 | #ifndef max 36 | #define max(a, b) (((a) > (b)) ? (a) : (b)) /* return the maximum of two values */ 37 | #endif 38 | #ifndef min 39 | #define min(a, b) (((a) < (b)) ? (a) : (b)) /* return the minimum of two values */ 40 | #endif 41 | 42 | #ifndef INFINITY 43 | #define INFINITY HUGE_VAL /* the floating point, positive infinity constant */ 44 | #endif 45 | 46 | #ifndef isfinite 47 | #define isfinite(d) finite(d) /* true if double d is finite (not infinity nor NaN) */ 48 | #endif 49 | 50 | #ifndef isinf 51 | #if sun /* reconstruct missing isinf() function */ 52 | #define isinf(d) ((fpclass(d) == FP_PINF) - (fpclass(d) == FP_NINF)) 53 | #endif 54 | #endif 55 | 56 | #define ARR_CNT(a) ((int) (sizeof(a)/sizeof(a[0]))) /* returns the number of elements in an array */ 57 | #define CLEAR_ARRAY(a) memset(a, 0, sizeof(a)) /* quickly sets all elements of an array to zero */ 58 | -------------------------------------------------------------------------------- /lib/mathomatic-master/lib/testmain.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains the test/example program 3 | * for the Mathomatic symbolic math library and API. 4 | * Copy or refer to this, 5 | * if you are going to use the Mathomatic code in your other projects. 6 | */ 7 | 8 | #include 9 | #include 10 | #include "mathomatic.h" 11 | 12 | int 13 | main(int argc, char **argv) 14 | { 15 | char *cp; /* character pointer */ 16 | char *ocp; /* output character pointer */ 17 | int rv; /* return value */ 18 | char buf[10000]; /* input buffer */ 19 | char *version; /* version number of the library */ 20 | 21 | printf("Mathomatic library test/example program.\n"); 22 | /* Initialize all global variables and arrays so that Mathomatic will work properly. */ 23 | if (!matho_init()) { /* call this library function exactly once in your program */ 24 | fprintf(stderr, "Not enough memory.\n"); 25 | exit(1); 26 | } 27 | /* Mathomatic is ready for use. */ 28 | if (matho_process((char *) "version", &version)) { 29 | printf("Mathomatic library version %s\n", version); 30 | } else { 31 | fprintf(stderr, "Error getting Symbolic Math Library version number.\n"); 32 | fprintf(stderr, "Mathomatic version command failed.\n"); 33 | exit(1); 34 | } 35 | 36 | /* Uncomment the following if you would like "set save" to save the current session settings for every future session. */ 37 | /* load_rc(true, NULL); */ 38 | 39 | /* This is a standard input/output loop for testing. */ 40 | printf("Press the EOF character (Control-D) to exit.\n"); 41 | for (;;) { 42 | printf("%d-> ", cur_equation + 1); 43 | fflush(stdout); 44 | if ((cp = fgets(buf, sizeof(buf), stdin)) == NULL) 45 | break; 46 | /* Run the Mathomatic symbolic math engine. */ 47 | rv = matho_process(cp, &ocp); 48 | if (warning_str) { 49 | /* Optionally display any warnings (not required, but helpful). */ 50 | printf("Warning: %s\n", warning_str); 51 | } 52 | if (ocp) { 53 | if (rv && result_en >= 0) { 54 | /* Display the result equation number. */ 55 | printf("%d: ", result_en + 1); 56 | } 57 | /* Display the result. */ 58 | printf("Library result string:\n%s\n", ocp); 59 | if (rv) { 60 | free(ocp); 61 | } else { 62 | printf("Error return.\n"); 63 | } 64 | } 65 | } 66 | #if VALGRIND 67 | free(version); 68 | free_mem(); /* reclaim all memory to check for memory leaks with something like valgrind(1) */ 69 | #endif 70 | printf("\n"); 71 | exit(0); 72 | } 73 | -------------------------------------------------------------------------------- /lib/mathomatic-master/license.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This Mathomatic include file contains the current license notice. 3 | */ 4 | 5 | /* The following is the Mathomatic license notice, stored in a string. */ 6 | /* It is displayed by the "help copyright" command. */ 7 | char *license_string = 8 | " Mathomatic computer algebra system\n" 9 | " Copyright (C) 1987-2012 George Gesslein II\n\n" 10 | 11 | "This library is free software; you can redistribute it and/or\n" 12 | "modify it under the terms of the GNU Lesser General Public\n" 13 | "License as published by the Free Software Foundation; either\n" 14 | "version 2.1 of the License, or (at your option) any later version.\n\n" 15 | 16 | "This library is distributed in the hope that it will be useful,\n" 17 | "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 18 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" 19 | "Lesser General Public License for more details.\n\n" 20 | 21 | "You should have received a copy of the GNU Lesser General Public\n" 22 | "License along with this library; if not, write to the Free Software\n" 23 | "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n\n" 24 | 25 | "The full text of this license with details is contained in the file \"COPYING\"\n" 26 | "in the Mathomatic source distribution, obtainable from \"www.mathomatic.org\";\n" 27 | "All Mathomatic software and associated files (except for the documentation)\n" 28 | "are published under this license. The Mathomatic documentation is licensed\n" 29 | "under the GNU Free Documentation License (GFDL) version 1.3,\n" 30 | "with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts,\n" 31 | "so it can be easily published, corrected, and translated by anyone.\n\n" 32 | 33 | "Chief author and copyright holder contact information:\n\n" 34 | 35 | " email:\n" 36 | " gesslein@mathomatic.org or\n" 37 | " georgegesslein@gmail.com\n\n" 38 | 39 | " postal address:\n" 40 | " George Gesslein II\n" 41 | " P.O. Box 224\n" 42 | " Lansing, New York 14882-0224\n" 43 | " USA\n\n" 44 | 45 | "Most others who have kindly contributed working code or good ideas to\n" 46 | "Mathomatic are listed in the files \"AUTHORS\" and \"changes.txt\".\n" 47 | "Great merit is given to people that report bugs, in the file \"changes.txt\".\n" 48 | "This means you will also show up in the file \"NEWS\".\n" 49 | "To report a bug, simply email the author, or use the bug reporting facility\n" 50 | "shown with \"help bugs\".\n"; 51 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/README.txt: -------------------------------------------------------------------------------- 1 | 2 | m4 Mathomatic 3 | ------------- 4 | 5 | The executable named "mathomatic" is the best to run, however if you would 6 | like functions, you need to run "rmath", which runs Mathomatic using GNU m4 7 | as a macro pre-processor, allowing easy entry of standard math functions like 8 | sqrt(x) and sin(x) (no logarithm function yet). "rmath" and "matho" are shell 9 | scripts and are only known to work with GNU software. "rmath" runs "matho" 10 | with a readline wrapper (rlwrap), if available. "matho" runs m4, reading 11 | "functions.m4", and piping the output into Mathomatic. m4 Mathomatic will not 12 | run under MS-Windows, unless m4 is provided by the third-party system CygWin. 13 | 14 | To permanently install these program files along with their man pages on a 15 | Unix-like system, if this is a binary distribution, type: 16 | 17 | sudo ./matho-install 18 | 19 | for trig functions with radian units. For trig with degree units, type: 20 | 21 | sudo ./matho-install-degrees 22 | 23 | These install commands may be repeated, the last one entered is current. This 24 | binary distribution archive must be extracted to a directory and shell must 25 | be running for the installation to work. 26 | 27 | To undo the above commands and uninstall Mathomatic from your system, type: 28 | 29 | sudo ./matho-uninstall 30 | 31 | Installation is *not* necessary to run Mathomatic. 32 | 33 | "sudo make m4install" or "sudo make m4install-degrees" is the proper way to 34 | install these files from the source code distribution. 35 | 36 | Defined m4 macros for functions and constants are listed in the file 37 | "functions.m4" and the rmath man page. All trigonometric functions (sin(x), 38 | tan(x), etc.) are implemented as complex exponentials in m4 Mathomatic, so 39 | they can be simplified, manipulated, and calculated. 40 | 41 | Mathomatic input is filtered by m4, so opening a shell or an editor doesn't 42 | work when running m4 Mathomatic. These are disabled. 43 | 44 | The "quit" and "exit" commands may have some delay. You can use the EOF 45 | character (control-D) to quit instantly, instead. 46 | 47 | The read command currently doesn't use m4, so it can't process functions. The 48 | way to read in text files with functions is to supply the filenames on the 49 | shell command line: 50 | 51 | rmath filenames 52 | 53 | All Mathomatic functions are real number, complex number, and symbolically 54 | capable. 55 | 56 | ---------------------------------------------------------------------------- 57 | 58 | You can turn on color mode with the Mathomatic command: 59 | 60 | set color 61 | 62 | For brighter colors, use: 63 | 64 | set bold color 65 | 66 | typed at the Mathomatic main prompt. For dimmer colors, type: 67 | 68 | set no bold 69 | 70 | To turn off color mode, type: 71 | 72 | set no color 73 | 74 | You can save the current color state (and all other settings) with: 75 | 76 | set save 77 | 78 | so that Mathomatic starts up with your desired color setting every time. 79 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/degrees.m4: -------------------------------------------------------------------------------- 1 | set no prompt 2 | ; Read this into rmath with "rmath degrees.m4" to use trig 3 | ; with arguments in degree units instead of radians. 4 | 5 | ; Standard trigonometry functions as complex exponentials follow. 6 | ; Argument x is in degrees. 7 | m4_define(`sin', `((e**(i*(($1)*pi/180))-e**(-i*(($1)*pi/180)))/(2i))'); sin(x) = sine of x 8 | m4_define(`cos', `((e**(i*(($1)*pi/180))+e**(-i*(($1)*pi/180)))/2)'); cos(x) = cosine of x 9 | m4_define(`tan', `((e**(i*(($1)*pi/180))-e**(-i*(($1)*pi/180)))/(i*(e**(i*(($1)*pi/180))+e**(-i*(($1)*pi/180)))))'); tan(x) = tangent of x 10 | m4_define(`cot', `(i*(e**(i*(($1)*pi/180))+e**(-i*(($1)*pi/180)))/(e**(i*(($1)*pi/180))-e**(-i*(($1)*pi/180))))'); cot(x) = cotangent of x 11 | m4_define(`sec', `(2/(e**(i*(($1)*pi/180))+e**(-i*(($1)*pi/180))))'); sec(x) = secant of x 12 | m4_define(`csc', `(2i/(e**(i*(($1)*pi/180))-e**(-i*(($1)*pi/180))))'); csc(x) = cosecant of x 13 | 14 | echo Trig function arguments are now in degree units only. 15 | set prompt >/dev/null 16 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/file_id.diz: -------------------------------------------------------------------------------- 1 | Mathomatic V16: Symbolic math program 2 | This program can automatically solve, 3 | simplify, compare, and calculate 4 | algebraic equations, etc. Does 5 | calculus operations, too. Free 6 | to distribute. 7 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/functions.m4: -------------------------------------------------------------------------------- 1 | set no prompt 2 | 3 | ; This m4 input file is used by the shell scripts "matho" and "rmath". 4 | ; This defines and enables named math functions in Mathomatic. 5 | ; Most functions here should be real number, complex number, and symbolically capable. 6 | 7 | ; m4 macro definitions for some elementary math functions and constants in Mathomatic. 8 | m4_define(`sqrt', `(($1)**.5)'); function sqrt(x) = square root of x 9 | m4_define(`cbrt', `(($1)**(1/3))'); function cbrt(x) = cube root of x 10 | m4_define(`exp', `(e**($1))'); function exp(x) = e^x 11 | m4_define(`pow', `(($1)**($2))'); function pow(x, y) = x^y 12 | m4_define(`abs', `(|($1)|)'); function abs(x) = absolute value = |x| 13 | m4_define(`sgn', `(($1)/|($1)|)'); signum function sgn(x) = sign of x; sgn(0) fails. 14 | m4_define(`factorial', `(($1)!)'); factorial(x) function = x! 15 | m4_define(`gamma', `((($1)-1)!)'); gamma(x) function = (x-1)! 16 | m4_define(`phi', `((1+5**.5)/2)'); phi = the golden ratio constant, a root of x^2-x-1=0 17 | m4_define(`omega', `(0.5671432904097838729999686622)'); an approximation of the Omega constant 18 | m4_define(`euler', `(0.57721566490153286060651209008)'); the Euler-Mascheroni constant (approximation) 19 | 20 | ;set modulus_mode=2 >/dev/null ; mode 1 or 2 required for floor() and ceil(). 21 | m4_define(`floor', `(($1)-($1)%1)'); floor(x) = floor function, real x -> integer result 22 | m4_define(`ceil', `(($1)+(-($1))%1)'); ceil(x) = ceiling function, real x -> integer result 23 | m4_define(`int', `(($1)//1)'); int(x) = truncate to integer, real x -> integer result 24 | m4_define(`round', `((($1)+|($1)|/($1)/2)//1)'); round(x) = round to nearest integer; beware, round(0) fails. 25 | 26 | ; Standard trigonometry functions as complex exponentials follow. 27 | ; Based on Euler's identity: e^(i*x) = cos(x) + i*sin(x) 28 | ; Argument x is in radians. 29 | m4_define(`sin', `((e**(i*($1))-e**(-i*($1)))/(2i))'); sin(x) = sine of x 30 | m4_define(`cos', `((e**(i*($1))+e**(-i*($1)))/2)'); cos(x) = cosine of x 31 | m4_define(`tan', `((e**(i*($1))-e**(-i*($1)))/(i*(e**(i*($1))+e**(-i*($1)))))'); tan(x) = tangent of x 32 | m4_define(`cot', `(i*(e**(i*($1))+e**(-i*($1)))/(e**(i*($1))-e**(-i*($1))))'); cot(x) = cotangent of x 33 | m4_define(`sec', `(2/(e**(i*($1))+e**(-i*($1))))'); sec(x) = secant of x 34 | m4_define(`csc', `(2i/(e**(i*($1))-e**(-i*($1))))'); csc(x) = cosecant of x 35 | m4_define(`sinc', `(((e**(i*pi*($1))-e**(-i*pi*($1)))/(2i))/(pi*($1)))'); sinc(x) = normalized sinc function 36 | 37 | ; Standard hyperbolic trigonometry functions follow. 38 | ; Available are sinh(x), cosh(x), tanh(x), coth(x), sech(x), and csch(x). 39 | ; These are related to the above trigonometry functions without the "h" appended to the function name. 40 | m4_define(`sinh', `((e**($1)-e**-($1))/2)') 41 | m4_define(`cosh', `((e**($1)+e**-($1))/2)') 42 | m4_define(`tanh', `((e**($1)-e**-($1))/(e**($1)+e**-($1)))') 43 | m4_define(`coth', `((e**($1)+e**-($1))/(e**($1)-e**-($1)))') 44 | m4_define(`sech', `(2/(e**($1)+e**-($1)))') 45 | m4_define(`csch', `(2/(e**($1)-e**-($1)))') 46 | 47 | echo Press the EOF character (Control-D) if you wish to exit Mathomatic. 48 | echo Standard functions are now available, except for logarithms. 49 | set prompt >/dev/null 50 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/gradians.m4: -------------------------------------------------------------------------------- 1 | set no prompt 2 | ; Read this into rmath with "rmath gradians.m4" to use trig 3 | ; with arguments in gradian units instead of radians. 4 | 5 | ; Standard trigonometry functions as complex exponentials follow. 6 | ; Argument x is in gradians. 7 | m4_define(`sin', `((e**(i*(($1)*pi/200))-e**(-i*(($1)*pi/200)))/(2i))'); sin(x) = sine of x 8 | m4_define(`cos', `((e**(i*(($1)*pi/200))+e**(-i*(($1)*pi/200)))/2)'); cos(x) = cosine of x 9 | m4_define(`tan', `((e**(i*(($1)*pi/200))-e**(-i*(($1)*pi/200)))/(i*(e**(i*(($1)*pi/200))+e**(-i*(($1)*pi/200)))))'); tan(x) = tangent of x 10 | m4_define(`cot', `(i*(e**(i*(($1)*pi/200))+e**(-i*(($1)*pi/200)))/(e**(i*(($1)*pi/200))-e**(-i*(($1)*pi/200))))'); cot(x) = cotangent of x 11 | m4_define(`sec', `(2/(e**(i*(($1)*pi/200))+e**(-i*(($1)*pi/200))))'); sec(x) = secant of x 12 | m4_define(`csc', `(2i/(e**(i*(($1)*pi/200))-e**(-i*(($1)*pi/200))))'); csc(x) = cosecant of x 13 | 14 | echo Trig function arguments are now in gradian units only. 15 | set prompt >/dev/null 16 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/matho: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This shell script runs Mathomatic with the GNU m4 macro pre-processor so that 3 | # standard math functions such as sqrt(x), sin(x), etc. may be easily entered. 4 | # Hyperbolic trig has "h" appended, like sinh(x) for hyperbolic sine. 5 | # Only works with GNU software. 6 | # See file "functions.m4" for the complete list of supported functions, 7 | # or type "man rmath" at the shell prompt. 8 | # 9 | # Usage: matho [ input_files ] 10 | 11 | MATHOMATIC="${0}matic" 12 | MFUNCTIONS="${0%/matho}/functions.m4" 13 | MOPTIONS="-ru -s-1" 14 | 15 | if ! m4 --version >/dev/null 16 | then 17 | echo The \"m4\" package is not installed. GNU m4 is required to run m4 Mathomatic. 18 | exit 1 19 | fi 20 | 21 | if [ -x "$MATHOMATIC" ] 22 | then 23 | echo Running "$MATHOMATIC" 24 | m4 -eP -- "$MFUNCTIONS" "$@" - | "$MATHOMATIC" $MOPTIONS 25 | elif [ -x ../mathomatic ] 26 | then 27 | echo Running ../mathomatic 28 | m4 -eP -- "$MFUNCTIONS" "$@" - | ../mathomatic $MOPTIONS 29 | else 30 | echo Running mathomatic 31 | m4 -eP -- "$MFUNCTIONS" "$@" - | mathomatic $MOPTIONS 32 | fi 33 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/matho-install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This shell script installs m4 Mathomatic so that any user can use it. 3 | # If this is a source distribution, you should change directory to its root, 4 | # and compile Mathomatic and "sudo make m4install" to install everything. 5 | # If this is a binary distribution, you should type "sudo ./matho-install" 6 | # from this directory to install the program files and man pages. 7 | 8 | PREFIX=/usr/local 9 | BINDIR=$PREFIX/bin 10 | MANDIR=$PREFIX/share/man/man1 11 | MAN1="mathomatic.1 rmath.1" 12 | MATHOMATIC=mathomatic 13 | if [ ! -x "$MATHOMATIC" ] 14 | then 15 | MATHOMATIC="../$MATHOMATIC" 16 | fi 17 | if [ ! -x "$MATHOMATIC" ] 18 | then 19 | echo mathomatic executable not found. 20 | exit 21 | fi 22 | 23 | echo Installing "$MATHOMATIC" to "$BINDIR" 24 | set -x 25 | mkdir -p $BINDIR 26 | mkdir -p $MANDIR 27 | cp $MAN1 $MANDIR 28 | ln -sf $MANDIR/rmath.1 $MANDIR/matho.1 29 | cp "$MATHOMATIC" functions.m4 matho rmath "$BINDIR" && echo Done! && exit 30 | echo 31 | echo Usage: sudo $0 32 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/matho-install-degrees: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This shell script installs m4 Mathomatic with trig functions that use degree units. 3 | # If this is a source distribution, you should change directory to its root, 4 | # and compile Mathomatic and "sudo make m4install-degrees" to install everything. 5 | # If this is a binary distribution, you should type "sudo ./matho-install-degrees" 6 | # from this directory to install the program files and man pages. 7 | 8 | PREFIX=/usr/local 9 | BINDIR=$PREFIX/bin 10 | MANDIR=$PREFIX/share/man/man1 11 | MAN1="mathomatic.1 rmath.1" 12 | MATHOMATIC=mathomatic 13 | if [ ! -x "$MATHOMATIC" ] 14 | then 15 | MATHOMATIC="../$MATHOMATIC" 16 | fi 17 | if [ ! -x "$MATHOMATIC" ] 18 | then 19 | echo mathomatic executable not found. 20 | exit 21 | fi 22 | 23 | echo Installing "$MATHOMATIC" to "$BINDIR" 24 | set -x 25 | mkdir -p $BINDIR 26 | mkdir -p $MANDIR 27 | cp $MAN1 $MANDIR 28 | ln -sf $MANDIR/rmath.1 $MANDIR/matho.1 29 | cp "$MATHOMATIC" functions.m4 matho rmath "$BINDIR" && 30 | cat degrees.m4 >>"$BINDIR"/functions.m4 && echo Done! && exit 31 | echo 32 | echo Usage: sudo $0 33 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/matho-uninstall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This shell script uninstalls m4 Mathomatic if installed 3 | # with matho-install or matho-install-degrees. 4 | # To uninstall Mathomatic from your computer, 5 | # type "sudo ./matho-uninstall". 6 | 7 | PREFIX=/usr/local 8 | BINDIR=$PREFIX/bin 9 | MANDIR=$PREFIX/share/man/man1 10 | MATHOMATIC=mathomatic 11 | BINFILES="$MATHOMATIC matho rmath functions.m4" 12 | MANFILES="mathomatic.1 rmath.1 matho.1" 13 | 14 | set -x 15 | for file in $BINFILES; 16 | do 17 | rm -f "$BINDIR"/"$file"; 18 | done 19 | for file in $MANFILES; 20 | do 21 | rm -f "$MANDIR"/"$file"; 22 | done 23 | 24 | echo "$MATHOMATIC" uninstalled. 25 | -------------------------------------------------------------------------------- /lib/mathomatic-master/m4/rmath: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This shell script runs m4 Mathomatic (matho) with readline capability. 3 | # Uses rlwrap program, if available, which is a readline front end. 4 | # The rlwrap program may be obtained at 5 | # http://utopia.knoware.nl/~hlub/uck/rlwrap/ 6 | # 7 | # Usage: rmath [ input_files ] 8 | 9 | MATHOPATH="${0%/rmath}/matho" 10 | if [ ! -x "$MATHOPATH" ] 11 | then 12 | MATHOPATH=matho 13 | fi 14 | 15 | if rlwrap true 16 | then 17 | rlwrap -H ~/.matho_history "$MATHOPATH" "$@" 18 | else 19 | echo readline support not loaded because \"rlwrap\" utility was not found. 20 | "$MATHOPATH" "$@" 21 | fi 22 | -------------------------------------------------------------------------------- /lib/mathomatic-master/makehtmlcard.awk: -------------------------------------------------------------------------------- 1 | # Convert TAB delimited Mathomatic help file to HTML. 2 | # See "makehtmlcard.sh". 3 | # Usage awk -F"\t" -f makehtmlcard.awk infile.txt >outfile.html 4 | # Credit goes to John Blommers (http://www.blommers.org) for starting this awk file and for the cheat sheet idea. 5 | 6 | BEGIN { 7 | print "" 8 | print "" 9 | print "" 10 | } 11 | 12 | NR==1 { 13 | print "Mathomatic Quick Reference Card" 14 | print "" 15 | print "" 16 | print "" 17 | print "" "" "" 18 | } 19 | 20 | NR==2 { 21 | print "" 22 | print "" 23 | print "" 24 | print "" 25 | print "" 26 | } 27 | 28 | NR>2 { 29 | print "" 30 | print "" 31 | print "" 32 | print "" 33 | print "" 34 | } 35 | 36 | END { 37 | print "
" "" $1 "" "
" $1 "" $2 "" $3 "
" $1 "" $2 "" $3 "
" 38 | print "
" 39 | # print "

" 40 | print "" 41 | print "Anything enclosed by straight brackets [like this] means it is optional and may be omitted." 42 | print "" 43 | # print "

" 44 | # print "" 45 | # print "To select an equation space and make it the current equation, type the equation number at the main prompt.
" 46 | # print "To solve the current equation, type the variable name at the main prompt or use the solve command." 47 | # print "
" 48 | print "

" 49 | print "" 50 | print "For more information, visit www.mathomatic.org" 51 | print "" 52 | print "" 53 | print "" 54 | } 55 | -------------------------------------------------------------------------------- /lib/mathomatic-master/makehtmlcard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | textfile="$1"quickrefcard.txt 6 | trap "echo Removing \"$textfile\"; rm -f \"$textfile\"" EXIT 7 | echo Creating Mathomatic Quick Reference Card named: "$1"quickrefcard.html 8 | ./mathomatic -e "help table >$textfile" 9 | echo Running awk... 10 | awk -F"\t" -f makehtmlcard.awk "$textfile" >"$1"quickrefcard.html 11 | echo Created "$1"quickrefcard.html 12 | echo Use print to PDF file in Firefox to create the PDF quick reference card. 13 | 14 | # pisa "$1"quickrefcard.html "$1"quickrefcard.pdf 15 | -------------------------------------------------------------------------------- /lib/mathomatic-master/makenews.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Make forward order changelog in "NEWS" file from changes.txt: 3 | set -e 4 | (echo; echo "The latest version of Mathomatic is `cat VERSION`, here are the changes:"; tac -r -s "^Mathomatic version.*$" changes.txt) | head -n -9 >NEWS.tmp 5 | echo >>NEWS.tmp 6 | echo ---------------------------------------------------------------------- >>NEWS.tmp 7 | echo End of this version history of the Mathomatic computer algebra system. >>NEWS.tmp 8 | echo Current as of `date '+%D'` \(`date '+%F'`\). >>NEWS.tmp 9 | echo The latest changes are at the beginning of this file. >>NEWS.tmp 10 | echo This file is always available up-to-date at http://mathomatic.org/NEWS >>NEWS.tmp 11 | echo Alternatively, you can get it at http://mathomatic.orgserve.de/NEWS >>NEWS.tmp 12 | echo Do not edit this file, edit the end of changes.txt instead. >>NEWS.tmp 13 | echo Written and maintained by George Gesslein II. >>NEWS.tmp 14 | mv NEWS.tmp NEWS 15 | -------------------------------------------------------------------------------- /lib/mathomatic-master/makepdfsheet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | htmlfile="$1"quickref.html 4 | pdffile=quickref.pdf 5 | 6 | echo Generating the Mathomatic Quick Reference Sheet PDF file... 7 | 8 | echo "" >"$htmlfile" 9 | echo '' >>"$htmlfile" 10 | echo '' >>"$htmlfile" 11 | echo 'Mathomatic Quick Reference Sheet' >>"$htmlfile" 12 | echo '' >>"$htmlfile" 13 | echo '' >>"$htmlfile" 14 | echo '

' >>"$htmlfile"
15 | 
16 | ./mathomatic -e "set html all" "help all main equations constants >>$htmlfile" || (rm "$htmlfile"; exit 1)
17 | 
18 | echo >>"$htmlfile"
19 | echo 'For more information, visit www.mathomatic.org' >>"$htmlfile"
20 | 
21 | echo '
' >>"$htmlfile" 22 | echo '' >>"$htmlfile" 23 | echo '' >>"$htmlfile" 24 | 25 | if htmldoc --webpage --format pdf --linkstyle plain --no-links -f "$pdffile" "$htmlfile" 26 | then 27 | echo "$pdffile" successfully created. 28 | rm "$htmlfile" 29 | exit 0 30 | else 31 | rm "$htmlfile" 32 | exit 1 33 | fi 34 | -------------------------------------------------------------------------------- /lib/mathomatic-master/menu/README.txt: -------------------------------------------------------------------------------- 1 | 2 | The Debian Menu System provides a unified menu interface for both text and 3 | X Windows oriented programs, without having to configure each window manager. 4 | 5 | These are the Debian Menu System files for Mathomatic. 6 | "mathomatic" and "mathomatic-primes" go in "/usr/share/menu". 7 | They should be put there by the Debian mathomatic package. 8 | -------------------------------------------------------------------------------- /lib/mathomatic-master/menu/mathomatic: -------------------------------------------------------------------------------- 1 | ?package(mathomatic):\ 2 | needs="text"\ 3 | hints="Mathomatic"\ 4 | section="Applications/Science/Mathematics"\ 5 | title="Mathomatic"\ 6 | command="/usr/bin/mathomatic"\ 7 | icon="/usr/share/pixmaps/mathomatic.xpm" 8 | -------------------------------------------------------------------------------- /lib/mathomatic-master/menu/mathomatic-primes: -------------------------------------------------------------------------------- 1 | ?package(mathomatic-primes):\ 2 | needs="text"\ 3 | hints="Mathomatic"\ 4 | section="Applications/Science/Mathematics"\ 5 | title="Prime Numbers (Mathomatic)"\ 6 | command="/usr/bin/matho-primes"\ 7 | icon="/usr/share/pixmaps/mathomatic.xpm" 8 | -------------------------------------------------------------------------------- /lib/mathomatic-master/misc/README.txt: -------------------------------------------------------------------------------- 1 | 2 | misc/README.txt 3 | --------------- 4 | 5 | Useful stuff that doesn't belong anywhere else goes in this directory: 6 | 7 | ideas.txt - The Mathomatic todo and idea list. 8 | 9 | known_bugs.txt - Current list of known Mathomatic bugs. 10 | Normally bugs are fixed immediately if they can be. 11 | 12 | *.in - Some Mathomatic input files that Mathomatic has trouble with. 13 | -------------------------------------------------------------------------------- /lib/mathomatic-master/misc/identities.in: -------------------------------------------------------------------------------- 1 | ; Mathomatic fails to completely simplify the following 3 identities with the simplify command. 2 | ; Solving for x or 0 verifies they are identities. 3 | 4 | ; (cos(4x)+cos(3x)+cos(2x))/(sin(4x)+sin(3x)+sin(2x))=cot(3x) 5 | ((((e^(4*i*x)) + (e^(-4*i*x)))/2) + (((e^(3*i*x)) + (e^(-3*i*x)))/2) + (((e^(2*i*x)) + (e^(-2*i*x)))/2))/((((e^(4*i*x)) - (e^(-4*i*x)))/(2*i)) + (((e^(3*i*x)) - (e^(-3*i*x)))/(2*i)) + (((e^(2*i*x)) - (e^(-2*i*x)))/(2*i))) = i*((e^(3*i*x)) + (e^(-3*i*x)))/((e^(3*i*x)) - (e^(-3*i*x))) 6 | ((e^x) - 1)/((e^(x/2)) + 1) = (e^(x/2)) - 1 7 | ((4^x) - 1)/((4^(x/2)) + 1) = (4^(x/2)) - 1 8 | simplify all 9 | copy all 10 | 11 | :solve 1-3 x 12 | solve 4-6 verifiable 0 13 | -------------------------------------------------------------------------------- /lib/mathomatic-master/misc/john.in: -------------------------------------------------------------------------------- 1 | ; A hard equation for improving Mathomatic. 2 | ; Shows that the simplify command is not perfect. 3 | P = (c - (r/((1 + f)^(t + 1))))*(1 - (1/((1 + f)^t)))/((1 + f)*f) 4 | -------------------------------------------------------------------------------- /lib/mathomatic-master/misc/known_bugs.txt: -------------------------------------------------------------------------------- 1 | Known bugs in Mathomatic 2 | ------------------------ 3 | 4 | Compiling with Clang or Xcode 4 and up, which uses LLVM: 5 | This is actually an optimization bug in the LLVM backend used by Clang 6 | and the Apple Xcode IDE. When dealing with memmove(3), LLVM optimization 7 | introduces bugs and program hangs. So when you are compiling Mathomatic with 8 | Clang or the latest Xcode, please be sure and compile with no optimization 9 | options or the "-O0" option (which disables all optimization), otherwise the 10 | regression tests and entering things like y=32^.5 and then simplifying will 11 | cause Mathomatic to hang forever. memmove(3) is used throughout Mathomatic. 12 | So when compiling Mathomatic with Clang or Xcode, always disable 13 | optimization, it will run all the tests in 1 second and is not noticeably 14 | slower. Mathomatic will hang during "make test" if compiled with optimization 15 | enabled when using LLVM as a backend. 16 | 17 | 17! bug: Fixed. 18 | "factor number 17!" and higher don't work because the maximum safely 19 | representable integer for double precision floating point is 15 digits long. 20 | This is not a bug. 21 | 22 | Absolute values and complex number problems: 23 | Absolute values and the imaginary unit (i) do not always remain intact 24 | after being manipulated with the standard rules of algebra. For example, 1/i 25 | correctly simplifies to -i, changing the sign of the result. So the fraction 26 | command and other possible operations may give wrong results due to differing 27 | sign after manipulations. The simplify command should always work, but it is 28 | not guaranteed for these. 29 | The solve command may have a problem too, but using the verify option 30 | should check that the result of solving absolute value or complex number 31 | equations is 100% correct. Don't forget though that the absolute value |x| 32 | definition in Mathomatic is ((x^2)^.5), which is different from the standard 33 | absolute value function in the complex realm, which would always return a 34 | positive and real distance on a complex Cartesian graph. Mathomatic is taking 35 | shortcuts with its definition and will not always return a real value result 36 | if any of the absolute value arguments are imaginary. It works perfectly with 37 | real value arguments. 38 | 39 | Solving modulus equations: 40 | May result in garbage, due to incomplete modulus operator solving code. 41 | I could just disable it, but I choose to research it at a later time, because 42 | it does sometimes work nicely. Again, the "solve verify" option tells if you 43 | should trust the results. 44 | -------------------------------------------------------------------------------- /lib/mathomatic-master/misc/linear4.in: -------------------------------------------------------------------------------- 1 | ; Combine 4 simultaneous linear equations with 4 unknowns (x1, x2, x3, x4). 2 | ; Solve for all 4 unknowns using the eliminate, solve, and simplify commands. 3 | 4 | ; Keep this to test simplification in Mathomatic when recursion is added to the GCD routines. 5 | ; Currently Mathomatic is unable to completely simplify all of the resulting equations. 6 | ; By using the simplify command immediately after some eliminate commands, 7 | ; equation number 4 solved for x4 is completely simplified. 8 | ; 9 | ; The rest may be easily simplifiable when polynomial GCD works recursively, 10 | ; so that it is multivariate. 11 | 12 | clear all ; restarts Mathomatic 13 | ; The next four lines enter all of the equations into Mathomatic 14 | b1 = a11*x1+a12*x2+a13*x3+a14*x4 15 | b2 = a21*x1+a22*x2+a23*x3+a24*x4 16 | b3 = a31*x1+a32*x2+a33*x3+a34*x4 17 | b4 = a41*x1+a42*x2+a43*x3+a44*x4 18 | 2 ; select equation #2 19 | eliminate x1 ; eliminate x1 variable from eq#2 20 | 3 ; select equation #3 21 | eliminate x1 x2 ; eliminate x1 x2 from eq#3 22 | 4 ; select equation #4 23 | eliminate x1 x2 x3 ; eliminate x1 x2 x3 from eq#4 24 | simplify all 25 | solve verifiable x4 ; solve for x4 26 | 3 ; select equation #3 27 | eliminate x4 using 4; find x3 28 | 2 ; select equation #2 29 | eliminate x4 using 4, x3 using 3; find x2 30 | 1 ; select equation #1 31 | eliminate x4 using 4, x3 using 3, x2 using 2; find x1 32 | simplify all 33 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/README.txt: -------------------------------------------------------------------------------- 1 | 2 | Mathomatic Prime Number Tools 3 | ----------------------------- 4 | 5 | This directory contains some small, command-line, integer math utilities 6 | written in C and Python. To compile, test, and install these utilities, type 7 | the following commands at the Unix shell prompt: 8 | 9 | make 10 | make test 11 | sudo make install 12 | 13 | This will install: 14 | 15 | matho-primes - quickly generate consecutive prime numbers 16 | primorial - calculate large primorials 17 | matho-mult - multiply large integers 18 | matho-pascal - output Pascal's triangle 19 | matho-sum - sum large integers 20 | matho-sumsq - output the minimum sum of the squares of integers 21 | 22 | These stand-alone utilities come with Mathomatic and they don't need to be 23 | installed to work properly. See the website www.mathomatic.org to get the 24 | latest version. 25 | 26 | The Python program "primorial" is included in this directory for calculating 27 | large primorials from matho-primes. A primorial is the product of all primes 28 | up to the given number. To generate a list of all unique primorials from 2 to 29 | 97, type the following at the Unix shell after installing matho-primes: 30 | 31 | primorial `matho-primes 2 97` 32 | 33 | Example that calculates the number of primes less than or equal to 1,000,000: 34 | 35 | matho-primes 0 1000000 | wc -w 36 | 37 | The result should be 78498. 38 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/lsqrt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tested long integer square root function. 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | #define true 1 9 | #define false 0 10 | 11 | #if DEBUG 12 | /* 13 | * Return true if x is the truncated integer square root of y. 14 | */ 15 | int 16 | verify_lsqrt(long y, long x) 17 | { 18 | if ((long long) x * x > y || ((long long) x + 1) * ((long long) x + 1) <= y) { 19 | return false; 20 | } 21 | return true; 22 | } 23 | #endif 24 | 25 | /* 26 | * Returns the truncated integer square root of y using 27 | * the Babylonian iterative approximation method, derived from Newton's method. 28 | * Returns -1 on error. 29 | * 30 | * This lsqrt() function was written by George Gesslein II 31 | * and is placed in the public domain. 32 | */ 33 | long 34 | lsqrt(long y) 35 | { 36 | long x_old, x_new; 37 | long testy; 38 | int nbits; 39 | int i; 40 | 41 | if (y <= 0) { 42 | if (y != 0) { 43 | #if DEBUG 44 | fprintf(stderr, "Domain error in %s().\n", __func__); 45 | #endif 46 | return -1L; 47 | } 48 | return 0L; 49 | } 50 | /* select a good starting value using binary logarithms: */ 51 | nbits = (sizeof(y) * 8) - 1; /* subtract 1 for sign bit */ 52 | for (i = 4, testy = 16L;; i += 2, testy <<= 2L) { 53 | if (i >= nbits || y <= testy) { 54 | x_old = (1L << (i / 2L)); /* x_old = sqrt(testy) */ 55 | break; 56 | } 57 | } 58 | /* x_old >= sqrt(y) */ 59 | /* use the Babylonian method to arrive at the integer square root: */ 60 | for (;;) { 61 | x_new = (y / x_old + x_old) / 2L; 62 | if (x_old <= x_new) 63 | break; 64 | x_old = x_new; 65 | } 66 | #if DEBUG 67 | if (!verify_lsqrt(y, x_old)) { 68 | fprintf(stderr, "Verification error in %s().\n", __func__); 69 | return -1L; 70 | } 71 | #endif 72 | return x_old; 73 | } 74 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/makefile: -------------------------------------------------------------------------------- 1 | # Makefile for compiling and installing the Mathomatic Prime Number Tools 2 | # under a Unix-like system. 3 | # See file README.txt for instructions. 4 | # 5 | # If make fails due to incomplete "long double" support, try: 6 | # CFLAGS="-O3 -DUSE_DOUBLES" make 7 | 8 | 9 | SHELL = /bin/sh # from http://www.gnu.org/prep/standards/ 10 | CC ?= gcc # C compiler to use 11 | INSTALL ?= install # installer to use 12 | INSTALL_PROGRAM ?= $(INSTALL) # Command to install executable program files. 13 | INSTALL_DATA ?= $(INSTALL) -m 0644 # Command to install data files. 14 | 15 | CC_OPTIMIZE = -O3 # Default C compiler optimization flags that are safe. 16 | #CC_OPTIMIZE += -ffast-math -fomit-frame-pointer # Extra optimize for speed, not functional under Mac OS X. 17 | 18 | OPTFLAGS ?= $(CC_OPTIMIZE) -Wall -Wshadow -Wno-char-subscripts # gcc specific flags; change for other C compilers. 19 | CFLAGS ?= $(OPTFLAGS) 20 | #CFLAGS += -std=gnu99 # Uses the Gnu99 standard; may require setting this on gcc command line if using an older compiler. 21 | LDLIBS += -lm 22 | 23 | # Install directories follow, installs everything in $(DESTDIR)/usr/local by default. 24 | prefix ?= /usr/local 25 | bindir ?= $(prefix)/bin 26 | mandir ?= $(prefix)/share/man 27 | 28 | # The executables to create: 29 | TARGETS = matho-primes matho-pascal matho-sumsq 30 | # The Python scripts to install: 31 | PYTHON_SCRIPTS = primorial matho-mult matho-sum 32 | # The executables to install: 33 | EXECUTABLES = $(TARGETS) $(PYTHON_SCRIPTS) 34 | # The man pages to install: 35 | MAN1 = matho-primes.1 matho-pascal.1 matho-sumsq.1 primorial.1 matho-mult.1 matho-sum.1 36 | 37 | all static: $(TARGETS) # make these by default 38 | @echo 39 | @echo Prime Number Tools successfully created. 40 | 41 | # Strip the binaries of their symbol tables. Makes smaller executables, but debugging becomes impossible. 42 | strip: $(TARGETS) 43 | strip $(TARGETS) 44 | 45 | matho-sumsq: matho-sumsq.o lsqrt.o 46 | $(CC) $(CFLAGS) $(LDFLAGS) $+ $(LDLIBS) -o $@ 47 | 48 | # To compile the Mathomatic Prime Number Tools as stand-alone executables 49 | # that have no shared library dependencies, type "make flush static". 50 | static: LDFLAGS += -static 51 | 52 | test: 53 | @echo Testing basic functionality of matho-primes: 54 | time -p ./matho-primes 10000000000000 10000000300000 twin >test.out && diff -u --strip-trailing-cr twins.out test.out 55 | @rm test.out 56 | @echo Small primes test passed. 57 | @echo 58 | 59 | # Same as "make test", except doesn't run the time command. 60 | check: 61 | @echo Testing basic functionality of matho-primes: 62 | ./matho-primes 10000000000000 10000000300000 twin >test.out && diff -u --strip-trailing-cr twins.out test.out 63 | @rm test.out 64 | @echo Small primes test passed. 65 | @echo 66 | 67 | bigtest: 68 | @echo Testing that long doubles are fully functional in matho-primes: 69 | time -p ./matho-primes 100000000000000000 100000000000300000 twin >bigtest.out && diff -u --strip-trailing-cr bigtwins.out bigtest.out 70 | @rm bigtest.out 71 | @echo Big primes test passed. 72 | @echo 73 | 74 | # Same as "make bigtest", except doesn't run the time command. 75 | bigcheck: 76 | @echo Testing that long doubles are fully functional in matho-primes: 77 | ./matho-primes 100000000000000000 100000000000300000 twin >bigtest.out && diff -u --strip-trailing-cr bigtwins.out bigtest.out 78 | @rm bigtest.out 79 | @echo Big primes test passed. 80 | @echo 81 | 82 | install: 83 | $(INSTALL) -d $(DESTDIR)$(bindir) 84 | $(INSTALL) -d $(DESTDIR)$(mandir)/man1 85 | $(INSTALL_PROGRAM) $(EXECUTABLES) $(DESTDIR)$(bindir) 86 | $(INSTALL_DATA) $(MAN1) $(DESTDIR)$(mandir)/man1 87 | @echo 88 | @echo The Prime Number Tools are installed. 89 | 90 | uninstall: 91 | cd $(DESTDIR)$(bindir) && rm -f $(EXECUTABLES) 92 | cd $(DESTDIR)$(mandir)/man1 && rm -f $(MAN1) 93 | @echo 94 | @echo Prime Number Tools uninstall completed. 95 | 96 | clean: 97 | rm -f *.o *.pyc *.pyo 98 | rm -f test.out bigtest.out 99 | 100 | flush distclean maintainer-clean: clean 101 | rm -f *.a 102 | rm -f $(TARGETS) 103 | rm -f *.exe 104 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/matho-mult: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Python program to multiply many large integers separated by spaces or newlines. 4 | # The integers to multiply may be entered on the command-line or into standard input. 5 | 6 | # Used by "primorial" with "matho-primes" to calculate large primorials. 7 | # A primorial is the product of all primes up to a given number. 8 | 9 | import string 10 | import sys 11 | 12 | prod = 1 # initialize product and make it an integer 13 | args = sys.argv[1:] 14 | if (args == []): 15 | # read stdin if no command line args 16 | while True: 17 | try: 18 | input_line = raw_input() 19 | except: 20 | break; 21 | for s in string.split(input_line): 22 | prod *= int(s) 23 | else: 24 | # multiply together the command-line args 25 | for arg in args: 26 | prod *= int(arg) 27 | print prod 28 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/matho-mult.1: -------------------------------------------------------------------------------- 1 | .TH MATHO-MULT 1 "" "Mathomatic" "Mathomatic Utilities" 2 | 3 | .SH NAME 4 | matho-mult \- multiply large integers 5 | 6 | .SH SYNOPSIS 7 | .B matho-mult 8 | [integers] 9 | 10 | .SH DESCRIPTION 11 | This command-line utility is optionally part of the 12 | .BR mathomatic (1) 13 | package. 14 | It uses Python to multiply many large integers separated by spaces or newlines. 15 | The size of the integers is only limited by the available memory of the computer. 16 | The single integer result is output to standard output, followed by a newline. 17 | 18 | The integers to multiply may be specified on the command line or 19 | read from standard input. 20 | 21 | .SH AUTHOR 22 | George Gesslein II (gesslein@mathomatic.org) 23 | at "http://www.mathomatic.org". 24 | 25 | .SH "REPORTING BUGS" 26 | If you find a bug, please report it to the author 27 | or at "https://launchpad.net/mathomatic". 28 | 29 | .SH "SEE ALSO" 30 | .BR mathomatic (1), 31 | .BR primorial (1), 32 | .BR matho-sum (1) 33 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/matho-pascal.1: -------------------------------------------------------------------------------- 1 | .TH MATHO-PASCAL 1 "" "Mathomatic" "Mathomatic Utilities" 2 | 3 | .SH NAME 4 | matho-pascal \- display Pascal's triangle 5 | 6 | .SH SYNOPSIS 7 | .B matho-pascal 8 | [number-of-lines] 9 | 10 | .SH DESCRIPTION 11 | This command-line utility is optionally part of the 12 | .BR mathomatic (1) 13 | package. 14 | It calculates up to 1000 lines of Pascal's triangle using floating point arithmetic, 15 | dumping the lines to standard output. 16 | The default is to center one screen full. 17 | 18 | Every number inside Pascal's triangle is the sum of the two numbers 19 | immediately above it. 20 | 21 | Each line of Pascal's triangle is the same as the binomial coefficients 22 | for a given power. 23 | 24 | The sum of all numbers in each line of Pascal's triangle is a power of 2. 25 | 26 | .SH AUTHOR 27 | George Gesslein II (gesslein@mathomatic.org) 28 | at "http://www.mathomatic.org". 29 | 30 | .SH "REPORTING BUGS" 31 | If you find a bug, please report it to the author 32 | or at "https://launchpad.net/mathomatic". 33 | 34 | .SH "SEE ALSO" 35 | .BR mathomatic (1), 36 | .BR matho-primes (1), 37 | .BR matho-sumsq (1) 38 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/matho-primes.1: -------------------------------------------------------------------------------- 1 | .TH MATHO-PRIMES 1 "" "Mathomatic" "Mathomatic Utilities" 2 | 3 | .SH NAME 4 | matho-primes \- generate consecutive prime numbers 5 | 6 | .SH SYNOPSIS 7 | .B matho-primes 8 | [start [stop] or "all"] ["twin"] ["pal" [base]] 9 | .br 10 | .B matho-primes 11 | [\-htuv] [\-c count] [\-m number] [\-p base] [start [stop]] 12 | 13 | .SH DESCRIPTION 14 | This command-line utility is optionally part of the 15 | .BR mathomatic (1) 16 | package. 17 | It quickly computes any number of consecutive prime numbers 18 | using a windowing, memory efficient 19 | sieve of Eratosthenes algorithm, dumping them to standard output. 20 | They are displayed one prime per line in ascending order, 21 | unless the "twin" option is specified, 22 | which displays only twin primes, two primes per line. 23 | 24 | Generates up to 18 decimal digit primes, 25 | or whatever is the number of digits of precision for a floating point 26 | .B long double 27 | in the C compiler used to compile this utility. 28 | Note that this utility might be compiled to use only double precision floating point, 29 | if long double precision is not fully supported by the C compiler or hardware, 30 | allowing at most 15 decimal digit primes in that case. 31 | 32 | Ways to verify that this utility is working are to pipe the output into the Unix "factor" utility, 33 | or compare the output with the BSD Games "primes" utility, using the supplied shell script: 34 | .B examples/testprimes. 35 | 36 | All numbers displayed by this utility 37 | are decimal (base 10) prime numbers. 38 | A prime number is an integer that cannot be factored. 39 | 40 | A range may be 41 | specified on the command line, otherwise the starting number and 42 | the number of primes to output is prompted for. 43 | The range is 44 | .B start 45 | to 46 | .B stop 47 | inclusive, and 48 | .B stop 49 | must 50 | be greater than or equal to 51 | .B start. 52 | 53 | If the 54 | .B \-c 55 | option is specified, the number of lines of primes displayed is limited to the 56 | decimal count that follows this option. 57 | 58 | If the 59 | .B \-t 60 | or "twin" option is specified on the command line, 61 | only 62 | .B twin primes 63 | will be displayed. 64 | Twin primes are two primes that differ in value by 2. 65 | Each twin pair is displayed together on the same line separated by a space character. 66 | 67 | If the 68 | .B \-p 69 | or "pal" option is specified on the command line, 70 | only 71 | .B palindromic primes 72 | are displayed. 73 | Palindromes are symmetrical, they read exactly the same forward and backward. 74 | The palindromic number 75 | .B base 76 | may be specified, the default is base 10. 77 | The 78 | .B base 79 | can be any integer greater than 1. 80 | Primes are always displayed in decimal (base 10). 81 | 82 | The version number and 83 | short help on the allowed command-line parameters and usage information 84 | are displayed when given the 85 | .B \-h 86 | option. 87 | 88 | With the 89 | .B \-u 90 | option, all output (standard output and standard error output) 91 | is set to be unbuffered, making all output happen immediately, 92 | instead of when the output buffer is full or when the program terminates 93 | or waits for input. 94 | 95 | The 96 | .B \-m 97 | option changes the memory size of the prime number sieve window. 98 | It is followed by a decimal, floating point number which is a multiplier 99 | of the default window size (2 megabytes). 100 | It is possible that changing the memory size may speed up the total run time a bit; 101 | otherwise there is no reason to use this option, and its use is not recommended. 102 | 103 | The 104 | .B \-v 105 | option simply displays the program name and version number, and then exits successfully. 106 | 107 | .SH AUTHOR 108 | George Gesslein II (gesslein@mathomatic.org) 109 | at "http://www.mathomatic.org". 110 | 111 | .SH "REPORTING BUGS" 112 | If you find a bug, please report it to the author 113 | or at "https://launchpad.net/mathomatic". 114 | 115 | .SH "SEE ALSO" 116 | .BR rmath (1), 117 | .BR mathomatic (1), 118 | .BR primorial (1), 119 | .BR matho-mult (1), 120 | .BR matho-sum (1), 121 | .BR matho-pascal (1), 122 | .BR matho-sumsq (1) 123 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/matho-sum: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Python program to sum many large integers separated by spaces or newlines. 4 | # The integers to sum may be entered on the command-line or into standard input. 5 | 6 | import string 7 | import sys 8 | 9 | sum = 0 # initialize sum and make it an integer 10 | args = sys.argv[1:] 11 | if (args == []): 12 | # read stdin if no command line args 13 | while True: 14 | try: 15 | input_line = raw_input() 16 | except: 17 | break; 18 | for s in string.split(input_line): 19 | sum += int(s) 20 | else: 21 | # sum together the command-line args 22 | for arg in args: 23 | sum += int(arg) 24 | print sum 25 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/matho-sum.1: -------------------------------------------------------------------------------- 1 | .TH MATHO-SUM 1 "" "Mathomatic" "Mathomatic Utilities" 2 | 3 | .SH NAME 4 | matho-sum \- sum large integers 5 | 6 | .SH SYNOPSIS 7 | .B matho-sum 8 | [integers] 9 | 10 | .SH DESCRIPTION 11 | This command-line utility is optionally part of the 12 | .BR mathomatic (1) 13 | package. 14 | It uses Python to sum many large integers separated by spaces or newlines. 15 | The size of the integers is only limited by the available memory of the computer. 16 | The single integer result is output to standard output, followed by a newline. 17 | 18 | The integers to sum may be specified on the command line or 19 | read from standard input. 20 | 21 | .SH AUTHOR 22 | George Gesslein II (gesslein@mathomatic.org) 23 | at "http://www.mathomatic.org". 24 | 25 | .SH "REPORTING BUGS" 26 | If you find a bug, please report it to the author 27 | or at "https://launchpad.net/mathomatic". 28 | 29 | .SH "SEE ALSO" 30 | .BR mathomatic (1), 31 | .BR primorial (1), 32 | .BR matho-mult (1) 33 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/matho-sumsq.1: -------------------------------------------------------------------------------- 1 | .TH MATHO-SUMSQ 1 "" "Mathomatic" "Mathomatic Utilities" 2 | 3 | .SH NAME 4 | matho-sumsq \- Find the minimum sum of the squares for integers 5 | 6 | .SH SYNOPSIS 7 | .B matho-sumsq 8 | .RI [ numbers ] 9 | 10 | .SH DESCRIPTION 11 | This command-line utility is optionally part of the 12 | .BR mathomatic (1) 13 | package. 14 | It finds the minimum number of positive integers that when squared 15 | and added together, equal the given number. There is a proof that no more 16 | than 4 squares summed together are required to represent any positive 17 | integer. 18 | 19 | The command-line may contain positive integers to find the minimum squares of, 20 | they must be less than 2147483648 (2^31) on 32-bit systems or 21 | less than 9223372036854775808 (2^63) on 64-bit systems. 22 | If "+" is appended to the given number, 23 | the program counts up from the given number. 24 | If the minimum number of squares is 2, 25 | this program displays all possible combinations with 2 squares for the given number, 26 | otherwise it just displays the first combination it finds. 27 | 28 | If no command-line arguments are given, the programs reads the numbers from 29 | standard input. 30 | 31 | .SH AUTHOR 32 | George Gesslein II (gesslein@mathomatic.org) 33 | at "http://www.mathomatic.org". 34 | 35 | .SH "REPORTING BUGS" 36 | If you find a bug, please report it to the author 37 | or at "https://launchpad.net/mathomatic". 38 | 39 | .SH "SEE ALSO" 40 | .BR mathomatic (1), 41 | .BR matho-pascal (1), 42 | .BR matho-primes (1) 43 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/primorial: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This is a Python program to display large primorials. 4 | # A primorial is the product of all primes up to the given number. 5 | # Uses the programs "matho-primes" and "matho-mult" as follows: 6 | # primorial 1000 7 | # runs: 8 | # matho-primes 0 1000 | matho-mult 9 | # 10 | # For fun, try: 11 | # primorial `matho-primes 2 97` 12 | # 13 | # to display all unique primorials from 2 to 97. 14 | 15 | import os 16 | import sys 17 | 18 | def usage(ev): 19 | print "This program calculates large primorials." 20 | print 21 | print "Usage: %s integers" % os.path.basename(sys.argv[0]) 22 | print 23 | print "A primorial is the product of all primes up to the given number." 24 | sys.exit(ev) 25 | 26 | def output_primorial(arg): 27 | sys.stdout.write(arg + "# = ") 28 | sys.stdout.flush() 29 | if (os.system("matho-primes 0 " + arg + " | matho-mult") != 0): 30 | sys.exit(1) 31 | 32 | args = sys.argv[1:] 33 | if (args == []): 34 | usage(2) 35 | else: 36 | for arg in args: 37 | try: 38 | if (int(arg) < 1): 39 | print >>sys.stderr, "Number too small." 40 | sys.exit(1) 41 | except: 42 | print >>sys.stderr, "Positive integer required." 43 | usage(1) 44 | output_primorial(arg) 45 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/primorial.1: -------------------------------------------------------------------------------- 1 | .TH PRIMORIAL 1 "" "Mathomatic" "Mathomatic Utilities" 2 | 3 | .SH NAME 4 | primorial \- calculate large primorials 5 | 6 | .SH SYNOPSIS 7 | .B primorial 8 | integers 9 | 10 | .SH DESCRIPTION 11 | This command-line utility is optionally part of the 12 | .BR mathomatic (1) 13 | package. 14 | It uses Python and 15 | .BR matho-primes (1) 16 | and 17 | .BR matho-mult (1) 18 | to calculate and display large primorials. 19 | 20 | A primorial is the product of all primes up to the given integer. 21 | The integers to show the primorials of are given on the command line. 22 | 23 | The calculated primorials are output to standard output. 24 | The size is limited by the amount of computer memory available. 25 | 26 | .SH AUTHOR 27 | George Gesslein II (gesslein@mathomatic.org) 28 | at "http://www.mathomatic.org". 29 | 30 | .SH "REPORTING BUGS" 31 | If you find a bug, please report it to the author 32 | or at "https://launchpad.net/mathomatic". 33 | 34 | .SH "SEE ALSO" 35 | .BR mathomatic (1), 36 | .BR matho-mult (1), 37 | .BR matho-primes (1) 38 | -------------------------------------------------------------------------------- /lib/mathomatic-master/primes/t: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Shell script to test the Mathomatic prime number tools. 3 | 4 | set -e 5 | set -u 6 | 7 | trap "rm -f test.out bigtest.out" EXIT 8 | 9 | make -j2 check bigcheck 10 | 11 | echo Testing matho-pascal... 12 | ./matho-pascal >/dev/null 13 | 14 | echo Testing matho-sumsq... 15 | ./matho-sumsq 12146807 50000000 >/dev/null 16 | 17 | echo Prime number tools tests successful. 18 | -------------------------------------------------------------------------------- /lib/mathomatic-master/standard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A standard include file for all math programs written in C. 3 | * 4 | * Copyright (C) 1987-2012 George Gesslein II. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | The chief copyright holder can be contacted at gesslein@mathomatic.org, or 21 | George Gesslein II, P.O. Box 224, Lansing, NY 14882-0224 USA. 22 | 23 | */ 24 | 25 | #ifndef M_EULER 26 | #define M_EULER 0.57721566490153286060651209008 /* Euler-Mascheroni constant (from GSL) */ 27 | #endif 28 | #ifndef M_PI 29 | #define M_PI 3.14159265358979323846 /* pi */ 30 | #endif 31 | #ifndef M_E 32 | #define M_E 2.7182818284590452354 /* e */ 33 | #endif 34 | 35 | #ifndef max 36 | #define max(a, b) (((a) > (b)) ? (a) : (b)) /* return the maximum of two values */ 37 | #endif 38 | #ifndef min 39 | #define min(a, b) (((a) < (b)) ? (a) : (b)) /* return the minimum of two values */ 40 | #endif 41 | 42 | #ifndef INFINITY 43 | #define INFINITY HUGE_VAL /* the floating point, positive infinity constant */ 44 | #endif 45 | 46 | #ifndef isfinite 47 | #define isfinite(d) finite(d) /* true if double d is finite (not infinity nor NaN) */ 48 | #endif 49 | 50 | #ifndef isinf 51 | #if sun /* reconstruct missing isinf() function */ 52 | #define isinf(d) ((fpclass(d) == FP_PINF) - (fpclass(d) == FP_NINF)) 53 | #endif 54 | #endif 55 | 56 | #define ARR_CNT(a) ((int) (sizeof(a)/sizeof(a[0]))) /* returns the number of elements in an array */ 57 | #define CLEAR_ARRAY(a) memset(a, 0, sizeof(a)) /* quickly sets all elements of an array to zero */ 58 | -------------------------------------------------------------------------------- /lib/mathomatic-master/t: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Shell script to test Mathomatic. 3 | 4 | if make --version >/dev/null 2>&1 5 | then 6 | set -x 7 | make test 8 | else 9 | set -x 10 | gmake test 11 | fi 12 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/README.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory contains only Mathomatic scripts. They include tests, 3 | examples, short tutorials, and educational math toys. 4 | 5 | To run all of the tests on a Unix compatible system 6 | and check their output, type "./t". 7 | 8 | To run a specific script, type "mathomatic script-name", 9 | or "read script-name" from within Mathomatic. 10 | 11 | To run a specific script, and create a complete HTML output file 12 | from it, type "./demo script-name". 13 | 14 | Look around and have fun! Feel free to contribute your Mathomatic scripts. 15 | Here are the good examples and lessons that are available in this directory: 16 | 17 | all.in - script that reads in all test scripts 18 | circles.in - uses eliminate command to combine the equations for 2 circles 19 | collatz.in - the Collatz conjecture as an equation 20 | cubic.in - calculate the 3 solutions of any cubic polynomial equation 21 | cubic2.in - general cubic polynomial formula using 2 equations 22 | demo.in - a demonstration of differentiation and Taylor series 23 | distance.in - derive the shortest distance between a point and a line in 2D 24 | electronics.in - a few electrical formulas 25 | ellipse.in - 2D equations for ellipses 26 | examples.in - some simple examples of Mathomatic in action 27 | fibonacci.in - direct formula to calculate phi and any Fibonacci number 28 | finance.in - derivation of the present value annuity formula 29 | fraction.in - shows how "simplify fraction" and "unfactor fraction" work 30 | heart.in - plot a heart with gnuplot 31 | heron.in - tutorial for the area formula of any triangle and derivations 32 | how_limit_works.in - how the experimental limit command works 33 | linear.in - combine 3 simultaneous linear equations with 3 unknowns 34 | pie.in - how to approximate the universal constants pi and e 35 | points.in - derive simple equations from 2 or 3 points in 2 dimensions 36 | poly.in - combine 3 quadratic equations with 3 unknown coefficients 37 | pyth3d.in - arrives at the distance between two points in 3D space 38 | quadratic.in - derives the general quadratic (2nd degree polynomial) formula 39 | quartic.in - calculate the 4 solutions of quartic polynomial equations 40 | radius.in - some fun formulas for the radius of a circle 41 | 42 | Some "rmath" (or "matho") only scripts: 43 | 44 | trig - creates an equation for each trigonometry function 45 | batman_plot - Batman equations plot the Batman logo 46 | 47 | Install m4 Mathomatic and type "rmath script-name" to run rmath scripts. 48 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/all.in: -------------------------------------------------------------------------------- 1 | ; This is a Mathomatic script that reads in all test scripts. 2 | 3 | clear all 4 | ; Test simplifying trig functions: 5 | read trig.in 6 | read hypertrig.in 7 | simplify all 8 | simplify frac all 9 | ; Let's simplify some trig identities without using m4: 10 | sin^2+cos^2=1 11 | elim all 12 | simplify 13 | tan=sin/cos 14 | elim all 15 | csc=1/sin 16 | elim all 17 | sec=1/cos 18 | elim all 19 | cot=1/tan 20 | elim all 21 | 1+tan^2=sec^2 22 | elim all 23 | cosh^2-sinh^2=1 ; The main hyperbolic trigonometry identity: 24 | elim all 25 | ; Now verify them all, to show and check the new solve command usage. 26 | solve 13-19 verifiable 0 27 | pause 28 | clear all 29 | ; Next, test fixed-point mode and some financial equations: 30 | read finance 31 | a=55/-3 32 | list 33 | display mixed 34 | display mixed factor 35 | display simple 36 | list 37 | display 38 | set no fixed_point 39 | display 40 | clear all 41 | read quadratic 42 | clear all 43 | read electronics 44 | simplify all 45 | clear all 46 | read fibonacci 47 | clear all 48 | read test 49 | clear all 50 | read fraction 51 | clear all 52 | read pie 53 | 1 54 | fraction 55 | read demo 56 | read limits 57 | ; read how_limit_works 58 | read test3 59 | read poly 60 | clear all 61 | read examples 62 | clear all 63 | read test1 64 | read test2 65 | read test6 66 | clear all 67 | read simplify 68 | read heron 69 | clear all 70 | read radius 71 | clear all 72 | read pyth3d 73 | clear all 74 | read distance 75 | clear all 76 | read circles 77 | clear all 78 | read ellipse 79 | solve all y 80 | simplify all 81 | pause 82 | clear all 83 | help examples 84 | clear all 85 | help conversions 86 | simplify all 87 | clear all 88 | help geometry 89 | simplify all 90 | quit 91 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/batman_gnuplot_bug.in: -------------------------------------------------------------------------------- 1 | 2 | ; Read this in with mathomatic, not rmath nor matho. 3 | ; These are the Batman equations. 4 | ; They plot the Batman logo using many absolute value functions with gnuplot. 5 | ; This plot proves gnuplot has a bug in it, because it doesn't come out quite right. 6 | ; There are 4 expressions simultaneously plotted here; 7 | ; it is the first, and longest, expression that comes out wrong. 8 | ; If you plot this in Google or Lybniz, it comes out right. 9 | 10 | plot 1.5*sqrt((-abs(abs(x)-1))*abs(3-abs(x))/((abs(x)-1)*(3-abs(x))))*(1+abs(abs(x)-3)/(abs(x)-3))*sqrt(1-(x/7)^2)+(4.5+0.75*(abs(x-0.5)+abs(x+0.5))-2.75*(abs(x-0.75)+abs(x+0.75)))*(1+abs(1-abs(x))/(1-abs(x))),(-3)*sqrt(1-(x/7)^2)*sqrt(abs(abs(x)-4)/(abs(x)-4)),abs(x/2)-0.0913722*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2),(2.71052+1.5-0.5*abs(x)-1.35526*sqrt(4-(abs(x)-1)^2))*sqrt(abs(abs(x)-1)/(abs(x)-1)) 11 | 12 | ; If readline is enabled, 13 | ; hitting the up arrow, then the Enter key, should allow a replot. 14 | :push plot 1.5*sqrt((-abs(abs(x)-1))*abs(3-abs(x))/((abs(x)-1)*(3-abs(x))))*(1+abs(abs(x)-3)/(abs(x)-3))*sqrt(1-(x/7)^2)+(4.5+0.75*(abs(x-0.5)+abs(x+0.5))-2.75*(abs(x-0.75)+abs(x+0.75)))*(1+abs(1-abs(x))/(1-abs(x))),(-3)*sqrt(1-(x/7)^2)*sqrt(abs(abs(x)-4)/(abs(x)-4)),abs(x/2)-0.0913722*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2),(2.71052+1.5-0.5*abs(x)-1.35526*sqrt(4-(abs(x)-1)^2))*sqrt(abs(abs(x)-1)/(abs(x)-1)) 15 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/batman_plot: -------------------------------------------------------------------------------- 1 | 2 | ; These are the Batman equations. 3 | ; They plot the Batman logo using many absolute value functions. 4 | ; This is a good test of absolute value simplification. 5 | ; To read in, install m4 Mathomatic and type "rmath batman_plot". 6 | 7 | y=1.5*sqrt((-abs(abs(x)-1))*abs(3-abs(x))/((abs(x)-1)*(3-abs(x))))*(1+abs(abs(x)-3)/(abs(x)-3))*sqrt(1-(x/7)^2)+(4.5+0.75*(abs(x-0.5)+abs(x+0.5))-2.75*(abs(x-0.75)+abs(x+0.75)))*(1+abs(1-abs(x))/(1-abs(x))) 8 | y=(-3)*sqrt(1-(x/7)^2)*sqrt(abs(abs(x)-4)/(abs(x)-4)) 9 | y=abs(x/2)-0.0913722*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2) 10 | y=(2.71052+1.5-0.5*abs(x)-1.35526*sqrt(4-(abs(x)-1)^2))*sqrt(abs(abs(x)-1)/(abs(x)-1)) 11 | ; Type "plot all" to see the batman logo. 12 | ; Test the simplify command by typing "repeat simplify all" 13 | ; then "plot all" again, making sure it is exactly the same plot. 14 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/circles.in: -------------------------------------------------------------------------------- 1 | 2 | ; This is a simple example of eliminate command usage. 3 | ; Combine the equations for 2 circles of radius "r" on a 2D Cartesian plane 4 | ; to find the points of intersection (x, y). 5 | 6 | (x-x1)^2+(y-y1)^2=r^2 ; circle of radius "r" with center at (x1, y1) 7 | (x-x2)^2+(y-y2)^2=r^2 ; circle of radius "r" with center at (x2, y2) 8 | eliminate x ; combine the two equations, removing the x variable from the result 9 | solve for y 10 | repeat simplify 11 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/collatz.in: -------------------------------------------------------------------------------- 1 | 2 | ; The Collatz conjecture as a mathematical feedback equation: 3 | out = (in/2) - (((5*in) + 2)*(((-1)^in) - 1)/4) 4 | ; Prove that feeding "out" into "in" will 5 | ; always eventually count down to the number 1. 6 | ; Run with the command "calc in". 7 | ; Repeatedly prompt with the command "repeat calc in". 8 | ; See all intermediate in/out values by typing "set debug 1" beforehand. 9 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/cubic.in: -------------------------------------------------------------------------------- 1 | 2 | ; General cubic (3rd degree polynomial) formula using 3 equations. 3 | ; Formula for the 3 roots (solutions for x) of the general 3rd degree polynomial equation. 4 | ; These formulas always seem to work correctly, whether imaginary or real solutions. 5 | ; 6 | ; This is currently the only way to solve cubic polynomials in Mathomatic, 7 | ; by manually entering the coefficients (a, b, c, and d) into the following equations. 8 | ; To visualize the coefficients of a polynomial equation: 9 | ; solve for 0 10 | ; unfactor 11 | ; factor x 12 | ; 13 | ; See also file "cubic2.in" for using 2 equations instead of 3. 14 | 15 | a x^3 + b x^2 + c x + d = 0 ; The general cubic equation. 16 | x_1=-b/{3 a}-1/{3 a} {{2 b^3-9 a b c+27 a^2 d+{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/{2}}^(1/3)-1/{3 a} {{2 b^3-9 a b c+27 a^2 d-{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/2}^(1/3) 17 | x_2=-b/{3 a}+{1+i 3^.5}/{6 a} {{2 b^3-9 a b c+27 a^2 d+{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/{2}}^(1/3)+{1-i 3^.5}/{6 a} {{2 b^3-9 a b c+27 a^2 d-{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/2}^(1/3) 18 | x_3=-b/{3 a}+{1-i 3^.5}/{6 a} {{2 b^3-9 a b c+27 a^2 d+{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/{2}}^(1/3)+{1+i 3^.5}/{6 a} {{2 b^3-9 a b c+27 a^2 d-{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/2}^(1/3) 19 | ; x_1, x_2, and x_3 are the solutions to the given general cubic equation. 20 | ; Type "calculate all" to temporarily plug in coefficients. 21 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/cubic2.in: -------------------------------------------------------------------------------- 1 | 2 | ; General cubic (3rd degree polynomial) formula using 2 equations. 3 | ; Formula for the 3 roots (solutions for x) of the general 3rd degree polynomial equation. 4 | ; These formulas always seem to work correctly, whether imaginary or real solutions. 5 | ; 6 | ; This is currently the only way to solve cubic polynomials in Mathomatic. 7 | ; This is also a good test of the optimize and "simplify quick" commands. 8 | ; Try "simplify quick all" and then "optimize all" for some true optimalism! 9 | 10 | a x^3 + b x^2 + c x + d = 0 ; The general cubic equation. 11 | ; A real solution: 12 | x_r=-b/{3 a}-1/{3 a} {{2 b^3-9 a b c+27 a^2 d+{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/{2}}^(1/3)-1/{3 a} {{2 b^3-9 a b c+27 a^2 d-{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/2}^(1/3) 13 | ; The 2 imaginary solutions or 2 more real solutions: 14 | x_i=-b/{3 a}+{1-sign*i*3^.5}/{6 a} {{2 b^3-9 a b c+27 a^2 d+{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/{2}}^(1/3)+{1+sign*i*3^.5}/{6 a} {{2 b^3-9 a b c+27 a^2 d-{(2 b^3-9 a b c+27 a^2 d)^2-4 (b^2-3 a c)^3}^.5}/2}^(1/3) 15 | ; x_r and x_i are the three solutions to the given general cubic equation. 16 | ; Type "calculate all" to temporarily plug in coefficients. 17 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/demo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Create complete color html files out of Mathomatic input (*.in) files. 3 | # The result is suitable for display on a website. 4 | # Usage: ./demo script_base_filenames 5 | 6 | RUN_SUB="${0}_sub" 7 | 8 | for file in "$@" 9 | do 10 | if [ ! -f "$file.in" ] 11 | then 12 | echo $file.in not found. 13 | exit 1 14 | fi 15 | echo Doing "$file.in" with "$RUN_SUB" and tidy... 16 | "$RUN_SUB" "$file" | tidy -q -i -wrap 1000 >$file.html 17 | done 18 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/demo.in: -------------------------------------------------------------------------------- 1 | clear all 2 | ; Some symbolic differentiation examples follow. 3 | 4 | ; Take the derivative of the absolute value function: 5 | |x| 6 | derivative ; The result is the sign function sgn(x), which gives the sign of x. 7 | repeat echo * 8 | ; Mathomatic can differentiate anything that doesn't require symbolic logarithms. 9 | y=e^(1+1/x) 10 | derivative ; The first order derivative is: 11 | derivative ; The second order derivative is: 12 | expand fraction ; Perhaps easier to read: 13 | repeat echo * 14 | ; A Taylor series demonstration: 15 | y=x_new^n ; x_new is what we want, without using the root operator. 16 | x_new ; It is easily solved for in Mathomatic. 17 | y ; But we want an algorithm to compute it without using non-integer exponentiation. 18 | taylor x_new, 1, x_old ; build the (nth root of y) iterative approximation formula 19 | solve verifiable x_new ; solve for the output variable 20 | ; That is the convergent nth root approximation formula. 21 | copy ; "calculate x_old 10000" tests this formula, if you would like to see for yourself. 22 | replace x_old x_new with x ; make x_old (input) and x_new (output) the same 23 | x ; make sure the formula was correct by solving for x 24 | repeat echo * 25 | ; Another Taylor series demo: 26 | e^x ; enter the exponential function 27 | taylor x, 10, 0 ; generate a 10th order taylor series of the exponential function 28 | laplace x ; do a Laplace transform on it 29 | simplify ; show the structure of the result 30 | laplace inverse x ; undo the Laplace transform 31 | compare with 10 ; check the result 32 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/demo_sub: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Called and used only by the demo shell script. 3 | 4 | set -e 5 | set -u 6 | 7 | echo '' 8 | echo '' 9 | echo 10 | echo '' 11 | echo '' 12 | echo "Actual timed Mathomatic output from the $@ script" 13 | echo '' 14 | echo '' 15 | echo '' 16 | echo '' 17 | 18 | echo '' 19 | echo '' 20 | echo 21 | echo '' 22 | 23 | echo "

Actual timed Mathomatic output from the $@ script

" 24 | 25 | /usr/bin/time -p mathomatic -dxr "$@" &1 26 | 27 | echo 'seconds total execution time of this script.' 28 | echo '
' 29 | echo 'More examples' 30 | echo 'www.mathomatic.org' 31 | 32 | echo '' 33 | echo '' 34 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/distance.in: -------------------------------------------------------------------------------- 1 | 2 | ; This input arrives at the shortest distance between a point and a line 3 | ; in 2 dimensions. The point is at (x0, y0) in cartesian coordinates. 4 | ; (x, y) are the points on the line. 5 | 6 | a*x+b*y+c=0 ; equation of the line 7 | y ; solve for y 8 | unfactor fraction ; equation of the line in slope-intercept form: 9 | distance=|a*(x-x0)+b*(y-y0)|/(a^2+b^2)^.5 10 | eliminate y ; Combine the above two equations to eliminate x and y. 11 | simplify ; The beautiful answer is: 12 | ; Replacing a with -m, b with 1, and c with -b results in the shortest distance from the line y=m*x+b. 13 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/electronics.in: -------------------------------------------------------------------------------- 1 | 2 | ; General electrical formulas: 3 | 4 | volts=amps*ohms ; Ohm's Law, commonly solved for resistance (ohms) or current (amps). 5 | watts=volts*amps ; Power Law 6 | 1/r=1/r1+1/r2 ; Resistance (r) of 2 resistors (r1 and r2) wired in parallel. 7 | solve verifiable r ; Solve for the resulting resistance. 8 | 1/r=1/r1+1/r2+1/r3 ; Resistance (r) of 3 resistors wired in parallel. 9 | solve verifiable r ; Solve for the resulting resistance. 10 | frequency=1/(2*pi*(L*C)^.5) ; Resonant frequency of an LC circuit in hertz. 11 | ; L is the inductance in henries, and C is the capacitance in farads. 12 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/ellipse.in: -------------------------------------------------------------------------------- 1 | 2 | ; This is an equation for an ellipse that was created using the rule 3 | ; that the sum of the distances from any point on the perimeter (x, y) 4 | ; to the two foci: (x1, y1) and (x2, y2), is a constant k. This can 5 | ; represent any ellipse of any orientation on the Cartesian plane. 6 | 7 | k = ((x1-x)^2+(y1-y)^2)^0.5 + ((x2-x)^2+(y2-y)^2)^0.5 8 | 9 | ; A simplified equation for a right ellipse centered at the origin (0, 0) 10 | ; of the Cartesian plane: 11 | 12 | 1 = x^2/radius1^2 + y^2/radius2^2 13 | ; The x-intercepts are radius1 and -radius1 because y=0 there. 14 | ; The y-intercepts are radius2 and -radius2 because x=0 there. 15 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/examples.in: -------------------------------------------------------------------------------- 1 | 2 | ; This is a line comment. This script shows some simple examples of Mathomatic usage. 3 | ; Mathomatic input files are scripts that may be read in with the "read" command. 4 | 5 | ; Equations are entered by just typing or pasting them in: 6 | c^2=a^2+b^2 ; The Pythagorean theorem, "c" squared equals "a" squared plus "b" squared. 7 | ; The entered equation becomes the current equation and is displayed. 8 | ; The current equation can be solved by simply typing in a variable name: 9 | c ; which is shorthand for the solve command. Solve for variable "c". 10 | ; "sign" variables are special two-valued variables that may only be +1 or -1. 11 | solve for b ; Another way to solve for a variable, using English. 12 | ; To output programming language code, use the code command: 13 | code ; C language code is the default. 14 | 15 | code java ; Mathomatic can also generate Java 16 | 17 | code python ; and Python code. 18 | 19 | repeat echo * 20 | a=b+1/b ; Enter another equation; this is actually a quadratic equation. 21 | 0 ; Solve for zero. 22 | unfactor ; Expand, showing that this is a quadratic polynomial equation in "b". 23 | solve verifiable b ; Require solution verification with the "verifiable" option. 24 | a ; Solve back for "a" and we should get the original equation. 25 | simplify ; The simplify command makes expressions simpler and prettier. 26 | repeat echo * 27 | ; Mathomatic is also handy as an advanced calculator. 28 | ; Expressions without variables entered at the main prompt are instantly evaluated: 29 | 2+3 30 | 495/44 ; Fractions are always reduced to their simplest form: 31 | ; Fractions greater than 1 can easily be displayed as mixed fractions. 32 | display mixed ; Display above fraction as a mixed fraction: 33 | display factor ; Integers and fractions are easily factored: 34 | 2^.5 ; The square root of 2, rounded to the default 14 digits: 35 | 36 | repeat echo * 37 | ; Symbolic logarithms like log(x) are not implemented, yet. 38 | 27^y=9 ; An example that uses numeric logarithms. 39 | solve verifiable y ; Require solution verification with the "verifiable" option. 40 | 41 | repeat echo * 42 | 0=2x^2-3x-20 ; A simple quadratic equation, to show how the calculate command works. 43 | solve verifiable x ; Solve for x, plugging the results into the original equation to verify. 44 | calculate ; Expand "sign" variables and approximate the RHS (Right-Hand Side). 45 | ; The calculate command also lets you plug values into a formula with variables, if any. 46 | display; Display the current equation, showing that it was not modified by calculate. 47 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fibonacci.in: -------------------------------------------------------------------------------- 1 | 2 | ; This Mathomatic input file contains the mathematical formula to 3 | ; directly calculate the "n"th Fibonacci number. 4 | ; The formula presented here is called Binet's formula, found at 5 | ; http://en.wikipedia.org/wiki/Fibonacci_number 6 | ; 7 | ; The Fibonacci sequence is the endless integer sequence: 8 | ; 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 ... 9 | ; Any Fibonacci number is always the sum of the previous two Fibonacci numbers. 10 | ; 11 | ; Easy to understand info on the golden ratio can be found here: 12 | ; http://www.mathsisfun.com/numbers/golden-ratio.html 13 | 14 | -1/phi=1-phi ; Derive the golden ratio (phi) from this quadratic polynomial. 15 | 0 ; show it is quadratic 16 | unfactor 17 | solve verifiable for phi ; The golden ratio will help us directly compute Fibonacci numbers. 18 | replace sign with -1 ; the golden ratio constant: 19 | fibonacci = ((phi^n) - ((1 - phi)^n))/(phi - (1 - phi)) ; Binet's Fibonacci formula. 20 | eliminate phi ; Completed direct Fibonacci formula: 21 | simplify ; Note that Mathomatic rationalizes the denominator here. 22 | for n 1 20 ; Display the first 20 Fibonacci numbers by plugging in values 1-20: 23 | ; Note that this formula should work for any positive integer value of n. 24 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/finance.in: -------------------------------------------------------------------------------- 1 | 2 | ; Combine 2 commonly used formulas to produce the mortgage payment formula. 3 | ; Here are 3 related financial formulas that can be "read" into Mathomatic. 4 | 5 | set fixed ; Enable fixed-point money mode; rounds to the nearest cent. 6 | ; First, the variable definitions: 7 | ; pv = present value 8 | ; fv = future value (maturity value) 9 | ; interest_rate = interest rate per period (1 = 100%) 10 | ; n = number of periods 11 | 12 | ; Compound Interest Future Value Formula: 13 | fv1 = pv*(1+interest_rate)^n 14 | ; Future Value Annuity Formula: 15 | fv2 = payment*(((1+interest_rate)^n-1)/interest_rate) 16 | ; Next we will combine these to produce the standard annuity formula. 17 | ; Set equal, then solve and simplify: 18 | fv1 = fv2 19 | pause 20 | eliminate all ; combine both formulas to produce the annuity formula: 21 | solve verifiable pv ; solve for present value: 22 | solve verifiable payment ; or solve for payment per period: 23 | pause End of finance tutorial 24 | ; Remember we are still in fixed-point money mode, 25 | ; unless you typed "set no fixed". 26 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fix1.in: -------------------------------------------------------------------------------- 1 | clear all 2 | y = (((((a+b)/(b-c))^0.25)+(((b-c)/(a+b))^0.25)+(((a-b)*i/(b-c))^0.5))*(i^0.5))^(1/n) 3 | y = (a^a)*(1+(((a^(a^2))*(b^a))^(1/(1-a)))) 4 | y = (a^2)*(1+(((a^(2*((1.5*a)-1)))*(b^a))^(1/(1-a)))) 5 | y = (15*(d^2)/((1+(d^2))^(7/2)))-(12/((1+(d^2))^(5/2)))-6 6 | y = ((9 + (32^.5))^.5) ; should simplify to (1 + 2*(2^.5)) someday 7 | simplify symbolic all 8 | simplify all 9 | x^2=|x| 10 | solve for x 11 | x^(1/99)=x 12 | solve verifiable x 13 | (2i)^.5+e^(pi*i) 14 | (1-2i)/(3+4i) 15 | divide (1-2i) (3+4i) 16 | 17 | y=x^3 18 | extrema x 19 | (x+1)^4 20 | extrema x 21 | roots 4 1 0 ; The 4 roots of unity. 22 | factor number -75 100000000000000 16! 7921%14 ; should be exactly 11 23 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fix2.in: -------------------------------------------------------------------------------- 1 | clear all 2 | b = ((-1)^(1/((-1*n)+1)*(2+n)))*(a^(1/((-1*n)+1))) 3 | x = 1/(y^(1/(n-1)*(-2+n)))/((n^(n/(n-1)))-(n^(1/(n-1)))) 4 | y = (x+(((1/x)+1)*((x^m)+((a+b)/(x^n)/(c+d)))))/(x+1) 5 | y = 3 / (x^3+3x^2-x-3) - 2 / (x^3-x^2-3x+3) + 4 / (x^3+x^2-3x-3) 6 | (x^2 - 1)^4/(x + 1)^2 7 | simplify all 8 | 1 9 | solve verifiable a 10 | 2 11 | solve verifiable y 12 | 1/(x+y) 13 | taylor x, 5, 0 14 | fraction 15 | simplify fraction 16 | simplify 17 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fix5.in: -------------------------------------------------------------------------------- 1 | clear all 2 | a = (x+1/2^.5)^3 3 | a = (b+((c+1)^0.5))^3 4 | a = b*c*x*((((x^2)*c)+(b^4))^3)*(x+c) 5 | a = (((b^2)+x)^3)*((1/x)+x)*b 6 | a = b*(((1/b)+(1/c))^3) 7 | a = (b^2)*(((1/b)+(1/c))^3) 8 | a = (b^2)*((b-c)^3) 9 | simplify all 10 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fix7.in: -------------------------------------------------------------------------------- 1 | ; Algebraic fractions test 2 | clear all 3 | (c+a-b)/(b-a) 4 | ((d*(b+c))+(a*(e1+f)))/(e1+f)/(b+c) 5 | ((((e1^2)+d)*b*((b^2)+2))-e1-f)/b/((b^2)+2)/(e1+f) 6 | ((b*((((e1^2)+d)*((b^2)+2))+(b*(e1+f))))+e1+f)/(e1+f)/b/((b^2)+2) 7 | ((1/(x^(1+n)))+(1/(x^n))+(x^(m-1))+(x^m)+x)/(x+1) 8 | (1/(a + b)) + (1/(b + c)) 9 | ((x - 1)^2)*(2 + x)/((1 + x)*((x - 3)^2)) 10 | simplify all 11 | fraction all 12 | simplify fraction all 13 | simplify all 14 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fix8.in: -------------------------------------------------------------------------------- 1 | clear all 2 | a = (((b^2)*(x^2))+(4*(b^2)*x)+(b^2)+(2*(b^3)*x)+(2*(b^3))+(b^4)+(2*b*(x^2))+(2*b*x)+(x^2))/(((b^3)*(x^2))+(2*(b^4)*x)+(b^5)) 3 | y = (((b+1)^0.5)*((b^2.5)+c))+((((b^2)+b)^0.5)*a) 4 | a = (b^(1-n))/(1+(b^(m-n))) 5 | a = (((b^2)+(b*(c^(1-n)))+(b^0.5))/(b^n)/(1+(b^(m-n))))^0.5 6 | simplify all 7 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fix9.in: -------------------------------------------------------------------------------- 1 | clear all 2 | ((1/b) + (1/c) + (1/d))^3 3 | ((+/-1000*(b!^4)+/-x)^2)*((1/x)+x)*b 4 | ((b+(2*i))^5) 5 | (((1/(b^2))+c)^2)*((1/b)+(c*b)) 6 | (6*(b^0.5)-3)^3 7 | (2-(4/(c-b)))^3 8 | (((e*((2*(x^3)) + 24 + (x!) - zy)) - pi)/e)^2 9 | (2+3x)^3 10 | simplify all 11 | display factor all 12 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/fraction.in: -------------------------------------------------------------------------------- 1 | 2 | ; Algebraic fractions tutorial. 3 | ; This Mathomatic input shows how "simplify fraction" and "unfactor fraction" work. 4 | 1/x+1/y+1/z 5 | fraction ; Convert expressions with algebraic fractions into a single fraction. 6 | simplify 7 | simplify fraction ; does the same as the above fraction command, but simplifies more. 8 | unfactor ; Expand the products of sums. 9 | unfactor fraction ; Fully expand algebraic fractions by also expanding division of sums. 10 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/heart.in: -------------------------------------------------------------------------------- 1 | 2 | ; Plot a heart with gnuplot: 3 | plot [-2:2] acos(1-abs(x))-pi,sqrt(1-(abs(x)-1)^2) 4 | 5 | ; If readline is enabled, 6 | ; hitting the up arrow, then the Enter key, should allow a replot. 7 | :push plot [-2:2] acos(1-abs(x))-pi,sqrt(1-(abs(x)-1)^2) 8 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/heron.in: -------------------------------------------------------------------------------- 1 | clear all 2 | ; This Mathomatic script shows two reverse derivations of Heron's formula. 3 | ; This is Heron's formula for the area of any triangle, 4 | ; given side lengths "a", "b", and "c". 5 | 6 | 2s = a+b+c 7 | triangle_area = (s*(s-a)*(s-b)*(s-c))^.5 8 | eliminate s ; Heron's formula: 9 | simplify ; Heron's formula simplified by Mathomatic: 10 | pause 11 | ; This is how we arrive at Heron's formula for the area 12 | ; of any triangle, given side lengths a, b, and c, using the formula 13 | ; for the area of a trapezoid with side lengths a, b, c, and d, 14 | ; where a and c are the parallel sides (a is the longer parallel side). 15 | 16 | ; A trapezoid is a quadrilateral with 17 | ; two sides that are parallel to each other. 18 | 19 | ; Formula for the area of a trapezoid that is not a parallelogram: 20 | trapezoid_area=(a+c)/(4*(a-c))*((a+b-c+d)*(a-b-c+d)*(a+b-c-d)*(-a+b+c+d))^.5 21 | pause 22 | copy 23 | replace c with 0 ; make the shorter parallel side length = 0 24 | replace d with c ; Heron's formula in its simplest form: 25 | replace trapezoid_area with triangle_area 26 | pause Please press the Enter key to verify the result. 27 | copy 28 | display 2 29 | compare 5 with 2 ; simplify and compare the result with Heron's formula: 30 | clear 5 31 | pause 32 | 33 | ; This is how we arrive at Heron's formula for the area 34 | ; of any triangle, given side lengths a, b, and c, using 35 | ; Brahmagupta's formula for the area of a cyclic quadrilateral, 36 | ; making one side length equal zero, to make a cyclic triangle. 37 | ; Since all triangles are cyclic (can be circumscribed by a circle), 38 | ; this gives the area for any triangle. 39 | 40 | 2s=a+b+c+d ; cyclic quadrilateral side lengths are a, b, c, and d 41 | cyclic_area = ((s-a)*(s-b)*(s-c)*(s-d))^.5 42 | eliminate s ; Brahmagupta's formula: 43 | pause 44 | copy 45 | replace d with 0 ; make one side length zero to get Heron's formula: 46 | pause Please press the Enter key to verify the result. 47 | compare 2 ; simplify and compare the result with Heron's formula: 48 | clear 49 | clear 1 5 50 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/how_limit_works.in: -------------------------------------------------------------------------------- 1 | clear all 2 | ; Read this file into Mathomatic to learn how the limit command does limits. 3 | ; The formula for the derivative of a function of "x" (f(x)) is: 4 | 5 | ; f(x+h) - f(x) 6 | ; limit ------------- As "h" goes to 0. 7 | ; h 8 | 9 | ; Here we will compute the derivative of "x^.5" using limits: 10 | 11 | y=((x+h)^.5-x^.5)/h 12 | pause 13 | limit h 0 ; Take the limit of the current equation as h goes to 0. 14 | ; The result should be the derivative of "x^.5": "y = 1/(2*x^0.5)". 15 | pause 16 | ; To show how the limit command works, we will do what it does, step by step. 17 | 18 | 1 ; Select the original equation (equation number 1). 19 | ; We want "h" to go to 0 to give us the derivative. 20 | ; Just entering 0 for "h" will give a divide by zero error. 21 | pause 22 | ; So we will first have to solve for "h": 23 | 24 | h 25 | pause 26 | ; Simplify and replace "h" with 0: 27 | 28 | simplify symbolic 29 | replace h with 0 30 | pause 31 | ; Last step, solve the equation back for "y": 32 | 33 | y 34 | compare 1 with 2 ; Compare with the result of the limit command. 35 | 36 | ; Obviously this method only works if the equation is solvable. 37 | pause 38 | ; INFINITY LIMITS 39 | ; --------------- 40 | ; To take the limit as some variable "h" goes to infinity, 41 | ; remember that 1/infinity is essentially 0, and the limit 42 | ; of "1/h" as "h" goes to 0 is +/-infinity, so replace "h" 43 | ; with "1/h" and take the limit as "h" now goes to 0. 44 | ; Note that this method doesn't always work and sometimes gives wrong answers. 45 | 46 | ; Let's try a simple example: 47 | y=(5x+100-a)/(x-b) 48 | limit x inf 49 | ; The limit command should say the result is 5. 50 | pause 51 | ; To show how the limit command works, we will do what it does, step by step. 52 | 53 | 3 ; Select the original equation (equation number 3). 54 | ; To take the limit as "x" approaches infinity, 55 | ; first replace "x" with "1/x": 56 | 57 | replace x with 1/x 58 | pause 59 | 60 | ; Simplify and replace "x" with 0: 61 | simplify 62 | replace x with 0 63 | ; The result should be 5. 64 | pause End of limit command tutorial. 65 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/hypertrig.in: -------------------------------------------------------------------------------- 1 | ; Definitions for hyperbolic trigonometry. 2 | ; Use m4 Mathomatic instead for easy entry of these hypertrig functions. 3 | ; Based on the identity cosh(x)^2-sinh(x)^2 = 1. 4 | 5 | ; sinh(x); hyperbolic sine of x 6 | sinh=(e^x-e^-x)/2 7 | 8 | ; cosh(x); hyperbolic cosine of x 9 | cosh=(e^x+e^-x)/2 10 | 11 | ; tanh(x); hyperbolic tangent of x 12 | tanh=(e^x-e^-x)/(e^x+e^-x) 13 | 14 | ; coth(x); hyperbolic cotangent of x 15 | coth=(e^x+e^-x)/(e^x-e^-x) 16 | 17 | ; sech(x); hyperbolic secant of x 18 | sech=2/(e^x+e^-x) 19 | 20 | ; csch(x); hyperbolic cosecant of x 21 | csch=2/(e^x-e^-x) 22 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/limits.in: -------------------------------------------------------------------------------- 1 | 2 | ; Tests for the experimental limit command. 3 | 4 | clear all 5 | ; find the derivative of: 6 | y = 1/(x^.5) 7 | ; using the difference quotient: 8 | y' = (1/(x+delta_x)^.5-1/x^.5)/delta_x 9 | limit delta_x 0 ; take the limit as delta_x (change in x) goes to 0 10 | 3 11 | integrate x ; take the antiderivative to see if it's right 12 | compare 1 13 | 14 | ; test infinity limits: 15 | 2x/(x+1) 16 | limit x inf ; answer should be 2 17 | 18 | (3x+100-a)/(x-b) 19 | limit x inf ; answer should be 3 20 | 21 | (((x^2) - (5*x) + 6)^(1/2)) - x 22 | limit x inf ; answer should be -5/2 23 | 24 | x*((x^2+1)^.5-x) 25 | limit x inf ; answer should be 1/2 26 | 27 | 1/x^2+1/x 28 | limit y inf ; result should be original expression with a warning. 29 | limit x inf ; result should be 0 30 | 31 | ((2*(x^2)) - x - 6)/((x^2) + (2*x) - 8) 32 | limit x inf ; result should be 2 33 | 34 | x^2+x 35 | limit x 0 ; result should be 0 36 | limit x 2 ; result should be 6 37 | display 38 | ; The following currently gives the wrong answer: 39 | limit x inf ; result should be inf 40 | ; The following currently gives errors: 41 | y=x+1/x 42 | :limit x 0 ; result should be inf 43 | :limit x inf; result should be inf 44 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/linear.in: -------------------------------------------------------------------------------- 1 | 2 | ; Combine 3 simultaneous linear equations with 3 unknowns (x, y, z). 3 | ; Solve for all 3 unknowns using the eliminate, solve, and simplify commands. 4 | 5 | clear all ; restart Mathomatic 6 | ; enter all 3 equations: 7 | d1=a1*x+b1*y+c1*z 8 | d2=a2*x+b2*y+c2*z 9 | d3=a3*x+b3*y+c3*z 10 | 2 ; select equation number 2 as the current equation 11 | eliminate x ; eliminate variable x from the current equation 12 | 3 ; select equation number 3 13 | eliminate x y ; eliminate variables x and then y from the current equation 14 | solve for z 15 | 2 ; select equation number 2 16 | eliminate z using 3 ; find y by combining equation numbers 2 and 3 17 | simplify 18 | 1 ; select equation number 1 19 | eliminate z using 3, y using 2; find x 20 | 21 | simplify all ; simplify and display all solutions 22 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/pie.in: -------------------------------------------------------------------------------- 1 | 2 | ; This is the famous Bailey-Borwein-Plouffe (BBP) formula. 3 | ; Sum this n = 0 to infinity to compute pi. 4 | ; This is especially useful for calculating pi in hexadecimal. 5 | ; One hexadecimal digit of pi is generated with each iteration. 6 | ((4/((8*n)+1))-(2/((8*n)+4))-(1/((8*n)+5))-(1/((8*n)+6)))/(16^n) 7 | simplify ; BBP simplifies to the ratio of two polynomials. 8 | sum n=0 to 10 ; Numerically sum BBP from n = 0 to 10 in steps of 1. 9 | pi ; The digits should be the same. 10 | repeat echo * 11 | x^n/n! ; Sum this n = 0 to infinity to compute (e^x). 12 | replace x with 1 ; Sum this n = 0 to infinity to compute e: 13 | sum n=0 to 20 ; Numerically sum from n = 0 to 20 in steps of 1. 14 | e ; The digits should be the same. 15 | repeat echo * 16 | ; Euler's identity is made of these most important universal constants: 17 | e^(pi*i)+1=0 18 | simplify ; An identity is when the LHS is identical to the RHS: 19 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/points.in: -------------------------------------------------------------------------------- 1 | 2 | ; This is the equation for a straight line given 2 points on the line. 3 | ; Point 1 is (x1, y1) and point 2 is (x2, y2) on a 2D Cartesian plane. 4 | 5 | y = ((y2*x1)+(x*(y1-y2))-(y1*x2))/(x1-x2) 6 | 7 | ; This is the equation for a quadratic curve given 3 points on it. 8 | ; It is derived in the file "poly.in" (y = a + b*x + c*x^2). 9 | ; Point 1 is (x1, y1), point 2 is (x2, y2), and point 3 is (x3, y3). 10 | 11 | y = ((y2*((x3*x1)+(x^2))*(x3-x1))+(x*(((x1^2)*(y2-y3))+((x3^2)*(y1-y2))))+(y1*((x2*((x^2)-(x3^2)))-((x^2)*x3)))+((x2^2)*((x*(y3-y1))+(x3*y1)))-(y3*((x^2)+(x1*x2))*(x2-x1)))/(x3-x1)/(x2-x1)/(x2-x3) 12 | 13 | ; Type in "calc" to plug in values. 14 | ; Just hit Enter when prompted for "x". 15 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/poly.in: -------------------------------------------------------------------------------- 1 | 2 | ; Combine 3 quadratic polynomial equations with 3 unknown coefficients (a, b, c). 3 | ; Solve for variables (a), (b), and (c). 4 | 5 | clear all ; restart Mathomatic 6 | ; enter all 3 equations: 7 | y1=a+b*x1+c*x1^2 8 | y2=a+b*x2+c*x2^2 9 | y3=a+b*x3+c*x3^2 10 | 2 ; select equation number 2 as the current equation 11 | eliminate a ; eliminate variable (a) from the current equation 12 | 3 ; select equation number 3 13 | eliminate a b ; eliminate variables (a) and then (b) from the current equation 14 | solve verifiable c 15 | simplify 16 | 2 ; select equation number 2 again 17 | eliminate c using 3 ; find (b) by combining equation numbers 2 and 3 18 | simplify 19 | 1 ; select equation number 1 20 | eliminate c using 3, b using 2 ; find (a) 21 | 22 | simplify fraction all ; display all solutions, converting to simple fractions first 23 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/pyth3d.in: -------------------------------------------------------------------------------- 1 | 2 | ; This arrives at the distance between two points in 3D space from the 3 | ; Pythagorean theorem (distance between two points on a 2D plane). 4 | ; The coordinate of point 1, 2D: (x1, y1), 3D: (x1, y1, z1). 5 | ; The coordinate of point 2, 2D: (x2, y2), 3D: (x2, y2, z2). 6 | 7 | distance2D^2=(x1-x2)^2+(y1-y2)^2 ; Distance formula for a 2D Cartesian plane. 8 | distance3D^2=distance2D^2+(z1-z2)^2 ; Add another leg. 9 | eliminate distance2D ; Combine the two equations. 10 | distance3D ; Solve to get the distance in 3D Cartesian space. 11 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/quadratic.in: -------------------------------------------------------------------------------- 1 | 2 | ; General quadratic (2nd degree polynomial) formula. 3 | ; Formula for the 2 roots (solutions for x) 4 | ; of the general quadratic equation. 5 | ; 6 | a x^2 + b x + c = 0 ; The general quadratic equation. 7 | copy select ; Make a copy and select it. 8 | solve verifiable for x ; Mathomatic can easily solve and verify that: 9 | ; This is the quadratic formula. 10 | ; The coefficients (a, b, and c) may be any mathematical expression not containing x. 11 | pause 12 | ; Here is the derivation and proof of the quadratic formula, 13 | ; without actually using the quadratic formula, 14 | ; because that is what we are trying to derive now, from the quadratic equation: 15 | #1: 16 | copy select ; make a copy of the general quadratic equation to work on and select it. 17 | -=c ; subtract "c" from both sides. 18 | /=a ; divide both sides by "a". 19 | pause Next simplify it and turn it into a repeated factor polynomial equation 20 | simplify 21 | +=b^2/(4*(a^2)) ; add "b^2/(4*(a^2))" to both sides. 22 | ; Now the LHS is a repeated factor polynomial, next factor it by pressing Enter to simplify. 23 | pause 24 | simplify ; Now the LHS is a factored polynomial, so solving for the single "x" is easy. 25 | set debug 1 ; Let Mathomatic do the work and show it too. 26 | ; Show how easy it is to solve this equation now, after pressing Enter. 27 | pause 28 | x 29 | ; Here is the raw solve result, press the Enter key to simplify and compare with the quadratic formula. 30 | pause 31 | set no debug 32 | repeat simplify 33 | compare with 2 34 | 35 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/quartic.in: -------------------------------------------------------------------------------- 1 | 2 | ; This general quartic (4th degree polynomial) formula as 3 | ; four equations combined into one is from: 4 | ; http://planetmath.org/encyclopedia/QuarticFormula.html 5 | ; Not perfect, gives division by zero warnings and only NaN for results 6 | ; if all four roots are the same. 7 | 8 | ; The four roots of the general 4th degree polynomial equation 9 | x^4 + a x^3 + b x^2 + c x + d = 0 10 | ; are given by 11 | 12 | x = ((-a)/4 + sign * 1/2(((a^2)/4 - (2b)/3 + (2^(1/3)(b^2 - 3a*c + 12d))/(3((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d + ((-4((b^2 - 3a*c + 12d))^3 + ((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d))^2)^.5)))^(1/3)) + (((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d + ((-4 ((b^2 - 3a*c + 12d))^3 + ((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d))^2)^.5)))/54)^(1/3))^.5) + sign1 * 1/2(((a^2)/2 - (4b)/3 - (2^(1/3)(b^2 - 3a*c + 12d))/(3((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d + ((-4((b^2 - 3a*c + 12d))^3 + ((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d))^2)^.5)))^(1/3)) - (((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d + ((-4 ((b^2 - 3a*c + 12d))^3 + ((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d))^2)^.5)))/54)^(1/3) + sign (-a^3 + 4a*b - 8c)/(4(((a^2)/4 - (2b)/3 + (2^(1/3) (b^2 - 3a*c + 12d))/(3 ((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d + ((-4 ((b^2 - 3a*c + 12d))^3 + ((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d))^2)^.5)))^(1/3)) + (((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d + ((-4 ((b^2 - 3a*c + 12d))^3 + ((2b^3 - 9a*b*c + 27c^2 + 27a^2d - 72b*d))^2)^.5)))/54)^(1/3))^.5)))^.5)) 13 | 14 | ; Type "calculate all" to temporarily plug in coefficients. 15 | ; Use "repeat simplify quick" to simplify this, plain old simplify does a terrible job. 16 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/radius.in: -------------------------------------------------------------------------------- 1 | 2 | ; Some more fun formulas. These are very similar to Heron's formula 3 | ; for the area of a triangle (see "heron.in"). a, b, and c are the 4 | ; lengths of the sides of the triangle. 5 | 6 | s=(a+b+c)/2 ; semiperimeter 7 | ; radius of a circle inscribed in a triangle, called an incircle: 8 | inradius=(s*(s-a)*(s-b)*(s-c))^.5/s 9 | eliminate s 10 | simplify 11 | 12 | ; The following is the equation for the radius of a circle circumscribing 13 | ; a triangle, called a circumcircle, which is a circle that passes through 14 | ; all the vertices of a polygon. 15 | radius=a*b*c/(4*(s*(s-a)*(s-b)*(s-c))^.5) 16 | eliminate s 17 | simplify 18 | #s ; Search backwards for the s variable; "/" searches forwards. 19 | clear ; No longer needed. 20 | display all 21 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/simplify.in: -------------------------------------------------------------------------------- 1 | 2 | ; Some complete simplifications Mathomatic has always been able to do. 3 | ; The result is the smallest expression that gives exactly the same results. 4 | 5 | 2*(x^2-y^2)^16-(x^2-y^2)^15*(2x^2-3) 6 | simplify ; Simplify the previously entered expression above. 7 | repeat echo * 8 | a^3/((a-b)*(a-c))+b^3/((b-c)*(b-a))+c^3/((c-a)*(c-b)) 9 | simplify ; Simplify algebraic fractions. 10 | repeat echo * 11 | (x^6+a^6)*(x+1)/((x^6+a^6)*(x^2-a^2)+a^2*x^2*(x^4-a^4))+a^2*x^2*(x+1)/(x^6-a^6-a^2*x^2*(x^2-a^2)) 12 | simplify 13 | repeat echo * 14 | (1-(1-(y+1)/(x+y+1))/(1-x/(x+y+1)))/((y+1)^2-x/(1+x/(y-x+1))*(x*(y+1)/(y-x+1)-x)) 15 | simplify fraction ; Any complex fraction can be reduced to a simple fraction with this command. 16 | repeat echo * 17 | ((2*((x*(x+(((x^2)-1)^(1/2))))-1))+1)/((2*x*((x^2)-1))+((((x^2)-1)^(1/2))*((2*(x^2))-1))) 18 | simplify ; Simplify an expression containing radicals (roots). 19 | ; Rationalizing the denominator was required to simplify the above expression. 20 | repeat echo * 21 | ((x - 2*y)^4/(x^2 - 4*y^2)^2 + 1)*(y + a)*(2*y + x) / (4*y^2 + x^2) 22 | repeat simplify 23 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/t: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Alternative shell script to test Mathomatic that doesn't require the make utility. 3 | # Just run this while in the tests directory with "./t" 4 | # to see if Mathomatic runs properly on your system. 5 | # After reading in and executing the Mathomatic scripts in "all.in", 6 | # it does a diff between the output of the test and the expected output. 7 | # If no differences are reported, "All tests passed 100% correctly" is displayed. 8 | 9 | # Usage: ./t [ mathomatic_executable_to_test ] 10 | 11 | if [ "$1" != "" ] 12 | then 13 | MATHOMATICPATH="$1" 14 | else 15 | MATHOMATICPATH="../mathomatic" 16 | if [ ! -x "$MATHOMATICPATH" ] 17 | then 18 | MATHOMATICPATH=mathomatic 19 | fi 20 | fi 21 | 22 | echo 23 | echo Testing $MATHOMATICPATH \(`$MATHOMATICPATH -v`\) || exit 1 24 | TESTOUT=`mktemp /tmp/test.XXXXXXXXXX` || exit 1 25 | time -p "$MATHOMATICPATH" -t all 0<&- >$TESTOUT && diff -u --strip-trailing-cr all.out $TESTOUT && echo "All tests passed 100% correctly." && rm $TESTOUT && exit 0 26 | echo "Test failed. Errors are in $TESTOUT" 27 | exit 1 28 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/test.in: -------------------------------------------------------------------------------- 1 | ; Read in some of the things previously fixed in Mathomatic. 2 | read fix1 3 | read fix2 4 | read fix5 5 | read fix7 6 | read fix8 7 | read fix9 8 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/test1.in: -------------------------------------------------------------------------------- 1 | y = .6666 - (4*(((10*(pi^2)*(r^3)/((d^2)*g*m*epsilon)) - 1)^(1/2))/15) 2 | simplify 3 | simplify symbolic 4 | r 5 | repeat simplify 6 | y 7 | repeat simplify symbolic 8 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/test2.in: -------------------------------------------------------------------------------- 1 | clear all 2 | y=(a/2)^2/b/4 3 | l=f*(b-y)+z*(a-f) 4 | m=2*(b-y)-a+f 5 | n=2*(b-y)+a-f 6 | o=l*(1/m-1/n)/2 7 | eliminate l m n y 8 | simplify 9 | copy 10 | f 11 | simplify symbolic 12 | 6 13 | derivative z 14 | f 15 | repeat simplify symbolic 16 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/test3.in: -------------------------------------------------------------------------------- 1 | ; Test solving linear equations with Mathomatic. 2 | 3 | read linear 4 | copy 5 | b2 6 | c2 7 | b3 8 | c3 9 | b1 10 | c1 11 | d2 12 | a2 13 | d3 14 | a3 15 | d1 16 | a1 17 | x 18 | compare with 4 19 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/test6.in: -------------------------------------------------------------------------------- 1 | ; Combine the equations for conservation of momentum and kinetic energy 2 | ; to solve for the resulting velocity of two objects colliding head on. 3 | clear all 4 | ; equations for energy: 5 | e1=1/2*mass1*velocity1_old^2 6 | e2=1/2*mass2*velocity2_old^2 7 | e3=1/2*mass1*velocity1_new^2 8 | e4=1/2*mass2*velocity2_new^2 9 | e1+e2=e3+e4 10 | eliminate all 11 | ; equations for momentum: 12 | #1: u1=mass1*velocity1_old 13 | #2: u2=mass2*velocity2_old 14 | #3: u3=mass1*velocity1_new 15 | #4: u4=mass2*velocity2_new 16 | u1+u2=u3+u4 17 | eliminate all 18 | clear 1-4 19 | eliminate velocity1_new 20 | velocity2_new 21 | simplify 22 | velocity2_new = ((sign*((mass1*(velocity1_old-velocity2_old))^2)^.5)+(mass1*velocity1_old)+(mass2*velocity2_old))/(mass1+mass2) 23 | compare 6 24 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/trig: -------------------------------------------------------------------------------- 1 | 2 | ; Trigonometric and hyperbolic trigonometric function listing that can be 3 | ; expanded and simplified by reading this file into m4 Mathomatic 4 | ; with the following shell command: 5 | 6 | ; rmath trig 7 | 8 | ; Trig functions: 9 | sine = sin(x) ; sine of x 10 | cosine = cos(x) ; cosine of x 11 | tangent = tan(x) ; tangent of x 12 | cotangent = cot(x) ; cotangent of x 13 | secant = sec(x) ; secant of x 14 | cosecant = csc(x) ; cosecant of x 15 | 16 | ; Hyperbolic trig functions: 17 | hypersine = sinh(x) ; hyperbolic sine of x 18 | hypercosine = cosh(x) ; hyperbolic cosine of x 19 | hypertangent = tanh(x) ; hyperbolic tangent of x 20 | hypercotangent = coth(x) ; hyperbolic cotangent of x 21 | hypersecant = sech(x) ; hyperbolic secant of x 22 | hypercosecant = csch(x) ; hyperbolic cosecant of x 23 | -------------------------------------------------------------------------------- /lib/mathomatic-master/tests/trig.in: -------------------------------------------------------------------------------- 1 | ; Trigonometric functions as complex exponentials. 2 | ; Use m4 Mathomatic instead for easy entry of these trig functions. 3 | ; Based on Euler's identity: e^(i*x) = cos(x) + i*sin(x) 4 | ; Variable x is an angle in radians. 5 | 6 | ; Unity relationship: sin(x)^2 + cos(x)^2 = 1 7 | 8 | ; sin(x) (sine of x) = cos(pi/2 - x) 9 | sin=(e^(i*x)-e^(-i*x))/(2i) 10 | 11 | ; cos(x) (cosine of x) = sin(pi/2 - x) 12 | cos=(e^(i*x)+e^(-i*x))/2 13 | 14 | ; tan(x) (tangent of x) = sin(x)/cos(x) = cot(pi/2 - x) 15 | tan=(e^(i*x)-e^(-i*x))/(i*(e^(i*x)+e^(-i*x))) 16 | 17 | ; cot(x) (cotangent of x) = cos(x)/sin(x) = tan(pi/2 - x) 18 | cot=i*(e^(i*x)+e^(-i*x))/(e^(i*x)-e^(-i*x)) 19 | 20 | ; sec(x) (secant of x) = 1/cos(x) = csc(pi/2 - x) 21 | sec=2/(e^(i*x)+e^(-i*x)) 22 | 23 | ; csc(x) (cosecant of x) = 1/sin(x) = sec(pi/2 - x) 24 | csc=2i/(e^(i*x)-e^(-i*x)) 25 | -------------------------------------------------------------------------------- /lib/mathomatic-master/update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Update the function prototypes in proto.h by using the cproto utility. 3 | # Run this whenever a new C function is added to the Mathomatic source code or 4 | # whenever a function definition is changed. 5 | 6 | cproto /dev/null || exit 1 # Test for existence of cproto utility. 7 | echo '/* Complete list of global C function prototypes for Mathomatic. */' >cproto.h 8 | echo '/* This file was created with the cproto utility by running the "./update" script. */' >>cproto.h 9 | echo '/* This file is required to compile Mathomatic quietly with the -Wall compiler option. */' >>cproto.h 10 | echo >>cproto.h 11 | cproto -DUNIX -DDEBUG *.c >>cproto.h && mv cproto.h proto.h && echo proto.h recreated. 12 | -------------------------------------------------------------------------------- /lib/mathomatic-master/zipsrc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Create a zip file in your home directory containing 3 | # the Mathomatic source distribution with no object files or binary executable files. 4 | # The current directory must be the Mathomatic build directory for this to work 5 | # and "make distclean" should have been done at some time beforehand. 6 | # Uses Info-ZIP and its command line options. 7 | 8 | if [ ! -f "VERSION" ] 9 | then 10 | echo 'zipsrc executed from an improper directory;' 11 | echo 'Must only be invoked as "./zipsrc" from the Mathomatic source directory.' 12 | exit 1 13 | fi 14 | 15 | set -e 16 | ./makenews.sh 17 | make -s -C primes distclean 18 | make -s -C lib distclean 19 | make -s doc/quickrefcard.html 20 | rm -f ~/am.zip */*.o */*.pyc */*.pyo 21 | echo Mathomatic development source code and docs version `cat VERSION`+ \ 22 | | zip -9rqzX ~/am.zip *.c *.h make* t update compile* *.txt VERSION AUTHORS COPYING NEWS *.1 zipsrc doc primes tests lib examples m4 misc icons menu \ 23 | && echo ~/am.zip created. 24 | -------------------------------------------------------------------------------- /nodewebkit_fetch/README: -------------------------------------------------------------------------------- 1 | This directory holds downloaded nodewebkit .tar.gz files, they can be removed 2 | using make webclean. 3 | 4 | Generally, you won't want to remove these because they are large and take lots 5 | of bandwidth. Please try to be nice to the NodeWebkit server! 6 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephlewis42/beancounter/10ae79fc0f99134a3696de9eaa67a7ec0bd2d9e3/screenshot.png -------------------------------------------------------------------------------- /src/beancounter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BeanCounter 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 76 | 77 | 78 | 79 |
80 | 81 |
82 | 88 |

BeanCounter

89 |
90 | 91 | 92 |
93 | 94 | 95 | 96 | 97 |
98 | 99 | 100 |
101 |
102 | 103 | 104 |
105 |

© Joseph Lewis 2014, MIT/GPL license.

106 |
107 | 108 |
109 | 110 | 111 | -------------------------------------------------------------------------------- /src/components/bower_components/platform/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "platform", 3 | "main": "platform.js", 4 | "homepage": "https://github.com/Polymer/platform", 5 | "authors": [ 6 | "The Polymer Authors" 7 | ], 8 | "description": "Integrate platform polyfills: load, build, test", 9 | "keywords": [ 10 | "polymer", 11 | "web", 12 | "components" 13 | ], 14 | "license": "BSD", 15 | "private": true, 16 | "version": "0.4.2", 17 | "_release": "0.4.2", 18 | "_resolution": { 19 | "type": "version", 20 | "tag": "0.4.2", 21 | "commit": "a2c58864021992690e6ee9ba170fbfa87af5bc9c" 22 | }, 23 | "_source": "git://github.com/Polymer/platform.git", 24 | "_target": "~0.4.2", 25 | "_originalSource": "Polymer/platform", 26 | "_direct": true 27 | } -------------------------------------------------------------------------------- /src/components/bower_components/platform/README.md: -------------------------------------------------------------------------------- 1 | Platform 2 | ======== 3 | 4 | Aggregated polyfills the Polymer platform. 5 | 6 | [![Analytics](https://ga-beacon.appspot.com/UA-39334307-2/Polymer/platform/README)](https://github.com/igrigorik/ga-beacon) 7 | -------------------------------------------------------------------------------- /src/components/bower_components/platform/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "platform", 3 | "main": "platform.js", 4 | "homepage": "https://github.com/Polymer/platform", 5 | "authors": [ 6 | "The Polymer Authors" 7 | ], 8 | "description": "Integrate platform polyfills: load, build, test", 9 | "keywords": [ 10 | "polymer", 11 | "web", 12 | "components" 13 | ], 14 | "license": "BSD", 15 | "private": true 16 | } -------------------------------------------------------------------------------- /src/components/bower_components/platform/build.log: -------------------------------------------------------------------------------- 1 | BUILD LOG 2 | --------- 3 | Build Time: 2014-10-02T15:20:01 4 | 5 | NODEJS INFORMATION 6 | ================== 7 | nodejs: v0.10.32 8 | chai: 1.9.1 9 | grunt: 0.4.4 10 | grunt-audit: 0.0.3 11 | grunt-concat-sourcemap: 0.4.1 12 | grunt-contrib-concat: 0.4.0 13 | grunt-contrib-uglify: 0.5.0 14 | grunt-contrib-yuidoc: 0.5.2 15 | grunt-karma: 0.8.3 16 | karma: 0.12.14 17 | karma-crbot-reporter: 0.0.4 18 | karma-firefox-launcher: 0.1.3 19 | karma-ie-launcher: 0.1.5 20 | karma-mocha: 0.1.4 21 | karma-safari-launcher: 0.1.1 22 | karma-script-launcher: 0.1.0 23 | mocha: 1.20.1 24 | Platform: 0.4.2 25 | 26 | REPO REVISIONS 27 | ============== 28 | WeakMap: 027f63a0b3ad8dfd26754b7943aacadee50559b7 29 | observe-js: b17a7aa27e4ed044ad503747e6d5a0011fb8d149 30 | ShadowDOM: 9472cf7a992f8c903e9db4235bc7da5d2d9640fb 31 | URL: cf5d82e444d2a029834365a8b9d185fd792227f0 32 | MutationObservers: a8aa7f9cc35c3ebef152be42f87ec2677a87f55e 33 | HTMLImports: 8d4f5ec4d6130c9035a5a4337c1a86f90e1b992d 34 | CustomElements: efdbbcb5a4ce27cd2c2b53312b15ba455554ffa8 35 | 36 | BUILD HASHES 37 | ============ 38 | build/platform.js: 448870d9303bfd7d1cfff36b6702be0714b9c4f2 -------------------------------------------------------------------------------- /src/components/bower_components/polymer/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "polymer", 3 | "version": "1.0.7", 4 | "main": [ 5 | "polymer.html" 6 | ], 7 | "license": "http://polymer.github.io/LICENSE.txt", 8 | "ignore": [ 9 | "/.*", 10 | "/test/" 11 | ], 12 | "authors": [ 13 | "The Polymer Authors (http://polymer.github.io/AUTHORS.txt)" 14 | ], 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/Polymer/polymer.git" 18 | }, 19 | "dependencies": { 20 | "webcomponentsjs": "^0.7.2" 21 | }, 22 | "devDependencies": { 23 | "web-component-tester": "*" 24 | }, 25 | "private": true, 26 | "homepage": "https://github.com/Polymer/polymer", 27 | "_release": "1.0.7", 28 | "_resolution": { 29 | "type": "version", 30 | "tag": "v1.0.7", 31 | "commit": "b39d0015ce5428232409eb3aca7ddefea899f894" 32 | }, 33 | "_source": "git://github.com/Polymer/polymer.git", 34 | "_target": "~1.0.7", 35 | "_originalSource": "Polymer/polymer", 36 | "_direct": true 37 | } -------------------------------------------------------------------------------- /src/components/bower_components/polymer/LICENSE.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The Polymer Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/components/bower_components/polymer/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "polymer", 3 | "version": "1.0.7", 4 | "main": [ 5 | "polymer.html" 6 | ], 7 | "license": "http://polymer.github.io/LICENSE.txt", 8 | "ignore": [ 9 | "/.*", 10 | "/test/" 11 | ], 12 | "authors": [ 13 | "The Polymer Authors (http://polymer.github.io/AUTHORS.txt)" 14 | ], 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/Polymer/polymer.git" 18 | }, 19 | "dependencies": { 20 | "webcomponentsjs": "^0.7.2" 21 | }, 22 | "devDependencies": { 23 | "web-component-tester": "*" 24 | }, 25 | "private": true 26 | } 27 | -------------------------------------------------------------------------------- /src/components/bower_components/polymer/build.log: -------------------------------------------------------------------------------- 1 | BUILD LOG 2 | --------- 3 | Build Time: 2015-07-16T14:37:31-0700 4 | 5 | NODEJS INFORMATION 6 | ================== 7 | nodejs: v2.3.4 8 | del: 1.2.0 9 | gulp: 3.9.0 10 | gulp-audit: 1.0.0 11 | gulp-bump: 0.3.1 12 | gulp-rename: 1.2.2 13 | gulp-replace: 0.5.3 14 | gulp-vulcanize: 6.0.1 15 | minimist: 1.1.1 16 | lazypipe: 0.2.4 17 | polyclean: 1.2.0 18 | run-sequence: 1.1.1 19 | semver: 4.3.6 20 | nodegit: 0.4.1 21 | 22 | REPO REVISIONS 23 | ============== 24 | polymer: 3d56eb0c97eb1ef90ec6942aca364d279377ff43 25 | 26 | BUILD HASHES 27 | ============ 28 | polymer-mini.html: 2429dd9d7909014a82cca9f81b8df239fc5a0599 29 | polymer-micro.html: 924b916bacfafd1a166c10fce29eab24ebd02717 30 | polymer.html: dbb7a228a8facf071dea38e4db2415a9a6becfc0 -------------------------------------------------------------------------------- /src/components/bower_components/webcomponentsjs/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webcomponentsjs", 3 | "main": "webcomponents.js", 4 | "version": "0.7.7", 5 | "homepage": "http://webcomponents.org", 6 | "authors": [ 7 | "The Polymer Authors" 8 | ], 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/webcomponents/webcomponentsjs.git" 12 | }, 13 | "keywords": [ 14 | "webcomponents" 15 | ], 16 | "license": "BSD", 17 | "ignore": [], 18 | "_release": "0.7.7", 19 | "_resolution": { 20 | "type": "version", 21 | "tag": "v0.7.7", 22 | "commit": "274327b631eeb8b48d49702e1f1570d5ce7fb93d" 23 | }, 24 | "_source": "git://github.com/Polymer/webcomponentsjs.git", 25 | "_target": "^0.7.2", 26 | "_originalSource": "webcomponentsjs" 27 | } -------------------------------------------------------------------------------- /src/components/bower_components/webcomponentsjs/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webcomponentsjs", 3 | "main": "webcomponents.js", 4 | "version": "0.7.7", 5 | "homepage": "http://webcomponents.org", 6 | "authors": [ 7 | "The Polymer Authors" 8 | ], 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/webcomponents/webcomponentsjs.git" 12 | }, 13 | "keywords": [ 14 | "webcomponents" 15 | ], 16 | "license": "BSD", 17 | "ignore": [] 18 | } 19 | -------------------------------------------------------------------------------- /src/components/bower_components/webcomponentsjs/build.log: -------------------------------------------------------------------------------- 1 | BUILD LOG 2 | --------- 3 | Build Time: 2015-07-15T17:22:18-0700 4 | 5 | NODEJS INFORMATION 6 | ================== 7 | nodejs: v2.3.4 8 | gulp: 3.9.0 9 | gulp-audit: 1.0.0 10 | gulp-concat: 2.6.0 11 | gulp-header: 1.2.2 12 | gulp-uglify: 1.2.0 13 | run-sequence: 1.1.1 14 | web-component-tester: 3.3.1 15 | 16 | REPO REVISIONS 17 | ============== 18 | webcomponentsjs: 83cd82b847c1fbeab6ba9a40d822c7d4cc96367a 19 | 20 | BUILD HASHES 21 | ============ 22 | CustomElements.js: f77fa5739800df7721b1e2bb86bdd8f260ef672d 23 | CustomElements.min.js: f1ba945213ce0495cb93919caa6d050ef114fbf5 24 | HTMLImports.js: c5473ac4fc64180ba40da4679479ed5903feb54f 25 | HTMLImports.min.js: 401ea71282cb28c1af168d7c08defecab18f5afb 26 | MutationObserver.js: 2cc42498f20f5b3842c6b5e8f7735d111967b579 27 | MutationObserver.min.js: 39a017771ac32f3edc8881b7ea20d0b2013d103e 28 | ShadowDOM.js: fd1d36923e47ed2c48719485dc7768a854e09015 29 | ShadowDOM.min.js: f771f33aab417207f8e198500918f74c1dce7314 30 | webcomponents-lite.js: 77d1bace03f086a89f9a8346fa1974205ba130b5 31 | webcomponents-lite.min.js: e87572819aedb8268109af569158d65911d8e398 32 | webcomponents.js: c4b4dd834dc76bba3b45e143adbfaae19bd0d340 33 | webcomponents.min.js: fd64b22600db44a3a428b538c468f18069435f4f -------------------------------------------------------------------------------- /src/components/bower_components/webcomponentsjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webcomponents.js", 3 | "version": "0.7.7", 4 | "description": "webcomponents.js", 5 | "main": "webcomponents.js", 6 | "directories": { 7 | "test": "tests" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/webcomponents/webcomponentsjs.git" 12 | }, 13 | "author": "The Polymer Authors", 14 | "license": { 15 | "type": "BSD-3-Clause", 16 | "url": "http://polymer.github.io/LICENSE.txt" 17 | }, 18 | "bugs": { 19 | "url": "https://github.com/webcomponents/webcomponentsjs/issues" 20 | }, 21 | "homepage": "http://webcomponents.org", 22 | "devDependencies": { 23 | "gulp": "^3.8.8", 24 | "gulp-audit": "^1.0.0", 25 | "gulp-concat": "^2.4.1", 26 | "gulp-header": "^1.1.1", 27 | "gulp-uglify": "^1.0.1", 28 | "run-sequence": "^1.0.1", 29 | "web-component-tester": "*" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/components/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/components/lorem-element.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/components/mathview/mspace.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | /*jslint browser: true*/ 5 | 6 | (function () { 7 | "use strict"; 8 | window.addEventListener("load", function () { 9 | var box, div, link, namespaceURI; 10 | // First check whether the page contains any element. 11 | namespaceURI = "http://www.w3.org/1998/Math/MathML"; 12 | // Create a div to test mspace, using Kuma's "offscreen" CSS 13 | document.body.insertAdjacentHTML("afterbegin", "
"); 14 | div = document.body.firstChild; 15 | box = div.firstChild.firstChild.getBoundingClientRect(); 16 | document.body.removeChild(div); 17 | if (Math.abs(box.height - 23) > 1 || Math.abs(box.width - 77) > 1) { 18 | // Insert the mathml.css stylesheet. 19 | link = document.createElement("link"); 20 | link.href = "mathml.css"; 21 | link.rel = "stylesheet"; 22 | document.head.appendChild(link); 23 | } 24 | }); 25 | }()); 26 | -------------------------------------------------------------------------------- /src/css/beancounter.css: -------------------------------------------------------------------------------- 1 | #results_area { 2 | display:block; 3 | width:100%; 4 | border-radius:.25em; 5 | border:1px solid gray; 6 | } 7 | 8 | #input_area { 9 | margin-bottom:1em; 10 | padding: 1em; 11 | color: #333; 12 | background-color: #f5f5f5; 13 | border: 1px solid #ccc; 14 | } 15 | 16 | #curr_eq{ 17 | } 18 | 19 | .resultinfo{ 20 | width:100%; 21 | margin-bottom:0; 22 | padding:.5em; 23 | border-top:1px solid #ddd; 24 | } 25 | 26 | .resultinfo h2{ 27 | margin-top:0em; 28 | color: rgb(66, 164, 238); 29 | font-weight: bold; 30 | font-size: 1.1em; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/css/bootstrap-tour.css: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * bootstrap-tour - v0.10.1 3 | * http://bootstraptour.com 4 | * ======================================================================== 5 | * Copyright 2012-2013 Ulrich Sossou 6 | * 7 | * ======================================================================== 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * ======================================================================== 20 | */ 21 | 22 | .tour-backdrop { 23 | position: fixed; 24 | top: 0; 25 | right: 0; 26 | bottom: 0; 27 | left: 0; 28 | z-index: 1100; 29 | background-color: #000; 30 | opacity: 0.8; 31 | filter: alpha(opacity=80); 32 | } 33 | .tour-step-backdrop { 34 | position: relative; 35 | z-index: 1101; 36 | background: inherit; 37 | } 38 | .tour-step-backdrop > td { 39 | position: relative; 40 | z-index: 1101; 41 | } 42 | .tour-step-background { 43 | position: absolute !important; 44 | z-index: 1100; 45 | background: inherit; 46 | border-radius: 6px; 47 | } 48 | .popover[class*="tour-"] { 49 | z-index: 1100; 50 | } 51 | .popover[class*="tour-"] .popover-navigation { 52 | padding: 9px 14px; 53 | } 54 | .popover[class*="tour-"] .popover-navigation *[data-role="end"] { 55 | float: right; 56 | } 57 | .popover[class*="tour-"] .popover-navigation *[data-role="prev"], 58 | .popover[class*="tour-"] .popover-navigation *[data-role="next"], 59 | .popover[class*="tour-"] .popover-navigation *[data-role="end"] { 60 | cursor: pointer; 61 | } 62 | .popover[class*="tour-"] .popover-navigation *[data-role="prev"].disabled, 63 | .popover[class*="tour-"] .popover-navigation *[data-role="next"].disabled, 64 | .popover[class*="tour-"] .popover-navigation *[data-role="end"].disabled { 65 | cursor: default; 66 | } 67 | .popover[class*="tour-"].orphan { 68 | position: fixed; 69 | margin-top: 0; 70 | } 71 | .popover[class*="tour-"].orphan .arrow { 72 | display: none; 73 | } 74 | -------------------------------------------------------------------------------- /src/css/jumbotron-narrow.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-right: 15px; 12 | padding-left: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | border-bottom: 1px solid #e5e5e5; 18 | } 19 | /* Make the masthead heading the same height as the navigation */ 20 | .header h3 { 21 | padding-bottom: 19px; 22 | margin-top: 0; 23 | margin-bottom: 0; 24 | line-height: 40px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | .container-narrow > hr { 41 | margin: 30px 0; 42 | } 43 | 44 | /* Main marketing message and sign up button */ 45 | .jumbotron { 46 | text-align: center; 47 | border-bottom: 1px solid #e5e5e5; 48 | } 49 | .jumbotron .btn { 50 | padding: 14px 24px; 51 | font-size: 21px; 52 | } 53 | 54 | /* Supporting marketing content */ 55 | .marketing { 56 | margin: 40px 0; 57 | } 58 | .marketing p + h4 { 59 | margin-top: 28px; 60 | } 61 | 62 | /* Responsive: Portrait tablets and up */ 63 | @media screen and (min-width: 768px) { 64 | /* Remove the padding we set earlier */ 65 | .header, 66 | .marketing, 67 | .footer { 68 | padding-right: 0; 69 | padding-left: 0; 70 | } 71 | /* Space out the masthead */ 72 | .header { 73 | margin-bottom: 30px; 74 | } 75 | /* Remove the bottom border on the jumbotron for visual effect */ 76 | .jumbotron { 77 | border-bottom: 0; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/js/plugins/beancounter.js: -------------------------------------------------------------------------------- 1 | /** 2 | The main file for BeanCounter's internal functions. 3 | 4 | Copyright 2014 - Joseph Lewis III 5 | 6 | Dual licensed GPLv3 + MIT 7 | **/ 8 | 9 | 'use strict'; 10 | 11 | // Show the version number of BeanCounter 12 | (function(){ 13 | 14 | var fun = function(bc){ 15 | bc.addResult("Beancounter Version", "0.3"); 16 | }; 17 | 18 | BeanCounterGeneral.registerAdvancedPlugin("version", fun); 19 | })(); 20 | 21 | // Show the version number of BeanCounter 22 | (function(){ 23 | 24 | var fun = function(bc){ 25 | bc.addResult("Copyright", "2014 Joseph Lewis <joseph@josephlewis.net>
\ 26 | Dual Licensed GPLv3 + MIT

\ 27 | Third Party Programs Used\ 28 |
    \ 29 |
  • JQuery - MIT License
  • \ 30 |
  • Bootstrap - MIT License
  • \ 31 |
  • Mathomatic - LGPL
  • \ 32 |
"); 33 | }; 34 | 35 | BeanCounterGeneral.registerAdvancedPlugin("(?:copyright|license|about)", fun); 36 | })(); 37 | -------------------------------------------------------------------------------- /src/js/plugins/calculus.js: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of BeanCounter 3 | 4 | Copyright 2014 Joseph Lewis III 5 | Licensed under the GPLv3 and MIT licenses. 6 | **/ 7 | 8 | // Differentiate 9 | (function() { 10 | 11 | var fun = function(bc, matches) { 12 | 13 | var exp = matches['Exp']; 14 | 15 | // Get the variables we can solve for 16 | var variables = bc.getVariables(); 17 | 18 | // Ensure we have a solvable system. 19 | if (!bc.isEquation() || 20 | bc.hasNumericalAnswer() || 21 | variables.length == 0) { 22 | return; 23 | } 24 | 25 | var sols = []; 26 | 27 | for (var i = 0; i < variables.length; i++) { 28 | var res = bc.processEquation(exp, "differentiate " + variables[i]); 29 | var res2 = bc.latexify(res) || res; 30 | 31 | sols.push("Differentiate for " + variables[i] + "

" + res2 + "

"); 32 | } 33 | 34 | bc.addResult("Differentials", sols.join("
")); 35 | }; 36 | 37 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 38 | })(); 39 | 40 | // Integrate 41 | (function() { 42 | 43 | var fun = function(bc, matches) { 44 | 45 | var exp = matches['Exp']; 46 | 47 | // Get the variables we can solve for 48 | var variables = bc.getVariables(); 49 | 50 | // Ensure we have a solvable system. 51 | if (!bc.isEquation() || 52 | bc.hasNumericalAnswer() || 53 | variables.length == 0) { 54 | return; 55 | } 56 | 57 | var sols = []; 58 | 59 | for (var i = 0; i < variables.length; i++) { 60 | var res = bc.processEquation(exp, "integrate " + variables[i]); 61 | var res2 = bc.latexify(res) || res; 62 | 63 | sols.push("Integrate " + variables[i] + "

" + res2 + "

"); 64 | } 65 | 66 | bc.addResult("Integrals", sols.join("
")); 67 | }; 68 | 69 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 70 | })(); 71 | -------------------------------------------------------------------------------- /src/js/plugins/converter.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | // shows raw input 4 | (function(){ 5 | var visualize = function(bc, matched){ 6 | var exp = bc.expression; 7 | 8 | bc.addResult("Input", exp); 9 | }; 10 | 11 | BeanCounterGeneral.advancedPlugins.push(visualize); 12 | })(); 13 | **/ 14 | -------------------------------------------------------------------------------- /src/js/plugins/elementary_stats.js: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of BeanCounter 3 | 4 | It is responsible for performing elementary statistics on datasets. 5 | 6 | Copyright 2014 Joseph Lewis III 7 | Licensed under the GPLv3 and MIT licenses. 8 | **/ 9 | 10 | 11 | (function(){ 12 | 13 | function sortNumber(a,b) { 14 | return a - b; 15 | } 16 | 17 | var stats = function(data){ 18 | var result = {}; 19 | 20 | // sort by number rather than string value which JS does by default 21 | data.sort(sortNumber); 22 | 23 | result["Sorted"] = data.join(", "); 24 | result["Size"] = data.length; 25 | 26 | var s = new Set(data); 27 | result["Unique Elements"] = s.size; 28 | 29 | result["Minimum"] = data[0]; 30 | result["Maximum"] = data[data.length - 1]; 31 | 32 | var sum = 0.0; 33 | for(var i in data){ 34 | sum += data[i]; 35 | } 36 | 37 | result["Sum Σ"] = sum; 38 | 39 | // mean; 40 | var mean = sum / data.length; 41 | result["Mean"] = mean; 42 | 43 | // median 44 | if(data.length % 2 == 0) { 45 | var middle = Math.floor(data.length / 2); 46 | result["Median"] = (data[middle - 1] + data[middle]) / 2.0; 47 | } else { 48 | result["Median"] = data[Math.floor(data.length / 2)]; 49 | } 50 | 51 | var variance = 0; 52 | for(var i in data){ 53 | var tmp = mean - data[i]; 54 | variance += Math.pow(tmp, 2); // squared 55 | } 56 | 57 | variance /= data.length * 1.0; 58 | 59 | result["Variance σ2"] = variance; 60 | 61 | // stddev 62 | result["Standard Deviation σ"] = Math.sqrt(variance); 63 | 64 | return result; 65 | }; 66 | 67 | var fun = function(bc, matches){ 68 | console.log("Statistics called"); 69 | var data = bc.evalList(matches["data"]); 70 | console.log("evaled list"); 71 | console.log(data); 72 | if(data.length <= 1) 73 | return; 74 | 75 | var results = stats(data); 76 | var html = bc.constructTable(results); 77 | console.log(html); 78 | bc.addResult("Statistics", html); 79 | }; 80 | 81 | 82 | var funHelp = function(bc, matches){ 83 | var data = [44, 50, 38, 96, 42, 47, 40, 39, 46, 50]; 84 | 85 | var results = stats(data); 86 | var html = "

You can do statistics on lists of numbers.

" + 87 | "

Example Input: 44, 50, 38, 96, 42, 47, 40, 39, 46, 50

" + 88 | "

Result:

" + 89 | bc.constructTable(results); 90 | 91 | 92 | console.log(html); 93 | bc.addResult("Help - Statistics", html); 94 | }; 95 | 96 | 97 | BeanCounterGeneral.registerAdvancedPlugin("{list|data}", fun); 98 | 99 | BeanCounterGeneral.registerAdvancedPlugin("help", funHelp); 100 | 101 | })(); 102 | 103 | 104 | (function(){ 105 | var fun = function(bc, matches){ 106 | 107 | var data = bc.evalList(matches["data"]); 108 | if(data.length <= 1) 109 | return; 110 | 111 | var sum = 0.0; 112 | var first = true; 113 | 114 | var textoutput = ""; 115 | for(var i in data){ 116 | if(! first) 117 | textoutput += " + "; 118 | sum += data[i]; 119 | 120 | textoutput += String(data[i]); 121 | 122 | first = false; 123 | } 124 | 125 | textoutput = String(sum) + " = " + textoutput; 126 | 127 | bc.addResult("Total", textoutput); 128 | }; 129 | 130 | BeanCounterGeneral.registerAdvancedPlugin("{list|data}", fun, "Total"); 131 | })(); 132 | -------------------------------------------------------------------------------- /src/js/plugins/firstrun.js: -------------------------------------------------------------------------------- 1 | 2 | // Prompts the user to do a tour 3 | (function(){ 4 | var fun = function(bc){ 5 | bc.addResult("Tutorial", "
First Time Using BeanCounter?

\ 6 |
"); 7 | }; 8 | 9 | BeanCounterGeneral.registerAdvancedPlugin("firstrun", fun); 10 | })(); 11 | 12 | 13 | function show_tour() 14 | { 15 | // Instance the tour 16 | var tour = new Tour({ 17 | debug: true, 18 | steps: [ 19 | { 20 | element: "#beancounter", 21 | placement: "bottom", 22 | title: "Welcome", 23 | content: "Welcome to BeanCounter, a calculator for the modern age" 24 | }, 25 | { 26 | element: "#curr_eq", 27 | title: "Input Area", 28 | placement: "bottom", 29 | content: "This is where you enter your equations. Press [enter] once its in to calculate.", 30 | onShow: function (tour) { 31 | document.getElementById("curr_eq").value = "y = 3x^2 + x^2 - 4/2 - 1x"; 32 | } 33 | 34 | }, 35 | { 36 | element: "#results_area", 37 | title: "Results Pane", 38 | placement: "top", 39 | content: "This is where the results show up", 40 | onShow: function (tour) { 41 | document.getElementById("curr_eq").value = "y = 3x^2 + x^2 - 4/2 - 1x"; 42 | 43 | document.getElementById("curr_eq").onkeyup({which:13}); 44 | } 45 | }, 46 | { 47 | element: "#aboutButton", 48 | title: "About", 49 | placement: "bottom", 50 | content: "You can get more information or view the tour again from here.", 51 | }, 52 | { 53 | element: "#results_area", 54 | title: "More Help", 55 | placement: "top", 56 | content: "For now, we'll leave you with some extra help so you can see what beancounter can do.", 57 | onShow: function (tour) { 58 | document.getElementById("curr_eq").value = "help"; 59 | document.getElementById("curr_eq").onkeyup({which:13}); 60 | } 61 | }, 62 | ]}); 63 | 64 | // Initialize the tour 65 | tour.init(); 66 | 67 | // Start the tour 68 | tour.start(); 69 | 70 | if (tour.ended()) { 71 | // decide what to do 72 | tour.restart(); 73 | } 74 | 75 | return false; 76 | } 77 | -------------------------------------------------------------------------------- /src/js/plugins/help.js: -------------------------------------------------------------------------------- 1 | 2 | // Performs a visualization of the current code 3 | (function(){ 4 | var fun = function(bc){ 5 | 6 | bc.addResult("Help - Calculator", "Beancounter can be used as a simple \ 7 | calculator, any of these should work in the entry field:\ 8 |
    \ 9 |
  • 3 + 4 - three plus four
  • \ 10 |
  • 3^2 * 8 - three squared times eight
  • \ 11 |
  • 5 / 6 - 9 - five divided by six minus nine
  • \ 12 |
  • 5 / (6 - 9) - five over six minus nine
  • \ 13 |
"); 14 | 15 | bc.addResult("Help - Expressions", "Beancounter can also handle \ 16 | expressions, it will simplify where needed and show the variables:\ 17 |
    \ 18 |
  • 3x + 2x + 1
  • \ 19 |
"); 20 | 21 | bc.addResult("Help - Equations", "Beancounter can also handle \ 22 | equations, it will extract variables, solve for the different variables,\ 23 | differentiate and integrate:\ 24 |
    \ 25 |
  • y = 3x + 4
  • \ 26 |
"); 27 | 28 | bc.addResult("Help - Keys", "
    \ 29 |
  • Use the up and down arrow keys in the entry area to work through your past entries.
  • \ 30 |
"); 31 | }; 32 | 33 | BeanCounterGeneral.registerAdvancedPlugin("help", fun); 34 | })(); 35 | -------------------------------------------------------------------------------- /src/js/plugins/plot.js: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of BeanCounter 3 | 4 | Copyright 2014 Joseph Lewis III 5 | Licensed under the MIT license. 6 | **/ 7 | 8 | "using strict;" 9 | 10 | require(['scripts/config'], function() { 11 | var fun = function(bc){ 12 | 13 | vars = bc.getVariables() 14 | if(vars.length == 0 || vars.length > 1) { 15 | return 16 | } 17 | 18 | var v = vars[0] 19 | 20 | // we do 1/10th of a unit for decent plotting without tearing through 21 | // the processor 22 | 23 | var start = -10 24 | var end = 10 25 | var step = 0.1 26 | 27 | for(var i = start; i < end; i += step) { 28 | 29 | console.log(bc.eval()); 30 | } 31 | 32 | bc.addResult("Plot", ""); 33 | }; 34 | 35 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 36 | }); 37 | -------------------------------------------------------------------------------- /src/js/plugins/primality.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | function isPrime(n) { 6 | if (isNaN(n) || !isFinite(n) || n%1 || n<2) return false; 7 | if (n%2==0) return (n==2); 8 | if (n%3==0) return (n==3); 9 | var m=Math.sqrt(n); 10 | for (var i=5;i<=m;i+=6) { 11 | if (n%i==0) return false; 12 | if (n%(i+2)==0) return false; 13 | } 14 | return true; 15 | } 16 | -------------------------------------------------------------------------------- /src/js/plugins/solve.js: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of BeanCounter 3 | 4 | Copyright 2014 Joseph Lewis III 5 | Licensed under the GPLv3 and MIT licenses. 6 | **/ 7 | 8 | // Solve equations for their different variables. 9 | (function(){ 10 | 11 | var fun = function(bc, matches){ 12 | 13 | var exp = matches['Exp']; 14 | 15 | // Ensure we have a solvable system. 16 | if( ! bc.isEquation() || 17 | bc.hasNumericalAnswer()){ 18 | return; 19 | } 20 | 21 | // Get the variables we can solve for 22 | var res = bc.processEquation(exp, "variables"); 23 | var variables = res.split("\n"); 24 | 25 | if(variables.length == 0){ 26 | return; 27 | } 28 | 29 | var sols = []; 30 | 31 | var i; 32 | for(i = 0; i < variables.length; i++) 33 | { 34 | if(variables[i] === "" || variables[i] === "answer"){ 35 | continue; 36 | } 37 | 38 | var res = bc.processEquation(exp, "solve " + variables[i]); 39 | var res2 = bc.latexify(res) || res; 40 | 41 | sols.push("Solve for " + variables[i] + "

" + res2 + "

"); 42 | } 43 | 44 | bc.addResult("Solutions", sols.join("
")); 45 | }; 46 | 47 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 48 | })(); 49 | -------------------------------------------------------------------------------- /src/js/plugins/variables.js: -------------------------------------------------------------------------------- 1 | /** 2 | This file is part of BeanCounter 3 | 4 | Copyright 2014 Joseph Lewis III 5 | Licensed under the GPLv3 and MIT licenses. 6 | **/ 7 | 8 | // List the variables the user input 9 | (function(){ 10 | 'use strict'; 11 | 12 | var fun = function(bc){ 13 | 14 | if(bc.hasNumericalAnswer()) 15 | return; // we don't extract for numerically solvable expressions 16 | 17 | try 18 | { 19 | var res = bc.processEquation(bc.expression, "variables"); 20 | res = res.replace("\n", ", "); 21 | 22 | bc.addResult("Variables", res); 23 | } 24 | catch(e) 25 | { 26 | console.log(e); 27 | } 28 | }; 29 | 30 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 31 | })(); 32 | -------------------------------------------------------------------------------- /src/js/plugins/visualize.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | // shows raw input 4 | (function(){ 5 | var visualize = function(bc){ 6 | var exp = bc.expression; 7 | 8 | bc.addResult("Input", exp); 9 | }; 10 | 11 | BeanCounterGeneral.basicPlugins.push(visualize); 12 | })(); 13 | 14 | 15 | // Performs a visualization of the current code 16 | (function(){ 17 | var fun = function(bc){ 18 | 19 | var exp = bc.expression; 20 | var tex = bc.latexify(exp); 21 | if(tex != "") 22 | { 23 | bc.addResult("Representation", tex); 24 | } 25 | }; 26 | 27 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 28 | })(); 29 | 30 | 31 | // Returns the answer if it is simple 32 | (function(){ 33 | var fun = function(bc){ 34 | var exp = bc.expression; 35 | var res = bc.processEquation(exp); 36 | if(res.indexOf("answer =") > -1) 37 | { 38 | bc.addResult("Answer", res.split("=")[1]); 39 | isbasic = true; 40 | } 41 | 42 | }; 43 | 44 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 45 | })(); 46 | 47 | 48 | // Simplifies the equation 49 | (function(){ 50 | var fun = function(bc){ 51 | if(bc.hasNumericalAnswer()) 52 | return; 53 | 54 | var simple = bc.processEquation(bc.expression, "simplify"); 55 | if(simple === bc.expression) 56 | return; 57 | 58 | var tex = bc.latexify(simple); 59 | if(tex != "") 60 | bc.addResult("Simplified", tex); 61 | }; 62 | 63 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 64 | })(); 65 | 66 | 67 | // an alternate using our new module 68 | (function(){ 69 | 70 | var fun = function(bc){ 71 | var exp = bc.expression; 72 | var res = bc.evaluate(exp); 73 | bc.addResult("Answer2", "" + res); 74 | }; 75 | 76 | BeanCounterGeneral.registerAdvancedPlugin("{expression|Exp}", fun); 77 | })(); 78 | 79 | 80 | 81 | // shows hello world 82 | (function(){ 83 | var visualize = function(bc, matched){ 84 | bc.addResult("Hello, " + matched["Name"], ""); 85 | }; 86 | 87 | BeanCounterGeneral.registerAdvancedPlugin("Hello {text|Name}", visualize); 88 | })(); 89 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BeanCounter", 3 | "main": "beancounter.html", 4 | 5 | "window": { 6 | "title": "BeanCounter 0.1", 7 | "toolbar": false, 8 | "frame": true, 9 | "width": 800, 10 | "height": 500, 11 | "position": "mouse", 12 | "min_width": 400, 13 | "min_height": 200 14 | }, 15 | "webkit": { 16 | "plugin": true 17 | } 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/sources/calculator.lex: -------------------------------------------------------------------------------- 1 | /* description: Parses end executes mathematical expressions. */ 2 | 3 | %define moduleName "calculator" 4 | 5 | /* lexical grammar */ 6 | %lex 7 | %% 8 | \s+ /* skip whitespace */ 9 | [0-9]+("."[0-9]+)?\b return 'NUMBER'; 10 | "=" return '='; 11 | "*" return '*'; 12 | "/" return '/'; 13 | "-" return '-'; 14 | "+" return '+'; 15 | "^" return '^'; 16 | "(" return '('; 17 | ")" return ')'; 18 | "sqrt" return 'SQRT'; 19 | "pi" return 'PI'; 20 | "e" return 'E'; 21 | "sin" return 'SIN'; 22 | "cos" return 'COS'; 23 | "tan" return 'TAN'; 24 | "abs" return 'ABS'; 25 | "ceil" return 'CEIL'; 26 | "floor" return 'FLOOR'; 27 | "log" return 'LOG'; 28 | ";" return ';'; 29 | \w+ return 'VARNAME'; 30 | <> return 'EOF'; 31 | 32 | /lex 33 | 34 | /* operator associations and precedence */ 35 | 36 | %left '+' '-' 37 | %left '*' '/' 38 | %left '^' 39 | %left UMINUS 40 | 41 | %start expressions 42 | 43 | %% /* language grammar */ 44 | 45 | expressions 46 | : definitions ';' e EOF 47 | %{ 48 | yy = {}; 49 | console.log($3); 50 | return $3; 51 | %} 52 | | e EOF 53 | %{ 54 | yy = {}; 55 | console.log($1); 56 | return $1; 57 | %} 58 | ; 59 | 60 | definitions 61 | : definition 62 | | definitions definition 63 | ; 64 | 65 | definition 66 | : VARNAME '=' NUMBER 67 | {yy["VAR_" + $1] = parseFloat($3);} 68 | ; 69 | 70 | e 71 | : e '+' e 72 | {$$ = $1 + $3;} 73 | | e '-' e 74 | {$$ = $1 - $3;} 75 | | e '*' e 76 | {$$ = $1 * $3;} 77 | | e '/' e 78 | {$$ = $1 / $3;} 79 | | e '^' e 80 | {$$ = Math.pow($1, $3);} 81 | | '-' e %prec UMINUS 82 | {$$ = -$2;} 83 | | '(' e ')' 84 | {$$ = $2;} 85 | | SQRT '(' e ')' 86 | {$$ = Math.sqrt( $3 );} 87 | | SIN '(' e ')' 88 | {$$ = Math.sin( $3 );} 89 | | COS '(' e ')' 90 | {$$ = Math.cos( $3 );} 91 | | TAN '(' e ')' 92 | {$$ = Math.tan( $3 );} 93 | | ABS '(' e ')' 94 | {$$ = Math.abs( $3 );} 95 | | CEIL '(' e ')' 96 | {$$ = Math.ceil( $3 );} 97 | | FLOOR '(' e ')' 98 | {$$ = Math.floor( $3 );} 99 | | LOG '(' e ')' 100 | {$$ = Math.log( $3 );} 101 | | NUMBER 102 | {$$ = parseFloat(yytext);} 103 | | E 104 | {$$ = Math.E;} 105 | | PI 106 | {$$ = Math.PI;} 107 | | VARNAME 108 | {$$ = yy["VAR_" + yytext];} 109 | ; 110 | 111 | %% /* Extra Code */ 112 | -------------------------------------------------------------------------------- /src/sources/latex_generator.lex: -------------------------------------------------------------------------------- 1 | /* description: Parses end executes mathematical expressions. */ 2 | 3 | /* lexical grammar */ 4 | %lex 5 | 6 | %% 7 | \s+ /* skip whitespace */ 8 | [0-9]+("."[0-9]+)?\b return 'NUMBER'; 9 | "=" return '='; 10 | "*" return '*'; 11 | "/" return '/'; 12 | "-" return '-'; 13 | "+" return '+'; 14 | "^" return '^'; 15 | "(" return '('; 16 | ")" return ')'; 17 | "sqrt" return 'SQRT'; 18 | "pi" return 'PI'; 19 | "e" return 'E'; 20 | \w+ return 'VARNAME'; 21 | <> return 'EOF'; 22 | 23 | /lex 24 | 25 | /* operator associations and precedence */ 26 | 27 | %left '+' '-' 28 | %left '*' '/' 29 | %left '^' 30 | %left UMINUS 31 | %left '=' 32 | 33 | %start expressions 34 | 35 | %% /* language grammar */ 36 | 37 | expressions 38 | : e '=' e EOF 39 | {return "{" + $1 + "} = {" + $3 + "}";} 40 | 41 | | e EOF 42 | {console.log($1); return $1;} 43 | ; 44 | 45 | e 46 | : e '+' e 47 | {$$ = "{" + $1 + "} + {" + $3 + "}";} 48 | | e '-' e 49 | {$$ = "{" + $1 + "} - {" + $3 + "}";} 50 | | e '*' e 51 | {$$ = "{" + $1 + "} \\bullet {" + $3 + "}";} 52 | | e '/' e 53 | {$$ = "{" + $1 + "}\\over{" + $3 + "}";} 54 | | e '^' e 55 | {$$ = "{" + $1 + "}^{" + $3 + "}";} 56 | | '-' e %prec UMINUS 57 | {$$ = "{-" + $2 + "}";} 58 | | '(' e ')' 59 | {$$ = "({" + $2 + "})";} 60 | | SQRT '(' e ')' 61 | {$$ = "\\sqrt{" + $3 + "}";} 62 | | NUMBER 63 | {$$ = yytext;} 64 | | E 65 | {$$ = "e";} 66 | | PI 67 | {$$ = "\\pi";} 68 | | VARNAME 69 | {$$ = yytext;} 70 | ; 71 | 72 | %% 73 | 74 | var Latexify = parser.parse; 75 | -------------------------------------------------------------------------------- /src/sources/mathml_generator.lex: -------------------------------------------------------------------------------- 1 | /* description: Parses end executes mathematical expressions. */ 2 | 3 | /* lexical grammar */ 4 | %lex 5 | 6 | %% 7 | \s+ /* skip whitespace */ 8 | [0-9]+("."[0-9]+)?\b return 'NUMBER'; 9 | "=" return '='; 10 | "*" return '*'; 11 | "/" return '/'; 12 | "-" return '-'; 13 | "+" return '+'; 14 | "^" return '^'; 15 | "(" return '('; 16 | ")" return ')'; 17 | "sqrt" return 'SQRT'; 18 | "pi" return 'PI'; 19 | "e" return 'E'; 20 | \w+ return 'VARNAME'; 21 | <> return 'EOF'; 22 | 23 | /lex 24 | 25 | /* operator associations and precedence */ 26 | 27 | %left '+' '-' 28 | %left '*' '/' 29 | %left '^' 30 | %left UMINUS 31 | %left '=' 32 | 33 | %start expressions 34 | 35 | %% /* language grammar */ 36 | 37 | expressions 38 | : e '=' e EOF 39 | {return "" + $1 + " = " + $3 + "";} 40 | 41 | | e EOF 42 | {console.log($1); return "" + $1 + "";} 43 | ; 44 | 45 | e 46 | : e '+' e 47 | {$$ = "" + $1 + " + " + $3 + "";} 48 | | e '-' e 49 | {$$ = "" + $1 + " -" + $3 + "";} 50 | | e '*' e 51 | {$$ = "" + $1 + " " + $3 + "";} 52 | | e '/' e 53 | {$$ = "" + $1 + " " + $3 + "";} 54 | | e '^' e 55 | {$$ = "" + $1 + " " + $3 + "";} 56 | | '-' e %prec UMINUS 57 | {$$ = "-" + $2 + "";} 58 | | '(' e ')' 59 | {$$ = " ( " + $2 + " ) ";} 60 | | SQRT '(' e ')' 61 | {$$ = "" + $3 + "";} 62 | | NUMBER 63 | {$$ = "" + yytext + "";} 64 | | E 65 | {$$ = "e";} 66 | | PI 67 | {$$ = "π";} 68 | | VARNAME 69 | {$$ = "" + yytext + "";} 70 | ; 71 | 72 | %% 73 | 74 | var Mathmlify = parser.parse; 75 | --------------------------------------------------------------------------------