scintilla4evr

Advanced Math UDF

15 posts in this topic

#1 ·  Posted (edited)

I started writing this UDF a while ago, so I decided to share it here.

This is an UDF full of advanced mathematical functions. It allows to work with primes, create number sequences, interpolate, calculate values of functions like Riemann zeta.

Full list of functions:

Spoiler

BooleAnd
BooleOr
BooleNot
BooleEqual
BooleXor
Combination
CombinationR
Variation
VariationR
BellCurve
ParabolaCurve
CubicCurve
QuarticCurve
FoliumCurve
CissoidCurve
ConchoidCurve
SemicubicalParabolaCurve
SerpentineCurve
ContinuedFraction
Cosh
Coth
Csch
Sech
Sinh
Tanh
ACosh
ACoth
ACsch
ASech
ASinh
ATanh
LinearInterpolation
CosineInterpolation
CubicInterpolation
LogN
Log10
Log2
Logit
ArithmeticMean
HeinzMean
LogMean
HeronianMean
StolarskyMean
Sinc
BernoulliStirling
Gd
AGd
GaussLegendrePi
BitEqual
Factor
Divisors
GCD
LCM
Factorial
FactorialN
Superfactorial
Newton
Pi
Tau
Sigma
EulerTotient
Versin
Exsec
RisingFactorial
FallingFactorial
IsCoprime
IsPrime
IsPrime2
ListPrimes
ListPrimes2
NthPrime
NRoot
Cbrt
Stirling1
Stirling2
Bell
Bernoulli
Catalan
Carol
Cullen
AiryAi
AiryBi
BesselJ0
BesselJ1
BesselJn
BesselY0
BesselY1
BesselYn
Erf
Erfc
FourierSquareWave
FourierSawtoothWave
FourierTriangleWave
Gamma
Digamma
Beta
Sign
SawtoothWave
SquareWave
TriangleWave
RiemannZeta
RiemannXi
DirichletEta
HurwitzZeta
DirichletLambda
TriangularNum
HexagonalNum
Cot
Sec
Csc
ACot
ASec
ACsc

Added with 1.1:
Differential
Point
RotatePoint
AngleBetweenPoints
CoinFlip
DieRoll
CalculateProbability
NormalDistribution
ArcsineDistribution
BetaDistribution
DiracDelta

Added with 1.2:
Determinant
MultiplyArrayByMatrix
DistanceBetweenPoints
Vector
VectorAdd
VectorSubtract
VectorMultiplyScalar
VectorDivideScalar
VectorNegate
VectorApplyOp
VectorDotProduct
VectorCross
VectorLength
VectorNormalize
VectorAngleBetween
VectorReflect
VectorTransmit
EulerRotateX
EulerRotateY
EulerRotateZ
Complex
ComplexReal
ComplexImag
ComplexNegate
ComplexAbs
ComplexArg
ComplexConj
ComplexAdd
ComplexSubtract
ComplexMultiply
ComplexDivide
ComplexExp
ComplexLog
ComplexPow
Quaternion
QuaternionGetVector
QuaternionFromScalarVectorPair
QuaternionConj
QuaternionNorm
QuaternionAdd
QuaternionSubtract
QuaternionMultiply
QuaternionInvert
QuaternionDivide
QuaternionRotateVector

Added with 1.3:
PolygonalNum
NSimplexNum
Fibonacci
Lucas
LucasLehmer
IsPrimeLucas
IsMersennePrime
IsPrime3
ListPrimes3
Lychrel
Integral
Pascal
IsPrimeAKS
IsPrime1
Differential2
Limit
Solve
IdentityMatrix
TransposeMatrix

Added with version 1.3.1:
Trigamma

Added with version 1.4:
SolveDiff
FresnelC
FresnelS
Clausen
IncompleteGamma
Variance
StandardDeviation
NormalDistributonPDF
GeneticIteration
GeneticCrossPairs

Added with version 1.5:
Graph
GraphAddPoint
GraphAddLink
GraphMarkPoint
GraphGetMark
GraphMarkAll
GraphGetConnections
GraphGetPathLength
GraphFindPathDijkstra

Added with version 1.6:
VectorDistance
ATan2
AlphaMaxBetaMin
Triangle
TriangleGetAngles
LevenshteinDistance

Added with version 1.7:
Mandelbrot
WarpFactor
LorenzFactor
TimeDilation
LengthContraction
Mollify
BellCurveMollifier
LinearMollifier
ConstantMollifier
SharpMollifier

 

Changelog:

Spoiler

