LTFunctions 2.1

LTFunctions was originally released onto CodeProject by user lucatabanelli in August 2006.

I began programming in 2010, while I was in high school. In 2011, I started work on a program called JeniMath: a scientific and statistical calculator named after my then-girlfriend. For JeniMath, I took LTFunctions and made an updated and overhauled version of it, called LTFunctions 2 (how original).

I grew bored of work on JeniMath in 2012, and since I stopped working on JeniMath, I haven't had any reason to touch or update LTFunctions 2 either. Beyond that, I haven't really had much use for LTFunctions 2, but I've still been proud about what the library turned into, and the functionality it offered.

LTFunctions 2 comes with a number of features:

  • Order of operations supported, including parantheses
    • (implied multiplication does not work though)
  • Supports 6 variables: U, V, W, X, Y, Z
  • Constant values: Pi, e, and the Golden Ratio
  • Trigonometry functions (sin, tan, cos), including inverse and hyperbolic versions
  • Logarithmic functions, in base 10 and base e (log(100) or lne(5))
  • Conversion between degrees and radians (deg(3.1) or rad(90) )
  • A handful of other functions
    • Exponent (2^3)
    • Square root (sqr(36))
    • Absolute value (abs(-13))
    • Floor and ceiling (flr(40.3) and cel(29.6))

I originally released LTFunctions 2 on an older website under the LGPL license. I am now re-releasing LTFunctions 2, but with the MIT License. The MIT License is a lot more permissive than the LGPL (or CPOL) and is pretty common to find in open-source software nowadays, and so that's why I decided to relicense it.

The original LTFunctions library was released without a license explicitly attached to it, but it seems that the CodeProject Open License (CPOL) was applied to the library after I encountered it and released my modification; since I acquired the code before the CPOL was applied though, I'm operating as though the license doesn't apply to me. You can use LTFunctions 2 under the terms of the CPOL if you'd like.

How to use

Here is an overview about how to use it:

VB.NET

Dim func As LTFunctions.Functions = New LTFunctions.Functions

func.Function = "2+x"

' Defining variables (you don't need to define all of them if you don't want)
func.U = 0
func.V = 1
func.W = 2
func.X = 3.14
func.Y = 4
func.Z = 5.1

func.BuildFunctionTree()

Console.WriteLine(func.Result)
Console.WriteLine(func.ErrorDescription)
If func.ErrorAt >= 0 Then
    Console.WriteLine(func.ErrorAt)
End If

C#

var func = new LTFunctions.Functions();

func.Function = "2+x";

⁄⁄ Defining variables (you don't need to define all of them if you don't want)
func.U = 0;
func.V = 1;
func.W = 2;
func.X = 3.14M;
func.Y = 4;
func.Z = 5.1M;

func.BuildFunctionTree();

Console.WriteLine(func.Result());
Console.WriteLine(func.ErrorDescription);
if (func.ErrorAt >= 0)
{
    Console.WriteLine(func.ErrorAt);
}

Why is it "2.1"

I'll be honest, the change history has been lost to me. This was built in a time before I discovered products like SVN or Git. I can maybe see if I can dig into old files and see if I can turn up anything, but it's probably unlikely I will. All I know is that "2.1.3" is the most recent version I made; what this offers over "2.1" or even "2.0", I do not know.

ArithmeticParser

I nowadays use a newer and more compact library called ArithmeticParser, which you can find as part of the Solid Shine UI library or available separately as its own library.

LTFunctions still definitely works though, and is still definitely usable in any code you want to make.

ArithmeticParser lacks a number of the advanced features that LTFunctions has, such as trigonometry and logarithmic functions, but does support implied multiplication and is overall more tested, faster, and easier to understand.