Jump to content

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


JSThePatriot
 Share

Math UDF's  

77 members have voted

  1. 1. Need additional Math UDF's?

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


Recommended Posts

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.

Interesting. I am missing some posts. I am going to have to start at the beginning again.

If there is a C library that is already created I can certainly create a plugin to encompass that functionality. That may be better as I stated before for more complex functions.

The easy functions should be in a UDF. I dont think AutoIt is quite ready to start bundling Plugins like they do UDF's so we need to get a good chunk of them into UDF's, and the rest into a plugin. I can do both, and plan to do that. =D

I really appreciate everyones support so far.

If everyone wants to continue contributing please just provide headers for your functions with the proper information as described in the standards for UDF submission guidelines. I will include it in the Math Library of Functions.

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

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

Do you want a string returned like "2/1" or the actual value. If you do want the value then my function returns the correct value. If we pass 1/2 or 0.5 to my function it will return 1/0.5 which is 2 or 2/1. That is the reciprocal of 1/2.

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

Do you want a string returned like "2/1" or the actual value. If you do want the value then my function returns the correct value. If we pass 1/2 or 0.5 to my function it will return 1/0.5 which is 2 or 2/1. That is the reciprocal of 1/2.

LOL, My Bad, Your right. I got a 'C' in math

[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]

Link to comment
Share on other sites

LOL, My Bad, Your right. I got a 'C' in math

I'll remember that about your math submissions :P jk. lol

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

that also, but i was also thinking that with the quadratics, you could implement simple physics into a game or visual presentation...

There are some really good books called "math for game developers" or something similar out there. I bet you can find them as pdf or chm files with some patience and a search engine.
Link to comment
Share on other sites

  • 1 month later...

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.2.1.14 (beta)
 Author:         4gotn1

 Script Function:
    Tests if a number is even or odd.
    Returns 1 - If the number is even.
    Returns 2 - If the number is odd.
#ce ----------------------------------------------------------------------------
Func _IsEven($eVal)
    Local $a = $eVal / 2
    Select
        Case Round($a, 0) = $a
            Return 1
        Case Round($a, 0) <> $a
            Return 0
    EndSelect
EndFunc

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.2.1.14 (beta)
 Author:         4gotn1

 Script Function:
    Returns Pi of a circle
#ce ----------------------------------------------------------------------------
Func _Pi($cRadius)
    $Sqrd = $cRadius * $cRadius
    Dim $vNum = ( 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609 * $Sqrd )
    Dim $rNum = Round( $vNum, 12 )
    
    Return $rNum
EndFunc

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.2.1.14 (beta)
 Author:         4gotn1

 Script Function:
    Converts to _Celcius and to _Fahrenheit
    Usage: _Celcius(32) will convert to 0 degrees celcius
           _Fahrenheit(0) will convert to 32 degrees fahrenheit
    Returns: The converted temperature
    
#ce ----------------------------------------------------------------------------

Func _Celcius($fTemp)
    Local $Decimal = 5 / 9
    Local $cTemp = $Decimal * ($fTemp - 32)
    Local $tNum = Round($cTemp, 2)
    
    Return $tNum
EndFunc
Func _Fahrenheit($cTemp)
    Local $Decimal = 9 / 5
    Local $fTemp = ($cTemp * $Decimal) + 32
    Local $tNum = Round($fTemp, 2)
    
    Return $tNum
EndFunc

Here's a quick _IsEven() and _Pi() i made a while ago :)

-edit-

Got bored, added a Fahrenheit and Celcius conversion func(s) too :D

Edited by 4gotn1
Link to comment
Share on other sites

Anyone have some example code to calculate/plot (draw any line) between two points, (IE plot a line to draw at any angle),I`m sure I`ve seen this in the forum before, but I can`t find it now..

Thanks.

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

I agree with more Math UDF's.

@trids

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

[u]My Programs:[/u]Word Search Creator - Make your own Word SearchShortHand - Hide a secret message in a jpg fileHex Editor - Edit your Binary fileIncrease file size - Increase the size of any filesArt Generator - A program that generate random picture[u]My Functions:[/u]16-Bits Hash - My Hash function similar to MD5Probabilities - My probabilities function (factorial, permuation, combination)_GetDate() - Convert a date to a day of the week_Base(), _Dec() - Convert a number in any base (bin, oct, hex, dec). Create your own!

Link to comment
Share on other sites

  • 1 month later...

@DTV:

try

ConsoleWrite(2^10)oÝ÷ Ù©ÝÊ°Y[zË«¦¸¬yÛkÉ«­¢+Ù
½¹Í½±]É¥Ñ ÉxÀ¸Ô¤oÝ÷ Ù©ÝÊ°Y[yëÞj+zË«¦¸¬yئi×­+(殶­s`¤gVæ2ôæWwFöäFW&Föâb33c¶bÂb33c¶FbÂb33c·7F'BÂb33c¶67W&7 b33c·Òb33c·7F'@ Fð b33c·Òb33c·ÒWV7WFR7G&æu&WÆ6Rb33c¶bÂgV÷C·gV÷C²ÂgV÷C²b33c·gV÷C²òWV7WFR7G&æu&WÆ6Rb33c¶FbÂgV÷C·gV÷C²ÂgV÷C²b33c·gV÷C² VçFÂ&÷VæBWV7WFR7G&æu&WÆ6Rb33c¶bÂgV÷C·gV÷C²ÂgV÷C²b33c·gV÷C²Âb33c¶67W&7Ò &WGW&âb33c·¤VæDgVæ0 ¤6öç6öÆUw&FRôæWwFöäFW&FöâgV÷C·ã2³"§ÓgV÷C²ÂgV÷C³2§ã"³"gV÷C²ÂÂ
Edited by tmo
Link to comment
Share on other sites

  • 1 year later...

