JSThePatriot Posted December 8, 2006 Share Posted December 8, 2006 I was trying to figure out the hypotenuse of a right triangle, and figured why not have AutoIt do the work for me. I looked through all of the math UDF's, and there weren't many math functions at all. I would like to know if anyone is interested in some additional math UDF's.Proposed UDF's_Hypotenuse_IsPythagoreanTriple_IsOdd_IsEven_GeneratePythagoreanTripleLet me know how great the interest is, and also if you have some other functions you would like to see in a Mathematics library.Thanks,JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
trids Posted December 8, 2006 Share Posted December 8, 2006 Maybe some statistical functions? .. Combinations, Permutations, StdDeviation, Variance Link to comment Share on other sites More sharing options...
trids Posted December 8, 2006 Share Posted December 8, 2006 _LCM (lowest common multiple) _HCF (highest common factor) _IsPrime Link to comment Share on other sites More sharing options...
AzKay Posted December 8, 2006 Share Posted December 8, 2006 Theres already a hypotenuse one. Forgot who made it though, want me to fish it out? # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
RazerM Posted December 8, 2006 Share Posted December 8, 2006 (edited) I agree with more Math UDF's. @trids expandcollapse popup;=============================================================================== ; ; Function Name: _HighestCommonFactor ; Description:: Returns the highest common factor ; Parameter(s): $a - can be value for testing with $b, or an array of values ; Requirement(s): None ; Return Value(s): Success - Highest Common Factor, Failure - 0 and @error = 1 ; Author(s): RazerM ; ;=============================================================================== ; Func _HighestCommonFactor($a, $b = "") If $b = "" And Not IsArray($a) Then Return SetError(1, 0, 0) ElseIf IsNumber($a) And IsNumber($B) Then Local $c While Not $b = 0 $c = $b $b = Mod($a, $B) $a = $c WEnd Return $a ElseIf $b = "" And IsArray($a) Then Local $c, $aArr = $a $a = 0 $b = 0 For $i = 0 To UBound($aArr) - 3 $a = $aArr[$i] $b = $aArr[$i + 1] $c = _HighestCommonFactor($a, $B) $d = _HighestCommonFactor($c, $aArr[$i + 2]) Next Return $d Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_HighestCommonFactor ;=============================================================================== ; ; Function Name: _LowestCommonMultiple ; Description:: Returns the lowest common multiple ; Parameter(s): $a - can be value for testing with $b, or an array of values ; Requirement(s): Array.au3 ; Return Value(s): Success - Lowest Common Multiple, Failure - 0 and @error = 1 ; Author(s): RazerM ; ;=============================================================================== ; Func _LowestCommonMultiple($a, $b = "") If $b = "" And Not IsArray($a) Then Return SetError(1, 0, 0) ElseIf IsNumber($a) And IsNumber($B) Then Return ($a / _HighestCommonFactor($a, $B)) * $b ElseIf $b = "" And IsArray($a) Then Local $iMax = _ArrayMax($a, 1), $iMultiple = $iMax, $iTest = 0 While 1 $iTest = 0 For $i = 0 To UBound($a) - 1 If Mod($iMultiple, $a[$i]) > 0 Then $iTest += 1 Next If $iTest = 0 Then Return $iMultiple $iMultiple += $iMax WEnd Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_LowestCommonMultiple ;=============================================================================== ; ; Function Name: _StandardDeviation ; Description:: Returns the standard deviation from an array of values ; Parameter(s): $aiNum - array of values ; Requirement(s): None ; Return Value(s): Success - Standard Deviation, Failure - 0 and @error = 1 ; Author(s): ; ;=============================================================================== ; Func _StandardDeviation($aiNum) If Not IsArray($aiNum) Then Return SetError(1, 0, 0) $xBar = __ArrayAddValues($aiNum)/UBound($aiNum) For $iCounter = 0 To UBound($aiNum)-1 $aiNum[$iCounter] = ($aiNum[$iCounter]-$xBar)^2 Next Return Sqrt(__ArrayAddValues($aiNum)/(UBound($aiNum)-1)) EndFunc Func __ArrayAddValues($avArray) Local $iRet For $iCounter = 0 To UBound($avArray)-1 $iRet += $avArray[$iCounter] Next Return $iRet EndFunc ;=============================================================================== ; ; Function Name: _Permutations ; Description:: Returns the number of permutations of size r, when taken from a set of size n ; Parameter(s): $n - The number of elements in the set ; $r - How many elements from this set to count permutations ; Requirement(s): None ; Return Value(s): Success - Number of Permutations, Failure - 0 and @error = 1 ; Author(s): RazerM ; ;=============================================================================== ; Func _Permutations($n, $r) If $r > $n Then Return SetError(1, 0, 0) Return _Factorial($n)/_Factorial($n-$r) EndFunc ;=============================================================================== ; ; Function Name: _Factorial ; Description:: Returns the product of all positive integers less than or equal to $number ; Parameter(s): $number - Any positive number greater than 0 ; Requirement(s): None ; Return Value(s): Success - Factorial of $number, Failure - -1 and @error = 1 ; Author(s): joke758, RazerM ; ;=============================================================================== ; Func _Factorial($number) If $number < 1 Then Return SetError(1, 0, -1) Local $n = 1 For $i = 1 To $number $n *= $i Next If $n = 0 Then Return SetError(1, 0, -1) Else Return $n EndIf EndFunc ;==>Factorial Edited December 8, 2006 by RazerM My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
ptrex Posted December 8, 2006 Share Posted December 8, 2006 @JSThePatriot I did a simular thing with FINANCIAL functions. see my signature. VERY LITTLE TO NO RESPONS regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
HackerZer0 Posted December 8, 2006 Share Posted December 8, 2006 how about more algebra??? like... Quadratic Formula -or- Parablas (min, max, intercepts/zeros) Synthetic Division of Polynomials Turn Polynomial into Multiple Binomials Polynomial GCF etc Earn money on CASHCRATE by sitting around doing nothing.. Link to comment Share on other sites More sharing options...
Locodarwin Posted December 8, 2006 Share Posted December 8, 2006 Inverse and hyperbolic trigs would be good and fairly easy to implement, given that many trig functions are already covered. @HackerZer0: Why would you need functions for polynomials and quadratic formulas? To help with your homework? -S (Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent] Link to comment Share on other sites More sharing options...
Uten Posted December 8, 2006 Share Posted December 8, 2006 I don't think AutoIt attract much interest as a tool for people dealing with this kind of things. I guess the spreadsheet applications are to superior at the job. But it would sure be nice to have "ready o run" udf's when you need them.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
locomaestro Posted December 9, 2006 Share Posted December 9, 2006 Func _findaside($sideA,$sideB,$sideC) Select case $sideA = "?" $b2 = $sideB * $sideb $c2 = $sidec * $sidec $answer = $c2 - $b2 $answer1 = Sqrt($answer) return $answer1 case $sideb = "?" $a2 = $sidea * $sidea $c2 = $sidec * $sidec $answer = $c2 - $a2 $answer1 = Sqrt($answer) Return $answer1 case $sidec = "?" $b2 = $sideB * $sideb $a2 = $sidea * $sidea $answer1 = $a2 + $b2 $answer2 = Sqrt($answer1) Return $answer2 EndSelect EndFunc Func _QuadraticFormula($a2,$bx,$c) $2x = $bx * $bx $xneg = $bx * -1 $4ac = -4 * $a2 * $c $2a = $a2 * 2 $x01 = Sqrt($2x + $4ac) $x11 = $xneg + $x01 $x22 = $xneg - $x01 $2ndresult = $x22/$2a $1stresult = $x11/$2a Return $1stresult & " and/or " & $2ndresult EndFunc here are two functions for the first one if you dont know a side just put a question mark Link to comment Share on other sites More sharing options...
theguy0000 Posted December 9, 2006 Share Posted December 9, 2006 what about _slope and _yIntercept for graphing...or i could just make a graphing program that asks the user for slope and y intercept...that would be cool...but how to do the graphing....... i'll post back later if i get anywhere on this The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 9, 2006 Author Share Posted December 9, 2006 I have already written the functions that I listed above. I haven't finished the _GeneratePythagoreanTriples. It was quite easy. I am glad everyone has shown an interest in this. Maybe the reason that people haven't shown much of an interest in AutoIt and Math may be that they don't want to write the functions themselves. It could also been a question of speed. This could start out as a set of UDF's that we can turn into a Plugin Library. @AzKay I wasn't interested searching forums for something I could type out faster. I just searched for the functions and/or UDF's. Thanks for the input. @RazorM Thanks for your additions. I will add them to the file. @ptrex I will look at your functions. Are they Standard UDF compliant? Thanks, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
theguy0000 Posted December 9, 2006 Share Posted December 9, 2006 Func _slope($x1,$y1, $x2,$y2) $xChange = $x1-$x2 $yChange = $y1-$y2 Return $yChange/$xChange EndFunc no big deal, just thought I would post it The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
ConsultingJoe Posted December 10, 2006 Share Posted December 10, 2006 (edited) How about reciprocal? Example: Reciprocal(1/2) = 2 Example: Reciprocal(4/3) = 3/4 Edited December 10, 2006 by CyberZeroCool Check out ConsultingJoe.com Link to comment Share on other sites More sharing options...
RazerM Posted December 10, 2006 Share Posted December 10, 2006 Func _Reciprocal($vNum) Return 1/$vNum EndFunc Seems a bit pointless to me. It's very simple My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Uten Posted December 10, 2006 Share Posted December 10, 2006 Obviously you all know about http://www.nr.com/. So, no need for me to post a link And the books.I think much of the C version should be possible to implement in au3 code. And yes I know and you know that the power in this case is not in speed but ease of use.. If we need raw speed for this kind of thing we should do it in a low level language. Or just by one of those nice libraries out there and use dllcall. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
dandymcgee Posted December 10, 2006 Share Posted December 10, 2006 Hmmmm..... let me know when you get a script that will solve my algebra word problems (scan the work sheet, copy paste the text to the editbox in the script, click solve, write down answer on paper). ...lol - Dan [Website] Link to comment Share on other sites More sharing options...
erifash Posted December 10, 2006 Share Posted December 10, 2006 (edited) How about some trigonometric functions?[offtopic] What happened to the board? It looks... updated [/offtopic] Edited December 10, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
Uten Posted December 10, 2006 Share Posted December 10, 2006 Hmmmm..... let me know when you get a script that will solve my algebra word problems (scan the work sheet, copy paste the text to the editbox in the script, click solve, write down answer on paper). ...lolI'm preeeety close to the last part. Don't know about the rest though. Sounds awfully difficult. You sure you need that Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
ConsultingJoe Posted December 10, 2006 Share Posted December 10, 2006 Func _Reciprocal($vNum) Return 1/$vNum EndFunc Seems a bit pointless to me. It's very simpleI don't think that would be right, if you wanted the reciprocal of 1/2 it would be 2/1 which is 2 not 1/1/2 like yours Check out ConsultingJoe.com Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now