EquTranslator 4.0.101

There is a newer version of this package available.
See the version list below for details.
dotnet add package EquTranslator --version 4.0.101                
NuGet\Install-Package EquTranslator -Version 4.0.101                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EquTranslator" Version="4.0.101" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EquTranslator --version 4.0.101                
#r "nuget: EquTranslator, 4.0.101"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EquTranslator as a Cake Addin
#addin nuget:?package=EquTranslator&version=4.0.101

// Install EquTranslator as a Cake Tool
#tool nuget:?package=EquTranslator&version=4.0.101                

EquTranslator is fast and compact math parser/evaluator with pre-build feature and user-friendly interface. It uses recursive descent and operator precedence rules to parse and evaluate run-time defined strings as math expressions.

Valid math expressions should consist of :

  • Variables should start from a letter and be no more than 32 characters long. The math expression may have unlimited number of variables.
  • Arithmetic operations : +, -, *, / , ^ .
  • Functions - set of predefined functions: : abs(x), acos(x), asin(x), atan(x), ceil(x), cos(x), cosh(x), exp(x), floor(x), J0(x), J1(x), ln(x), log10(x), sin(x), sinh(x), sqrt(x), tan(x), tanh(x), Y0(x), Y1(x). Also, users can define their own function to improve performance and extend functionality.

The main characteristics of EquTranslator :

  • Extremely fast.
  • Friendly interface and error handling support.
  • Safe Multithreading.
  • Supports unlimited number of variables.
  • Math expression must be presented as double byte(UNICODE) string.
  • Can be extended by user defined functions.
  • Target platform : x86 and x64.

You can find list of error messages in EquTypes.h file.

#include <iostream>
#include "EquWin32.h"
#include "EquTypes.h"


// Error handler
void  ErrorHandler(EQUHANDLE hnd, int errCode, const wchar_t* message, const wchar_t* message2)
{
	std::cout << "Error: " << message << ": " << message2 << std::endl;
	throw errCode;
}


//User defined function
TCalc  pow3(TCalc x)
{
	return x * x * x;
}


int main(int argc, char* argv[])
{
	const wchar_t* mathExp = L"1.2e-3+x+2.3*(1-sin(y/3.14)^2)-z";
	const wchar_t* varList = L"x,y,z";
	TCalc args[] = { 1, 2.5, 1.7e-2 };
	TCalc res = TCalc(0);
	EQUHANDLE equHnd = NULL;

	// Initialize EquTranslator algorithm before we can use any function.
	// Return value (handle) must be used in each function call.
	equHnd = ::InitEquTranslator(
		ErrorHandler	//Error callback function
	);

	try
	{
		//Evaluate math expression for a given point "args"
		res = ::Evaluate(equHnd, L"x+y+z", varList, args);
		res = ::Evaluate(equHnd, mathExp, varList, args);

		args[0] = 2.3; args[1] = -5;
		res = ::Evaluate(equHnd, L"x/y+(x^2-y^2)", L"x,y", args);

		//Add user defined function to EquTranslator
		::AddFunction(equHnd, L"p3", pow3);

		// Calculate set of points for one math expression
		// Build it first
		::Build(equHnd, L"3.14*p3(x)+sin(y)-sqrt(z+x)", L"x,y,z");

		res = 0;
		for (int i = 0; i < 10000; i++)
		{
			args[0] = args[0] + 1;
			args[1] = (TCalc)i + 1;
			args[2] = args[0] / args[1];
			// Do calculation for a given point
			res += ::CalcFor(equHnd, args);
		}

		// Another functions to calculate set of points for a given expression.
		::Compile(equHnd, mathExp, varList, args);

		res = 0;
		for (int i = 0; i < 10000; i++)
		{
			args[0] = args[0] + 1;
			args[1] = (TCalc)i + 1;
			args[2] = args[0] / args[1];
			// Do calculation for a given point
			res += ::Run(equHnd);
		}

	}
	catch (int errCode)
	{
		std::cout << "Error code: " << errCode << std::endl;
	}

	// Release resources
	::CloseEquTranslator(equHnd);

	return 0;
}
Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.1.264 413 2/26/2021
4.0.101 580 11/12/2019