Jump to content
Sign in to follow this  
xZZTx

Math Delta?

Recommended Posts

xZZTx

I was just looking for a delta function and im kinda shocked i didn't find 1...

is there really no delta in autoit or did i just not look well..


Sorry For Any Spelling / Grammar Errors I May Make.... I Failed English Wayyyy To Many Times..

Share this post


Link to post
Share on other sites
JRowe

Func Delta($val1, $val2)
If $val1 = $val2 Then
    Return 1
    EndIf
Return 0
EndFunc

Usage :

$a = Delta(40, 20)
$b = Delta(20,20)

$a = 0

$b = 1

It's a relatively simple thing, unless you're thinking of a different delta.

Share this post


Link to post
Share on other sites
PsaltyDS

Maybe he meant this kind of Delta (absolute difference):

$iDelta = _Delta(2, -3)
ConsoleWrite("Delta(2,-3) = " & $iDelta & @LF)

Func _Delta($iX, $iY)
    Return Abs($iX - $iY)
EndFunc

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
xZZTx

Yes thats the delta i was talking about.. but is no one else shocked that it is not included?!

it has almost all the other math functions but not a simple delta?!

just seems a bit odd


Sorry For Any Spelling / Grammar Errors I May Make.... I Failed English Wayyyy To Many Times..

Share this post


Link to post
Share on other sites
Malkey

Yes thats the delta i was talking about.. but is no one else shocked that it is not included?!

it has almost all the other math functions but not a simple delta?!

just seems a bit odd

Silly me thought you meant the Differentiation Delta. I thought no one would want a function that subtracted two variables, my mistake.

Anywho, this script is supposed to find the gradient at a point on a curve as delta X approaches zero.

Local $iX_Value = 1
Local $Equation = "x^3 +3*x^2"

Local $dfx = DeltaX($iX_Value, $Equation)

MsgBox(0, "", " dy/dx of (" & $Equation & ") at " & $iX_Value & " along X-axis is " & @CRLF & _
        $dfx & "      Or, a gradient of " & Round(_ATan2($dfx, 1) * 180 / (4 * ATan(1)), 2) & " Degrees")


; $x is distance along x-axis
; $sEq is equation eg. "3*x^2"
; Returns (Delta Y)/(Delta X) , the gradient, of a curve scribed by the equation, $sEq,
;  at the point on the curve ,$x along the x-axis.
Func DeltaX($x, $sEq)
    Local $dfx = 0
    Local $mean = 0
    Local $y = StringReplace($sEq, "x", "$x")
    ;ConsoleWrite( " $y = " & $y & @CRLF)
    Local $ydx = StringReplace($sEq, "x", "($x+$dx)")
    ;ConsoleWrite( " $ydx = " & $ydx & @CRLF)
    For $a = -0.0000001 To 0.0000001 Step 0.0000002
        $dx = $a
        $mean += (Execute($ydx) - Execute($y)) / $dx
        ;ConsoleWrite("$dx = " & $dx & "     $mean = " & $mean & @CRLF)
    Next
    Return Round($mean / 2, 8)
EndFunc   ;==>DeltaX

Func _ATan2(Const $nY, Const $nX) 
    Return ATan($nY / $nX) + ((($nY <= 0) And ($nX < 0)) + (($nY > 0) And ($nX < 0))) * 4 * ATan(1)
EndFunc   ;==>_ATan2
Edited by Malkey

Share this post


Link to post
Share on other sites
JRowe
xZZTx

well if any 1 does not get what i mean by delta it would be

if $A = 10 then $A = 4 the delta would be -6 and from that if $A = 6 then Delta = 2

just had to clear that up


Sorry For Any Spelling / Grammar Errors I May Make.... I Failed English Wayyyy To Many Times..

Share this post


Link to post
Share on other sites
PsaltyDS

well if any 1 does not get what i mean by delta it would be

if $A = 10 then $A = 4 the delta would be -6 and from that if $A = 6 then Delta = 2

just had to clear that up

Then your "Delta" is just the "-" subtraction operator. Why would you need a function for that?

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.