steos.expression.solver 1.0.92

dotnet add package steos.expression.solver --version 1.0.92
                    
NuGet\Install-Package steos.expression.solver -Version 1.0.92
                    
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="steos.expression.solver" Version="1.0.92" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="steos.expression.solver" Version="1.0.92" />
                    
Directory.Packages.props
<PackageReference Include="steos.expression.solver" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add steos.expression.solver --version 1.0.92
                    
#r "nuget: steos.expression.solver, 1.0.92"
                    
#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.
#:package steos.expression.solver@1.0.92
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=steos.expression.solver&version=1.0.92
                    
Install as a Cake Addin
#tool nuget:?package=steos.expression.solver&version=1.0.92
                    
Install as a Cake Tool

ExpressionSolver

NuGet Version Downloads License: MIT

Advanced mathematical expression evaluation library for .NET with NumPy-like array operations and element-wise functions.

🚀 What's New in v2.0

Element-wise Array Operations

solver.Solve("[1, 2, 3] * [4, 5, 6]");        // → "[4, 10, 18]"
solver.Solve("[10, 20, 30] + 5");             // → "[15, 25, 35]"
solver.Solve("SQRT([9, 16, 25])");            // → "[3, 4, 5]"

Real-world Example: Rectangle Diagonals

// Calculate diagonals for multiple rectangles at once
var widths = "[3, 4, 5]";
var heights = "[4, 3, 12]";
var diagonals = solver.Solve($"SQRT({widths} * {widths} + {heights} * {heights})");
// Result: "[5, 5, 13]" - diagonal for each rectangle

📦 Installation

dotnet add package ExpressionSolver

🎯 Quick Start

using ExpressionSolver;

var solver = new ExpressionProcessor();

// Basic arithmetic
var result1 = solver.Solve("2 + 3 * 4");              // → "14"
var result2 = solver.Solve("SQRT(25)");               // → "5"

// Array operations (NEW!)
var result3 = solver.Solve("[1, 2, 3] * 2");          // → "[2, 4, 6]"
var result4 = solver.Solve("SUM([10, 20, 30])");      // → "60"

// Business logic
var result5 = solver.Solve("AVERAGE([100, 200, 150]) > 150"); // → "TRUE"

📋 Core Features

Mathematical Operations

// Arithmetic
solver.Solve("3 + 4 * 2");                    // → "11"
solver.Solve("2 ^ 3");                        // → "8"

// Functions
solver.Solve("SQRT(16)");                     // → "4"
solver.Solve("SIN(90)");                      // → "1"
solver.Solve("LN(2.718281828)");              // → "1"

Aggregation Functions

solver.Solve("SUM([1, 2, 3, 4, 5])");         // → "15"
solver.Solve("AVERAGE([10, 20, 30])");        // → "20"
solver.Solve("MAX([5, 2, 8, 1])");            // → "8"
solver.Solve("MIN([5, 2, 8, 1])");            // → "1"
solver.Solve("COUNT([1, 2, 3])");             // → "3"
solver.Solve("MEDIAN([1, 2, 3, 4, 5])");      // → "3"

Logical Operations

solver.Solve("5 > 3 AND 2 < 4");              // → "TRUE"
solver.Solve("NOT(FALSE)");                   // → "TRUE"
solver.Solve("10 IN [5, 10, 15]");            // → "TRUE"
solver.Solve("\"apple\" == \"apple\"");       // → "TRUE"

Array OperationsNew in v2.0

// Element-wise arithmetic
solver.Solve("[1, 2, 3] + [4, 5, 6]");        // → "[5, 7, 9]"
solver.Solve("[2, 3, 4] ^ [2, 2, 2]");        // → "[4, 9, 16]"
solver.Solve("[10, 20, 30] - [1, 2, 3]");     // → "[9, 18, 27]"

// Broadcasting (scalar with array)
solver.Solve("[1, 2, 3] * 2");                // → "[2, 4, 6]"
solver.Solve("5 + [10, 20, 30]");             // → "[15, 25, 35]"

// Element-wise functions
solver.Solve("SQRT([9, 16, 25])");            // → "[3, 4, 5]"
solver.Solve("SIN([0, 30, 90])");             // → "[0, 0.5, 1]"

// Complex expressions
solver.Solve("SUM([1, 2, 3] * [2, 2, 2])");   // → "12"
solver.Solve("AVERAGE([10, 20] + [5, 10])");  // → "22.5"

💼 Use Cases

Business Analytics

// Sales analysis
var prices = "[10, 20, 30, 40, 50]";
var quantities = "[2, 3, 1, 4, 2]";

var totalRevenue = solver.Solve($"SUM({prices} * {quantities})");     // → "370"
var avgPrice = solver.Solve($"AVERAGE({prices})");                    // → "30"
var priceDeviation = solver.Solve($"{prices} - {avgPrice}");          // → "[-20, -10, 0, 10, 20]"