Version 1.7:

  • Added Mandelbrot()
  • Added WarpFactor()
  • Fixed ComplexLog()
  • Added physics constants (from physics.nist.gov)
  • Added LorentzFactor(), TimeDilation(), LengthContraction() and RelativisticMomentum()
  • Added Mollify(), BellCurveMollifier, LinearMollifier, ConstantMollifier and SharpMollifier
  • Added NewtonianGravity()

Version 1.6:

  • Added VectorDistance()
  • Fixed RotatePoint()
  • Point() and DistanceBetweenPoints() now call Vector() and VectorDistance() respectively
  • Added ATan2()
  • Added AlphaMaxBetaMin()
  • Added Triangle() and TriangleGetAngles()
  • Added LevenshteinDistance() using Wagner-Fischer algorithm
  • Added an example of genetic algorithm

Version 1.5:

  • Added graph functions
  • Added GraphFindPathDijkstra() for finding the path in an undirected graph (example included)

Version 1.4:

  • Added SolveDiff() for numerically solving differential equations
  • Added Fresnel integrals (FresnelC and FresnelS)
  • Added some statistical functions (more later)
  • Added Clausen()
  • Added IncompleteGamma()
  • Added basic genetic algorithm functions (see Genetic.au3)
  • Fixed issues with _Degree(), _Radian() and _MathCheckDiv()

Version 1.3.1:

  • Reimplemented DLL functions in AutoIt
  • Added Trigamma()

Version 1.3:

  • Added polygonal and n-simplex numbers
  • Added Fibonacci, Lucas and Lucas-Lehmer sequences
  • Added IsPrime3(), faster alternative to both IsPrime1() and IsPrime2()
  • Added IsPrimeAKS()
  • Added IsMersennePrime()
  • Added Lychrel()
  • Added Integral()
  • Added Pascal's triangle
  • Renamed IsPrime() to IsPrime1()
  • Added IdentityMatrix() and TransposeMatrix()
  • Added Solve()
  • Added new IsPrime()
  • Renamed Differential() to Differential2()
  • Added new Differential()

Version 1.2:

  • Added matrices
  • Added DistanceBetweenPoints()
  • Added vectors
  • Added Euler rotations
  • Added complex numbers
  • Added procedural events for probability calculations
  • Corrected algorithm for differentials
  • Added quaternions

Version 1.1:

  • Added differentials
  • Added probability calculation and some predefined events
  • Added point functions
  • Added examples for differentials and probability

Version 1.0:

  • first version of the UDF

Download

Edited by scintilla4evr
3 people like this

Share this post


Link to post
Share on other sites



Where does math.dll come from?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Where does math.dll come from?


I wrote it in C++ to make some calculations faster.

Share this post


Link to post
Share on other sites

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

New version!

Changes include:

  • Complex numbers
  • Quaternions
  • Probability improvements
  • And more!

 Math_UDF.zip

Share this post


Link to post
Share on other sites

Hi scintilla4evr,

First off, great to see more maths support for AutoIt being added. But I'm having a little trouble understanding your design choices. Only four functions (Bessel, error function, and two Gamma) actually use your tiny dll, which you say is for speed reasons. But any function involving trig would also benefit from being carried out directly on the FPU rather than in AutoIt, not to mention calculus, log, and iterative search algos like you use for primes all being faster when pre-compiled. So if you decide to provide a dedicated dll (which is definitely beneficial here), why not put everything in there? Alternatively, if you favour pure AutoIt for legibility and understanding, why not dispense with the dll altogether, especially since you now need an additional msvcr dll that is about 73 times bigger than your own dll? Incidentally, you can get rid of that dependency by compiling with runtime binary flag /MT instead of /MD (in MSVC, under Code Generation in Project properties, section C++). It would also help if you provide your dll source, but that is of course entirely up to you. But if I were to use your Bessel functions I would want to know how your algorithms actually work, since Bessel functions can be solved in several, rather different ways. It's just a thought.

 

1 person likes this

Share this post


Link to post
Share on other sites

Version 1.3:

  • Added polygonal and n-simplex numbers
  • Added Fibonacci, Lucas and Lucas-Lehmer sequences
  • Added IsPrime3(), faster alternative to both IsPrime1() and IsPrime2()
  • Added IsPrimeAKS()
  • Added IsMersennePrime()
  • Added Lychrel()
  • Added Integral()
  • Added Pascal's triangle
  • Renamed IsPrime() to IsPrime1()
  • Added IdentityMatrix() and TransposeMatrix()
  • Added Solve()
  • Added new IsPrime()
  • Renamed Differential() to Differential2()
  • Added new Differential()

And RFTC, I will follow your advice and try to reimplement these functions in AutoIt and get rid of the DLLs. Thanks for the advice!

