# Math Delta?

## Recommended Posts

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 on other sites

```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 on other sites

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```

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 on other sites

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 on other sites

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 on other sites

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 on other sites

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?

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

## Create an account

Register a new account

×

• Wiki

• Back

• Git