// Profit margin calculation
var sales = "[100, 200, 150, 300, 250]";
var costs = "[80, 160, 120, 240, 200]";
var margins = solver.Solve($"(({sales} - {costs}) / {sales}) * 100"); // → "[20, 20, 20, 20, 20]"

Scientific Computing

// Physics: Kinetic energy calculation
var mass = "2";  // kg
var velocities = "[10, 20, 30]";  // m/s
var kineticEnergy = solver.Solve($"0.5 * {mass} * ({velocities} ^ 2)");
// Result: "[100, 400, 900]" (Joules)

// Geometry: Distance between points
var x1 = "[0, 1, 3]";
var y1 = "[0, 1, 4]"; 
var x2 = "[3, 4, 0]";
var y2 = "[4, 5, 0]";
var distances = solver.Solve($"SQRT((({x2} - {x1}) ^ 2) + (({y2} - {y1}) ^ 2))");
// Result: "[5, 5, 5]"

Financial Modeling

// Compound interest for different periods
var principal = "1000";
var rate = "0.05";  // 5%
var years = "[1, 2, 3, 5, 10]";
var futureValues = solver.Solve($"{principal} * ((1 + {rate}) ^ {years})");
// Result: "[1050, 1102.5, 1157.625, 1276.2815625, 1628.8946267]"

// ROI calculation
var investment = "[1000, 2000, 1500]";
var returns = "[1200, 2400, 1800]";
var roi = solver.Solve($"(({returns} - {investment}) / {investment}) * 100");
// Result: "[20, 20, 20]" (20% ROI for each)

🔄 Migration Guide (v1.x → v2.0)

Breaking Change: Aggregation Function Syntax

❌ v1.x (deprecated):

solver.Solve("SUM[1, 2, 3]");           // Old bracket syntax
solver.Solve("AVERAGE[data]");          // No longer supported

✅ v2.0 (standard):

solver.Solve("SUM([1, 2, 3])");         // Standard function syntax
solver.Solve("AVERAGE([data])");         // Excel/SQL compatible

Auto-migration Pattern

Use this regex to update your code:

  • Find: (SUM|AVERAGE|MAX|MIN|COUNT|MEDIAN)\[([^\]]+)\]
  • Replace: $1([$2])

📊 Supported Data Types

Type Example Description
Numbers 42, 3.14, -10 Integer and decimal numbers
Booleans TRUE, FALSE Logical values
Strings "Hello", "World" Text values with quotes
Arrays [1, 2, 3], [1.5, 2.7] Collections of values

🎨 Advanced Examples

Statistical Analysis

// Standard deviation calculation
var data = "[10, 12, 14, 16, 18]";
var mean = solver.Solve($"AVERAGE({data})");  // → "14"
var variance = solver.Solve($"AVERAGE(({data} - {mean}) ^ 2)");  // → "8"
var stdDev = solver.Solve($"SQRT({variance})");  // → "2.828..."

Data Transformation

// Normalize data to 0-1 range
var values = "[10, 20, 30, 40, 50]";
var min = solver.Solve($"MIN({values})");      // → "10"
var max = solver.Solve($"MAX({values})");      // → "50"
var normalized = solver.Solve($"({values} - {min}) / ({max} - {min})");
// Result: "[0, 0.25, 0.5, 0.75, 1]"

Conditional Logic

// Check if values are above average
var scores = "[85, 92, 78, 96, 88]";
var avg = solver.Solve($"AVERAGE({scores})");  // → "87.8"
var aboveAverage = solver.Solve($"{scores} > {avg}");
// Note: Boolean arrays not yet supported, use individual comparisons

⚡ Performance & Compatibility

  • Target Framework: .NET Standard 2.0+
  • Performance: Linear O(n) complexity for array operations
  • Memory: Efficient with proper garbage collection
  • Thread Safety: Evaluation is thread-safe
  • Zero Regression: Existing scalar operations unchanged

🔧 Error Handling

The library provides detailed error messages with precise locations:

// Array size mismatch
solver.Solve("[1, 2, 3] + [4, 5]");
// → InvalidOperationException: "Несовпадение размеров массивов: 3 vs 2"

// Division by zero in array
solver.Solve("[1, 2, 3] / [0, 1, 2]");
// → InvalidOperationException: "Деление на ноль в элементе с индексом 0"

// Invalid function argument
solver.Solve("SQRT([-1, 4, 9])");
// → InvalidOperationException: "SQRT(...) определён только для неотрицательных чисел. Ошибка в элементе с индексом 0: -1"

🧪 Testing

The library includes comprehensive test coverage:

  • 100+ unit tests covering all features
  • Element-wise operation validation
  • Error handling verification
  • Performance benchmarks
  • Backward compatibility tests
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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
1.0.92 142 7/1/2025
1.0.8 137 7/1/2025
1.0.7 143 6/24/2025
1.0.6 195 3/12/2025
1.0.5 177 3/12/2025
1.0.4 129 2/12/2025
1.0.3 115 2/12/2025
1.0.2 114 2/12/2025
1.0.1 116 2/12/2025
1.0.0 127 2/12/2025