CodePlexProject Hosting for Open Source Software

**Mathos** is** amazingly easy** to **use** and
**understand **for everyone with basic knowledge of any .NET Framework based language, e.g.
**Visual Basic, Visual C#**, **Iron Python**, **Iron Rugby**, etc.

Find out more at http://mathosproject.com/!

- Perform basic and more complex calculations with Fractions.
- Convert different units (length, speed, mass, area, volyme), and numeral systems.
- Include Coordinates to perform simple and more advanced calculations such as
*Slope, MidPoint, Distance.* - Perform calculations with geometrical shapes (2 dimensional), such as
*Circles, Squares, Rectangles, Triangles, Parallelograms, Trapezoids, Cubes**(3 dimensional),*and*Spheres, Square pyramids, Rectangular prisms, Right circular cones**Right circular cylinders*. - Use the Mathos's Syntax, to calculate with less code typing.

- Make financial calculations.
- Parse simple and more advanced expressions with a Math Parser.
- And of course, there are lots of other cool features available in Mathos!

Mathos is single library that contains different functions in areas like: *Arithmetic*,
*Coordinate Geometry*, *Fractions*. For the moment, it's not quite finished, and more features will be added.

The second part of this project is a Math Parser. At this development stage, you should be able to do a lot of cool stuff with it, for instance, customize functions, add variables, before and on the run time. You can also add and/or edit operators, and change the way they should behave.

- Fractions
- Declaration
- Addition
- Subtraction
- Multiplication & Division
- Comparison
- Complex Fractions

- Coordinates, etc.
- Numbers
- Mathos Syntax

Fraction is a base type in Mathos. You can express a point in terms of fractions, and do a lot of other fun stuff. Fractions can for instance be added, subtracted, multiplied, divided by each other.
*(namespace: Mathos.Arithmetic.Fractions)*

**Declaration**

Fraction fractA = new Fraction(21, 7); Fraction fractB = "21/7"; Fraction fractC = 3; Assert.IsTrue(fractA == fractB); Assert.IsTrue(fractA == fractC); Assert.IsTrue(fractB == fractC);

**Addition**

Fraction fractA = new Fraction(2, 3); Fraction fractB = new Fraction(5, 3); Assert.IsTrue(fractA + fractB == new Fraction(7, 3)); Fraction fractC = new Fraction(3, 5); Fraction fractD = new Fraction(1, 4); Assert.IsTrue(fractC + fractD == new Fraction(17, 20)); Assert.IsTrue(new Fraction("1/4") + new Fraction("2/8") == new Fraction(6, 12)); Assert.IsTrue(2 + new Fraction(2, 9) == "20/9"); Assert.IsFalse("2" + "2/9" == "20/9"); // you need to have at least one definition of Fraction

**Subtraction**

Fraction fractA = "6/8"; Fraction fractB = "2/8"; Fraction result = fractA - fractB; Assert.IsTrue(result == "1/2");

**Multiplication & Division**

Fraction fractA = "3/62"; Fraction fractB = "5/54"; Fraction result = fractA * fractB; Assert.IsTrue("5/1116" / fractA == fractB);

**Comparison**

Assert.IsTrue(new Fraction(1, 2) >= new Fraction(1, 3)); Assert.IsTrue("1/2" < new Fraction(2, 3));

**Complex Fractions**

A complex fraction is actually behaving as a normal fraction, but instead of declaring the *nominator* and the *denominator
*as integers, we pass in two fractions.

// basic definition of a complex fraction Fraction complex1 = new Fraction(new Fraction(3, 2), new Fraction(2, 5)); Fraction complex2 = new Fraction("3/4","2/6"); // but under the hood, we are actually doing following Fraction complex3 = new Fraction(3, 2) / new Fraction(2, 5);

This struct is a good way to store coordinates as a variable inside .NET. The difference between System.Drawing.Point is that this structure is simple, small, and easy to work with.

// declarations Coordinate coord1 = new Coordinate(3, 4); Coordinate coord2 = "5,7"; // the result can be expressed as a fraction Fraction midPoint1 = Calculate.Slope(coord1, coord2); // ... or as a decimal decimal midPoint2 = Calculate.Slope("3,4", "5,7"); decimal distance = Calculate.Distance(coord1, coord2);

This namespace contains classes that are useful to use when performing simple checks on all kinds of integers. It contains three classes
*Get*, *Check*, and *Convert*. It's the *Get* and the
*Convert* classes that are, for the moment, supported by the extension method,
*Mathos Syntax*.

/* Using "Numbers" directly */ bool myNumberIsPrime = Mathos.Arithmetic.Numbers.Check.IsPrime(29); long PositiveNumber = Mathos.Arithmetic.Numbers.Convert.ToPositive(-2); long GDC = Mathos.Arithmetic.Numbers.Get.gdc(20, 4); foreach (long factor in Mathos.Arithmetic.Numbers.Get.Factors(81)) { System.Diagnostics.Debug.WriteLine("Factor: " + factor.ToString()); }

This is a namespace that contains extension methods to the *Arithmetic* namespace. Instead of typing the entire function name, in order to check a small thing, you can simply do as below:

/* * Mathos.Syntax is a collection of extenssion methods * for the common value types in .NET Framework. */ int myNumber = 29; bool myNumberIsPrime = myNumber.IsPrime(); // true bool myNumberIsOdd = myNumber.IsEven(); // false bool myNumberIsPositive = myNumber.IsPositive(); // true long mySecondNumber = 32; long myThirdNumber = 9; bool AreCoprimes = mySecondNumber.IsCoprime(myThirdNumber); // true

Last edited Mar 30, 2013 at 12:23 PM by artemlos, version 1