Inadmissible data type or value. overflow.

Function Derivative(optional x,optional n)  
	dim d as double 	
	if (x = 0 and (n = 0 or n = 1)) then
		stop
	end if
	d = n*x^(n-1) 
	Derivative = d
End Function

It’s almost worthless without showing how you call that function. No way to figure out what’s wrong with your call of the function. For me e.g. =DERIVATIVE(4,2) works an shows the correct value of the derivative of the quadratic function at x=4.