All Projects → soegaard → racket-cas

soegaard / racket-cas

Licence: other
Simple computer algebra system

Programming Languages

racket
414 projects

Projects that are alternatives of or similar to racket-cas

Algebra Latex
Parse and calculate latex formatted math
Stars: ✭ 20 (-65.52%)
Mutual labels:  algebra, math, cas
Gap
Main development repository for GAP - Groups, Algorithms, Programming, a System for Computational Discrete Algebra
Stars: ✭ 447 (+670.69%)
Mutual labels:  algebra, math
Newton Api
➗ A really micro micro-service for advanced math.
Stars: ✭ 358 (+517.24%)
Mutual labels:  algebra, math
Unplugged
Open book about math and computer science.
Stars: ✭ 1,189 (+1950%)
Mutual labels:  algebra, math
Grassmann.jl
⟨Leibniz-Grassmann-Clifford⟩ differential geometric algebra / multivector simplicial complex
Stars: ✭ 289 (+398.28%)
Mutual labels:  algebra, math
Nerdamer
a symbolic math expression evaluator for javascript
Stars: ✭ 322 (+455.17%)
Mutual labels:  algebra, math
Algebrite
Computer Algebra System in Javascript (Coffeescript)
Stars: ✭ 800 (+1279.31%)
Mutual labels:  algebra, cas
Euler
The open-source computational framework for the Swift language
Stars: ✭ 37 (-36.21%)
Mutual labels:  algebra, math
Abstract Algebra Cheatsheet
📗 A visualization of key structures in abstract algebra.
Stars: ✭ 137 (+136.21%)
Mutual labels:  algebra, math
Alga
Abstract algebra for Rust.
Stars: ✭ 154 (+165.52%)
Mutual labels:  algebra, math
Math Php
Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
Stars: ✭ 2,009 (+3363.79%)
Mutual labels:  algebra, math
augmath
Interactive Computer Algebra System. Augmenting how we *do* mathematics using computers
Stars: ✭ 41 (-29.31%)
Mutual labels:  algebra, math
Mather
zzllrr mather(an offline tool for Math learning, education and research)小乐数学,离线可用的数学学习(自学或教学)、研究辅助工具。计划覆盖数学全部学科的解题、作图、演示、探索工具箱。目前是演示Demo版(抛转引玉),但已经支持数学公式编辑显示,部分作图功能,部分学科,如线性代数、离散数学的部分解题功能。最终目标是推动专业数学家、编程专家、教育工作者、科普工作者共同打造出更加专业级的Mather数学工具
Stars: ✭ 270 (+365.52%)
Mutual labels:  algebra, math
Atosym
algebraic expressions parsing and evaluation through a property system based algorithm
Stars: ✭ 15 (-74.14%)
Mutual labels:  algebra, math
Angourimath
Open-source symbolic algebra library for C# and F#. One of the most powerful in .NET
Stars: ✭ 266 (+358.62%)
Mutual labels:  algebra, math
Fasteval
Fast and safe evaluation of algebraic expressions
Stars: ✭ 177 (+205.17%)
Mutual labels:  algebra, math
Algebra
means completeness and balancing, from the Arabic word الجبر
Stars: ✭ 92 (+58.62%)
Mutual labels:  algebra, math
Reduce.jl
Symbolic parser generator for Julia language expressions using REDUCE algebra term rewriter
Stars: ✭ 172 (+196.55%)
Mutual labels:  algebra, math
Mathematics for Machine Learning
Learn mathematics behind machine learning and explore different mathematics in machine learning.
Stars: ✭ 28 (-51.72%)
Mutual labels:  algebra, math
Tensor
A library and extension that provides objects for scientific computing in PHP.
Stars: ✭ 146 (+151.72%)
Mutual labels:  math
racket-cas
==========

A Simple Computer Algebra System (CAS) for Racket
-------------------------------------------------

Here is a short example. Open racket-cas.rkt in DrRacket and run it.