Advanced Math UDF

1 person likes this

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Version 1.4:

  • Added SolveDiff() for numerically solving differential equations
  • Added Fresnel integrals (FresnelC and FresnelS)
  • Added some statistical functions (more later)
  • Added Clausen()
  • Added IncompleteGamma()
  • Added basic genetic algorithm functions (see Genetic.au3)
  • Fixed issues with _Degree(), _Radian() and _MathCheckDiv()

I'll try to make an example of a genetic algorithm and include it in the next version.

Advanced Math UDF

Edited by scintilla4evr
2 people like this

Share this post


Link to post
Share on other sites

Version 1.5:

  • Added graph functions
  • Added GraphFindPathDijkstra() for finding the path in an undirected graph (example included)

Advanced Math UDF

PS. No example for a genetic algorithm yet. Sorry! Will you forgive me?

1 person likes this

Share this post


Link to post
Share on other sites

That's greate! Thanks!

Share this post


Link to post
Share on other sites

1.6:

  • Added VectorDistance()
  • Fixed RotatePoint()
  • Point() and DistanceBetweenPoints() now call Vector() and VectorDistance() respectively
  • Added ATan2()
  • Added AlphaMaxBetaMin()
  • Added Triangle() and TriangleGetAngles()
  • Added LevenshteinDistance() using Wagner-Fischer algorithm
  • Added an example of genetic algorithm (finally!)

Advanced Math UDF

Share this post


Link to post
Share on other sites

Very nice update ! 

Really cool UDF. 

Thanks !

Share this post


Link to post
Share on other sites

1.7:

  • Added Mandelbrot()
  • Added WarpFactor()
  • Fixed ComplexLog()
  • Added physics constants (from physics.nist.gov)
  • Added LorentzFactor(), TimeDilation(), LengthContraction() and RelativisticMomentum()
  • Added Mollify(), BellCurveMollifier, LinearMollifier, ConstantMollifier and SharpMollifier
  • Added NewtonianGravity()

mollify.png

