Sign in to follow this  
Followers 0
JSThePatriot

How great is the interest in some extra Math UDF's?

Math UDF's   77 members have voted

  1. 1. Need additional Math UDF's?

    • Yes
      55
    • No
      4
    • Maybe
      14
    • I dont care
      4

Please sign in or register to vote in this poll.

53 posts in this topic

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
  • _GeneratePythagoreanTriple
Let 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)

Share this post


Link to post
Share on other sites



Maybe some statistical functions? ;)

.. Combinations, Permutations, StdDeviation, Variance

Share this post


Link to post
Share on other sites

_LCM (lowest common multiple)

_HCF (highest common factor)

_IsPrime ;)

Share this post


Link to post
Share on other sites

Theres already a hypotenuse one. Forgot who made it though, want me to fish it out?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I agree with more Math UDF's.

@trids

;===============================================================================
;
; 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 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.

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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..;)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

How about reciprocal?

Example: Reciprocal(1/2) = 2

Example: Reciprocal(4/3) = 3/4

Edited by CyberZeroCool

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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..:lmao: 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.

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Share this post


Link to post
Share on other sites

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). :lmao:...lol

I'm preeeety close to the last part. Don't know about the rest though. Sounds awfully difficult. You sure you need that ;)

Share this post


Link to post
Share on other sites

Func _Reciprocal($vNum)
    Return 1/$vNum
EndFunc

Seems a bit pointless to me. It's very simple

I 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

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

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
Sign in to follow this  
Followers 0