aboutsummaryrefslogtreecommitdiff

Symbolic differentiation of mathematical expressions

Features

  • Parses mathematical expressions
  • Differentiates them symbolically
  • Can print resulting derivative in latex format

Installation

To install this program you need a working C compiler and a posix compatible system (not Windows). To install it clone the git repository and run make.

$ git clone https://git.marioforzanini.com/dwrt
$ cd dwrt
$ make
$ sudo make install

The last command installs the binary in /usr/local/bin, make sure you add this directory to your $PATH to be able to find the binary. If you don't know what this means or how to do it, just look up 'PATH variable linux' on the web.

Usage

Once installed, running the program without any option yields a simple help message:

$ dwrt
usage: dwrt [-l] variable

So if you want to differentiate with respect to variable x, you should invoke dwrt with 'x' as an argument:

$ dwrt x
sin(x)
cos(x)
^D

Where ^D indicates that the user pressed Control and the letter d on the keyboard at the same time, on most unix systems this sends the EOF (end of file) character.

To avoid having to do this you can also:

$ echo "sin(x)" | dwrt x

Latex output

The optional switch -l instructs the program to produce its output in latex format:

$ echo "sin(x)" | dwrt -l x
\cos\left(x\right)

To see how this could be useful, take a look at (to_pdf.sh)[./to_pdf.sh].

Tests

If you want to run unit tests:

$ make clean
$ make test

If you also want test coverage:

$ make clean
$ make COV=1
$ make COV=1 test
$ make cov

then open lcov/index.html in your favourite browser.

Formatting

All code is formatted using knfmt, so before contributing run

$ make format

Todo

  • Simplify expressions
  • Write some integration tests
  • eqn(1) output