Advanced Math UDF

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • jrsofsd
      By jrsofsd
      RunningStats calculates running (moving) statistics: Standard Deviation, Variance, and Mean . The single function _RunningStats(), queries, clears, restores, or adds to the running statistics.
      Example.au3 adds 7 samples of data to running statistics and displays the results using _ArrayDisplay().
      Example-Persistent-Storage.au3 adds the first 6 samples to the running statistics and stores the results in an INI file. The data is read from the INI file and restored to the running statistics. The 7th sample is added and the results displayed, matching the results from Example.au3.
      Credits: John D. Cook for his article "Accurately computing running variance" at http://www.johndcook.com/blog/standard_deviation/
      RunningStats.zip
    • GarnetDagger
      By GarnetDagger
      Hello friends, I need some help and ideas because I am a tiny bit lost here!
      I am building some GUI with some tools and one of my tabs allows me to retrieve Data from my database in pre-defined ways I prefer.

      Currently, I can just look at them as in a Listview so no editing allowed I believe(*if I am wrong please correct me), but my dream is that I can have full control over it as in a spreadsheet program such as excel and open office. 
      what I like to include is for example;
      click cell to edit,
      Move cursor to next left, top, down or right cell, and make the cells bigger or smaller
      mouse over functions (for example a product info or picture loading etc),
      Enter to save temporary data in the cell / field or right away update it to my database also,
      Right mouse click for options etc,
      drag my cells and columns to edit 
      select multiple* rows / columns  etc
       
      the whole basic shenanigans i guess.
      this seems to be a daunting task for a beginner like me and I Know I am not a great programmer myself either. but I got time on my hand and I am very interested in how to accomplish this if possible, has it been done before and if not why not?!?!?! , The options I want in bold are required for the bare minimum to make things remotely work.
      Can I have some small guidance on this? I am under the impression that the AutoIt itself does not have these functions or possibilities, can I program this myself and how? Do I need to start accessing resources outside AutoIt and for example need to start learning win32 GUI programming or whatever it is called?
      I have tried the search for a while but I am at a loss.
      any help is appreciated and I will try to contribute myself as much as possible and I want to emphasize that I really Require the ELI5 (explain me like I am 5 years old) approach!
       
      thank you so much for reading and your time!  Regards Rene
       
    • Katie_Deely
      By Katie_Deely
      Hey there
      I'm thinking about making a program that will calculate with huge numbers. Well above 1*10^18 probably. Can autoit deal with that? If not, how can I make it work?
      Thanks!
    • rm4453
      By rm4453
      I keep getting error : Statement cannot be just an expression.
      Here are the 3 error variations it gives:
      Global $ImageCount += 1
      ~~~~~~~~~~~~~~~~~~~~~^
      Global $ImageCount += 1
      ~~~~~~~~~~~~~~~~~~~~^
      Global $ImageCount +=
      ~~~~~~~~~~~~~~~~~~~^
      Here is the code:
      Case $Image1 ;GUICtrlSetState($Image1, 4+128) GUICtrlSetState($Image2, 64) $Image1_done = 1 OpenImages() Global $Image1_added = $imagePath ;MsgBox("Info", "Image 1 Path", $Image1_added) OpenEditBox() Global $Image1_Description = $editBox_save If $im1 = 0 Then Global $ImageCount += 1 $im1 = 1 EndIf Case $Image2 If $Image1_done = 1 Then ;GUICtrlSetState($Image2, 4+128) GUICtrlSetState($Image3, 64) OpenImages() Global $Image2_added = $imagePath ;MsgBox("Info", "Image 2 Path", $Image2_added) OpenEditBox() Global $Image2_Description = $editBox_save $Image2_done = 1 If $im2 = 0 Then Global $ImageCount += 1 $im2 = 1 EndIf Else EndIf Case $Image3 If $Image2_done = 1 Then ;GUICtrlSetState($Image3, 4+128) GUICtrlSetState($Image4, 64) OpenImages() Global $Image3_added = $imagePath ;MsgBox("Info", "Image 3 Path", $Image3_added) OpenEditBox() Global $Image3_Description = $editBox_save $Image3_done = 1 If $im3 = 0 Then Global $ImageCount += 1 $im3 = 1 EndIf Else EndIf Case $Image4 If $Image3_done = 1 Then ;GUICtrlSetState($Image4, 4+128) GUICtrlSetState($Image5, 64) OpenImages() Global $Image4_added = $imagePath ;MsgBox("Info", "Image 4 Path", $Image4_added) OpenEditBox() Global $Image4_Description = $editBox_save $Image4_done = 1 If $im4 = 0 Then Global $ImageCount += 1 $im4 = 1 EndIf Else EndIf Case $Image5 If $Image4_done = 1 Then ;GUICtrlSetState($Image5, 4+128) GUICtrlSetState($Image6, 64) OpenImages() Global $Image5_added = $imagePath ;MsgBox("Info", "Image 5 Path", $Image5_added) OpenEditBox() Global $Image5_Description = $editBox_save $Image5_done = 1 If $im5 = 0 Then Global $ImageCount += 1 $im5 = 1 EndIf Else EndIf Case $Image6 If $Image1_done = 1 Then ;GUICtrlSetState($Image6, 4+128) OpenImages() Global $Image6_added = $imagePath ;MsgBox("Info", "Image 6 Path", $Image6_added) OpenEditBox() Global $Image6_Description = $editBox_save If $im6 = 0 Then Global $ImageCount += 1 $im6 = 1 EndIf Else EndIf  
    • Danyfirex
      By Danyfirex
      Well a Simple way to launch an advanced association dialog box to easy edit aplication association.
      Local Const $sCLSID_LaunchAdvancedAssociationUI = "{1968106d-f3b5-44cf-890e-116fcb9ecef1}" Local Const $sIID_ILaunchAdvancedAssociationUI = "{1f76a169-f994-40ac-8fc8-0959e8874710}" Local Const $sTagILaunchAdvancedAssociationUI = "LaunchAdvancedAssociationUI hresult(wstr)" ; Create the object. Local $aRegApp = _GetRegisteredApplications() If IsArray($aRegApp) Then LaunchAdvancedAssociationUI($aRegApp[0]) EndIf Func LaunchAdvancedAssociationUI($AppRegName) Local $oLaunchAdvancedAssociationUI = ObjCreateInterface($sCLSID_LaunchAdvancedAssociationUI, $sIID_ILaunchAdvancedAssociationUI, $sTagILaunchAdvancedAssociationUI) If Not IsObj($oLaunchAdvancedAssociationUI) Then Return False Return SUCCEEDED($oLaunchAdvancedAssociationUI.LaunchAdvancedAssociationUI($AppRegName)) EndFunc ;==>LaunchAdvancedAssociationUI Func _GetRegisteredApplications() Local $sWow64 = "" Local $sString = "" Local $aRegApp[0] Local $i = 1 If @AutoItX64 Then $sWow64 = "\Wow6432Node" Do $sString = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\RegisteredApplications", $i) If Not @error Then ReDim $aRegApp[$i] $aRegApp[$i - 1] = $sString $i += 1 EndIf Until @error <> 0 If $i = 1 Then Return 0 Return $aRegApp EndFunc ;==>_GetRegisteredApplications Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos