### TheMathFunction by Joel Bennett 6 years ago

embed code: <script type="text/javascript" src="http://PoshCode.org/embed/2094"></script>download | new post

You need to download and unpack LoreSoft.MathExpressions.dll into your Documents\WindowsPowerShell\Libraries or tweak this module.

**Examples**:

C:\PS> math 3 ^ sqrt pi

7.00931221713741

C:\PS> math sin sqrt 3

0.987026644990354

C:\PS> math ‘(42 / 9) * ( cos(.56) ^ 3 ) + Tan 60’

3.15828206698

C:\PS> (math (2mb) ^ 2)/1gb

4096

- Add-Type -Path (Join-Path (Split-Path $Profile) Libraries\LoreSoft.MathExpressions.dll)
- ## You can dot-source this in 1.0 after uncommenting the following line, and deleting the first and last lines.
- # [Reflection.Assembly]::LoadFrom((Join-Path (Split-Path $Profile) Libraries\LoreSoft.MathExpressions.dll)) | Out-Null
- $MathEvaluator = New-Object LoreSoft.MathExpressions.MathEvaluator
- Function Use-Math {
- $MathEvaluator.Evaluate( ($args -join " ") )
- }
- Set-Alias Math Use-Math
- Export-ModuleMember -Function * -Alias *

**Submit a correction or amendment below (**

**click here to make a fresh posting)**

After submitting an amendment, you'll be able to view the differences between the old and new posts easily.