To begin write:
    > (require racket-cas/repl)

This changes the meaning of quote such that automatic simplifier
will simplify all quoted and quasi-quoted expressions.
    > '(+ x 2 a 3 (* 4 x))
    '(+ 5 a (* 5 x))

Also, in the repl it can be convenient to write x instead of 'x so,
we will turn on auto quoting:

    > (require racket-cas/auto-quote)
    > x
    'x

TeX output is available;
    > (tex (expand '(expt (+ a b) 2)))

This can also be rendered at the REPL:
    > (render (expand '(expt (+ a b) 2)))

The Taylor series of sin(x) around x=2 of degree 3:
    > (taylor '(sin x) x 2 3)
    '(+ (* -1/2 (expt (+ -2 x) 2) (sin 2)) (* -1/6 (expt (+ -2 x) 3)
(cos 2)) (* (+ -2 x) (cos 2)) (sin 2))

Since (sin 2) can not be represented exactly it is not evaluated
numerically. Use N (for numeric) to force numeric evaluation:
    > (N (expand (taylor '(sin x) x 2 3)))
    '(+  -0.6318662024609201
       (* 2.2347416901985055         x)
      (* -0.8707955499599832 (expt x 2))
      (* 0.0693578060911904  (expt x 3)))

An alternative is to use 2.0 instead of 2.
   > (expand (taylor '(sin x) x 2.0 3))
   <same result>
This works since 2.0 is an inexact number, and inexactness is contagious.

We expect the Taylor series around 2.0 approximates sin(x) for x near 2.0.
Let's compare the Taylor series in 2.1 with sin(2.1).

First we substitute the x in the Taylor series with 2.1.
    > (subst (expand (N (taylor '(sin x) x 2 3))) x 2.1)
    0.8632056138429305
The we calculate sin(2.1) for comparision:
    > (sin 2.1)
    0.8632093666488738

To show that Racket CAS also supports bigfloats (floating point 
numbers with an arbitrary number of decimals), let's see what
the result is with a precision of 100 binary decimals:
    > (bf-N (taylor '(sin x) x 2 3) 100 x (bf 2.1))
    (bf #e0.86320561384293019376447471077597)

We can use standard plot library to draw a few graphs of the Taylor polynomials.
The plot library expects standard Racket functions from number to number.
The function  compile  will turn a symbolic expression into a normal Racket function.
    > (require plot)
    > (plot (list (function (compile (taylor '(sin x) x 0 5)) #:color "green")
                  (function sin #:color "red" -3.14 3.14)))
    <nice graphs appear in DrRacket>

Let's compare Taylor polynomials of various orders.
    > (plot (append (for/list ([n 6]) (function (compile (taylor '(cos x) x pi n)) #:color (+ n 1)))
                    (list (function cos #:color "red")))
            #:x-min (- pi) #:x-max (* 3 pi) #:y-min -2 #:y-max 2)
     <graphs appear>

Racket CAS can compute limits for x->a where a is a real number.
The  limit  function will apply l'Hospital's rule if neccessary (upto 10 times).
Standard high school limits therefore work:
    > (limit '(/ (sin x) x) x 0)
   1

For anyone interested in contributing to the code, the main file is racket-cas/racket-cas.rkt.
In that file quote behaves as the standard Racket quote.
Since +, *, -, / are bound to their standard Racket meaning,
the functions ⊕ ⊗ ⊖ ⊘ are used where the arguments are (automatically simplified) 
symbolic expressions.

For functions such as expt, sin etc. the corresponding functions that handle symbolic
expressions are Expt, Sin, etc.


Thanks to all for contributing code and sending in bugs.
In particular, thanks to the following contributors:

Contributors
------------
 - Bowen Fu  (integrate, complex numbers, together, combine and more)


Related
-------
Check out another CAS for Racket, https://github.com/Metaxal/rascas .


Enjoy
/soegaard
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].