Jump to content

Advanced Math UDF

Recommended Posts

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)

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 1 month later...

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:


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 APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *


My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

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 * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

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) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

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 *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"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: 2023-04-24

Link to comment
Share on other sites

  • 5 months later...
Link to comment
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.


Link to comment
Share on other sites

  • 2 months later...

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

Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
Share on other sites

  • 2 months later...

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?

Link to comment
Share on other sites

  • 1 month later...


  • 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

Link to comment
Share on other sites

  • 5 weeks later...


  • 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()


Advanced Math UDF

Link to comment
Share on other sites

  • 1 year later...

I tried to understand how your UDF work but I failed. There are so many warning and errors thrown to console. I saw many functions defined like this one:

Func __Pascal(ByRef $aRet)
    Local $ret[UBound($arr)+1]
    Local $i

    For $i = 0 To UBound($arr)
        $v1 = ($i > 0) ? $arr[$i-1] : 1
        $v2 = ($i < UBound($arr)) ? $arr[$i] : 1
        $ret[$i] = $v1+$v2

    Return $ret

whici might be fine using global variables but doesn't looks good since every function might be stand alone and code easy to debug. With your last UDF version, I tried to run Mollify example and my console cry out.


>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\advmathudf-au3-master\advmathudf-au3-master\Examples\Mollify.au3" /UserParams    
+>11:44:49 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\...\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\...\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (  from:C:\Program Files (x86)\AutoIt3  input:C:\advmathudf-au3-master\advmathudf-au3-master\Examples\Mollify.au3
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Curves.au3"(42,26) : warning: $ret possibly not declared/created yet
    $ret[0] = Cos($theta)*$r
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Curves.au3"(51,16) : warning: $ret possibly not declared/created yet
    $ret[0] = $t^2
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Sequences.au3"(108,24) : warning: $arr: possibly used before declaration.
    Local $ret[UBound($arr)
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Special\Airy.au3"(332,12) : warning: $x: possibly used before declaration.
    ElseIf $x <=
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Special\Step.au3"(9,14) : warning: $t: possibly used before declaration.
    Return 2*($t/
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Special\TrigIntegrals.au3"(4,66) : warning: $__g_ADVMATHUDF_INTEGRALSTEP: possibly used before declaration.
    Return Integral(_SiIntegral, 0, $x, $__g_ADVMATHUDF_INTEGRALSTEP,
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Calculus\Integral.au3"(5,26) : warning: $Infinity: possibly used before declaration.
    If $vStart = -$Infinity And
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Graphs\Graph.au3"(38,28) : error: Statement cannot be just an expression.
        ($aGraph[0])[$i] = $iMark
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Sequences.au3"(108,24) : error: $arr: undeclared global variable.
    Local $ret[UBound($arr)
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Special\Step.au3"(9,14) : error: $t: undeclared global variable.
    Return 2*($t/
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Calculus\Integral.au3"(5,26) : error: $Infinity: undeclared global variable.
    If $vStart = -$Infinity And
"C:\advmathudf-au3-master\advmathudf-au3-master\Math\Special\Gamma.au3"(9,40) : error: Gamma2(): undefined function.
        Return $Pi / (Sin($Pi*$x)*Gamma2(1-$x)
C:\advmathudf-au3-master\Examples\Mollify.au3 - 5 error(s), 7 warning(s)
!>11:44:50 AU3Check ended. Press F4 to jump to next error.rc:2
+>11:44:50 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 1.902

This might be a very useful UDF but it should be rewrite in a better manner.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

When do you start B)

My UDFs and Tutorials:


Active Directory (NEW 2022-02-19 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki
WebDriver - Wiki


Link to comment
Share on other sites

  • 4 months later...


this maybe an absolute stupid question, but how to proceed, once i have downloaded the udf-file?
What i have done so far, downloaded, extracted to D:\Test\Maths. Then pointed Sciteconfig to that folder as userincluded folder. That´s it. So, if i want to i.e. compute the GCD of two integers in a Form...well?...no clue...can you assist me?




Link to comment
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

  • Create New...