This may be too stupid to include, but I use it time and time again - I have also posted it elsewhere.

Convert/Find a point on a (one-dimensional)range when the range is resized or rescaled.

the idea being a point (2) on a line segment (from 0 - 10) could be converted to a proportional point on a line segment from (-10 - 73)

Func _ConvertRange($i, $n, $x, $nb, $xb)
    ;converts a number in a range of numbers
    ;proportionally to number in another range
    ;despite whether the numbers are negative or not
    $C = ((($i - $n) / ($x - $n)) * ($xb - $nb)) + $nb
    Return $C
EndFunc

I'd also like to request a function - since I can't seem to find it.

An Arcsine function with an adjustable precision...(ASin only seems to work towards 14 places?)

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

This may be too stupid to include, but I use it time and time again - I have also posted it elsewhere.

Convert/Find a point on a (one-dimensional)range when the range is resized or rescaled.

the idea being a point (2) on a line segment (from 0 - 10) could be converted to a proportional point on a line segment from (-10 - 73)

Func _ConvertRange($i, $n, $x, $nb, $xb)
    ;converts a number in a range of numbers
    ;proportionally to number in another range
    ;despite whether the numbers are negative or not
    $C = ((($i - $n) / ($x - $n)) * ($xb - $nb)) + $nb
    Return $C
EndFuncoÝ÷ Øýu©l¢X¤zÚ+z«²Öºw-ìw!ƧßÛlyé­¡ø§v+@
ܲ)Þ~éܶ*'Â+ajvë-i¹^¦·È¨¢åÊÇËhÂ䶭Û5âZqë?ªê-ze·¬¶§)ඬ(!¶¯y¸§¶«m²-¶h²Ù²ªê-
ïz´Zªº_ºw-ۺح$²X¤z,²Ú,ئ-Ö°)^j
³¥«­¢+ÙÕ¹}
½¹ÙÉÐ ÀÌØíÍ}$°ÀÌØíÍ}%}1½ÜôаÀÌØíÍ}%}!¥ ôÈÀ°ÀÌØíÍ}=}1½ÜôÀ°ÀÌØíÍ}=}!¥ ôÄÀÀ¤(IÑÕɸ   ÀÌØíÍ}=}!¥ ´ÀÌØíÍ}=}1½Ü¤¼ ÀÌØíÍ}%}!¥ ´ÀÌØíÍ}%}1½Ü¤¤¨ ÀÌØíÍ}$´ÀÌØíÍ}%}1½Ü¤¤¬ÀÌØíÍ}=}1½Ü)¹Õ¹
Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

It's been done i know, but here is a quick-fix quadratic that i use when i leave my calculator in my locker.

MsgBox(0,"", _Quadratic(1,4,2))


Func _Quadratic($a, $b, $c)
$ID = ($b^2)-(4*$a*$c)
If $ID<0 or $a = 0 then Return "#Undef"
$Result1 = (-1*$b+Sqrt($id))/(2*$a)
$Result2 = (-1*$b-Sqrt($id))/(2*$a)
Return "x= "&$Result1&" or "&$Result2
EndFunc
Link to comment
Share on other sites

It's been done i know, but here is a quick-fix quadratic that i use when i leave my calculator in my locker.

MsgBox(0,"", _Quadratic(1,4,2))


Func _Quadratic($a, $b, $c)
$ID = ($b^2)-(4*$a*$c)
If $ID<0 or $a = 0 then Return "#Undef"
$Result1 = (-1*$b+Sqrt($id))/(2*$a)
$Result2 = (-1*$b-Sqrt($id))/(2*$a)
Return "x= "&$Result1&" or "&$Result2
EndFunc
That's a good one, but it would be more useful as a function if it returned results rather than a string. Also, there is no reason it couldn't return results if $a is zero.

$Ans = _Quadratic(1, 4, 2)
If @error = 1 Then
    MsgBox(0, 'ERROR', 'Cannot solve that.')
Else
    MsgBox(0, "", "x = " & $Ans[0] & " or x = " & $Ans[1])
EndIf

Func _Quadratic($a, $b, $c)
    Local $Result[2]
    If $a = 0 Then
        If $b = 0 Then Return SetError(1, 2,0)
        $Result[0] = -$c / $b
        $Result[1] = $Result[0]
        Return $Result
    EndIf
    
    $ID = ($b ^ 2) - (4 * $a * $c)
    If $ID < 0 Then Return SetError(1, 1, 0)
    
    $Result[0] = (-$b + Sqrt($ID)) / (2 * $a)
    $Result[1] = (-$b - Sqrt($ID)) / (2 * $a)
    Return $Result
EndFunc  ;==>_Quadratic
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

If $a = 0 then in the quadratic formula:

-b +- sqrt( (b^2) - (4*a*c))

2a

Then when you divide by 2a, are you not dividing by zero? thus undefined?

Edited by Paulie
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...