[net.puzzle] More on Interview Questions.

mouli@cavell.UUCP (Bopsi Chandramouli) (03/14/85)

Here are two more 'good' interview questions. Actually I was asked
the first question in a job interview.

1) Hope you agree that

              x**2 = x + x + x + ... x such terms. 

   Then consider these two derivatives.

              d(x**2)
             ----     = 2*x.
              dx

              d(x + x + x + x .. x such terms)
             ____                              = 1 + 1 + 1 + 1 .. x such terms
              dx
                      = x.

   Why is this anamoly?

 2) what is the derivative of factorial x?

Bopsi Chandramouli.
ihnp4!alberta!cavell!mouli.

panos@utcsri.UUCP (Panos Economopoulos) (03/23/85)

> 
>
Here are the answers to the following questions:

> From: mouli@cavell.UUCP (Bopsi Chandramouli)
> Subject: More on Interview Questions.
> Message-ID: <379@cavell.UUCP>
> Date: 14 Mar 85 06:00:58 GMT
> Organization: U. of Alberta, Edmonton, AB
> 
> 
> Here are two more 'good' interview questions. Actually I was asked
> the first question in a job interview.
> 
> 1) Hope you agree that
> 
>               x**2 = x + x + x + ... x such terms. 
> 
>    Then consider these two derivatives.
> 
>               d(x**2)
>              ----     = 2*x.
>               dx
> 
>               d(x + x + x + x .. x such terms)
>              ____                              = 1 + 1 + 1 + 1 .. x such terms
>               dx
>                       = x.
> 
>    Why is this anamoly?

The problem appears because differentiation is a linear operator,
i.e.  d(af(x)+bg(x))/dx = a df(x)/dx + b dg(x)/dx for a,b constants.
Therefore, d(x+x+x+..+x)/dx = dx/dx + dx/dx + ... + dx/dx ONLY
for a constant number of additions. However, the way the problem
is presented, we have x additions at the righthand side, i.e. a
function of the variable and the above property does NOT hold,
i.e., we cannot get rid of the brackets and differentiate each term
independently.


> 
>  2) what is the derivative of factorial x?
> 

Factorial x or  x! for short, is  in general defined as

	x! = G (x+1) =  integral from 0 to inf  (t to the power of x
			times e to the power of -t) dt

where G(x) is the Gamma function.

The derivative of x! is, therefore, the derivative of the integral
with respect to x. Because the function g(t,x) (t to the power ... -t)
which is to be integrated is continuous w.r.t. t and x, and 
because its derivative dg(t,x)/dx is also continuous, we can
interchange the integral and the derivative, i.e. integrate
the derivative of g(t,x) w.r.t. x  (Leibnitz?? thrm??)
Doing this we get:

	dx!/dx = integral from 0 to inf ( x * t to the power of (x-1) *
			e to the power -t) dt
	       = x * integral from 0 to inf ( t to the power of (x-1) *
			e to the power -t) dt
	       = x * G (x)
	       = x * (x-1)!
	       = x!

That is, the derivative of x! is x!

I wasn't expecting this result, since the one function you can easily
get that equals its derivative is the exponential. A question one
could ask is can you really find ALL functions, defined in any way,
that equal their derivatives and  which are they?

-- 

					Panos Economopoulos

UUCP:   {decvax,linus,ihnp4,uw-beaver,allegra,utzoo}!utcsri!panos
CSNET:  panos@toronto

mvramakrishn@watdaisy.UUCP (Rama) (03/24/85)

> > 
> >
> Here are the answers to the following questions:
> 
> > From: mouli@cavell.UUCP (Bopsi Chandramouli)
> > 
> >  2) what is the derivative of factorial x?
> > 
> 
> Factorial x or  x! for short, is  in general defined as
> 
> 	x! = G (x+1) =  integral from 0 to inf  (t to the power of x
> 			times e to the power of -t) dt
> 
> where G(x) is the Gamma function.
> 
> The derivative of x! is, therefore, the derivative of the integral
> with respect to x. Because the function g(t,x) (t to the power ... -t)
> which is to be integrated is continuous w.r.t. t and x, and 
> because its derivative dg(t,x)/dx is also continuous, we can
> interchange the integral and the derivative, i.e. integrate
> the derivative of g(t,x) w.r.t. x  (Leibnitz?? thrm??)
> Doing this we get:
> 
> 	dx!/dx = integral from 0 to inf ( x * t to the power of (x-1) *
> 			e to the power -t) dt
> 	       = x * integral from 0 to inf ( t to the power of (x-1) *
> 			e to the power -t) dt
> 	       = x * G (x)
> 	       = x * (x-1)!
> 	       = x!
> 
> That is, the derivative of x! is x!
> 
> I wasn't expecting this result, since the one function you can easily
> get that equals its derivative is the exponential. A question one
> could ask is can you really find ALL functions, defined in any way,
> that equal their derivatives and  which are they?
> 
> -- 
   There seem to be slight error in the above.
	I am not an expert on Maths but from fundamental high school calculus,
		Let    y(x) = x!
			y(x+1) = (x+1)!

			(let  deltax = 1)
			dy/dx  =  limit as deltax -> 0 of 
					(y(x+deltax)-y(x)) / (deltax)
				= { y(x+1) - y(x) } / {(x+1)-x}
				= { (x+1)! - x! } / 1
				= (x+1) x! - x!
				= x x! + x! - x!
				= x * x!
	That is,  the derivative of  x!  is  x * x!
	
	Well, I do realise that the above is not a mathematical proof.
	The correct procedure seems to be the one given by <379@cavell.UUCP>
--------------------------------------------------------------------------------
	May I take this opportunity to REQUEST the people on the net to try
	to avoid posting something on a problem on which already scores
	of people have posted (unless it is very important).
	An example is obout manhole covers, a topic which has degenerated into
	personal fights (into talks about personal holes !).  
--------------------------------------------------------------------------------
    								Rama

UUCP:  {decvax,utzoo,ihnp4,allegra,clyde}!watmath!watdaisy!mvramakrishn
CSNET: mvramakrishn%watdaisy@waterloo.csnet
ARPA:  mvramakrishn%watdaisy%waterloo@csnet-relay.arpa
Mail:  M.V.Ramakrishna, Dept of Computer Science, University of Waterloo,
       Waterloo Ont., N2L 3G1 Canada

ndiamond@watdaisy.UUCP (Norman Diamond) (03/25/85)

> 		Let    y(x) = x!
> 			y(x+1) = (x+1)!
> 
> 			(let  deltax = 1)
> 			dy/dx  =  limit as deltax -> 0 of 
> 					(y(x+deltax)-y(x)) / (deltax)
> 				= { y(x+1) - y(x) } / {(x+1)-x}
> 				= { (x+1)! - x! } / 1
> 				= (x+1) x! - x!
> 				= x x! + x! - x!
> 				= x * x!
> 	That is,  the derivative of  x!  is  x * x!

Limit as deltax -> 0, but let deltax = 1?
Is this, then, the limit as 1 -> 0?

dy/dx = limit as deltax -> 0 of
        { (x+deltax) (x+deltax-1)!  -  x! } / {deltax}

        most of those deltax samples will be much smaller than 1.

-- 

   Norman Diamond

UUCP:  {decvax|utzoo|ihnp4|allegra}!watmath!watdaisy!ndiamond
CSNET: ndiamond%watdaisy@waterloo.csnet
ARPA:  ndiamond%watdaisy%waterloo.csnet@csnet-relay.arpa

"Opinions are those of the keyboard, and do not reflect on me or higher-ups."

apdoo@alice.UUCP (Alan Weiss) (03/25/85)

This line is for the line eater.

	The solution given to the question "What is the derivative of x! ?"
is not quite right.  It is true that

x! = integral (t^x exp(-t) dt)

but differentiating with respect to x we get

derivative of x! = integral (log(t)*t^x*exp(-t))dt

which is not, in general, equal to x!.  In fact, it is not hard to show
that the only solution of the equation

df/dx = f

is f = C exp(x), where C is an arbitrary constant.  Parenthetically,
it is not hard to show that

derivative of x! is approximately equal to   x!*log(x).

See, for example, references to the diagamma function or any book on
asymptotic expansions of integrals.

steve@siemens.UUCP (03/27/85)

/* Written  2:40 am  Mar 23, 1985 by panos@utcsri in siemens:net.puzzle */
> Here are the answers to the following questions:
> 
> > From: mouli@cavell.UUCP (Bopsi Chandramouli)
> > 
> >  2) what is the derivative of factorial x?
> 
> Factorial x or  x! for short, is  in general defined as
> 
> 	x! = G (x+1) =  integral from 0 to inf  (t to the power of x
> 			times e to the power of -t) dt
> 
> where G(x) is the Gamma function.
> 
> The derivative of x! is, therefore, the derivative of the integral
> with respect to x. Because the function g(t,x) (t to the power ... -t)
> which is to be integrated is continuous w.r.t. t and x, and 
> because its derivative dg(t,x)/dx is also continuous, we can
> interchange the integral and the derivative, i.e. integrate
> the derivative of g(t,x) w.r.t. x  (Leibnitz?? thrm??)
> Doing this we get:
> 
****** WARNING!! ****** MISTAKE (see below) AT THIS STEP ******
> 	dx!/dx = integral from 0 to inf ( x * t to the power of (x-1) *
> 			e to the power -t) dt
> 	       = x * integral from 0 to inf ( t to the power of (x-1) *
> 			e to the power -t) dt
> 	       = x * G (x)
> 	       = x * (x-1)!
> 	       = x!
> 
> That is, the derivative of x! is x!
> 
> I wasn't expecting this result, since the one function you can easily
> get that equals its derivative is the exponential. A question one
> could ask is can you really find ALL functions, defined in any way,
> that equal their derivatives and  which are they?
> -- 
> 					Panos Economopoulos

Panos, I'm afraid you made a mistake.  First of all,
the exponential function can be defined/discovered by looking for the
set of functions whose derivatives are equal to themselves.  (You get
the set of all functions re^x where r is any real constant.)  One learns
more than one ever wanted to know about this sort of thing in Differential
Equations.  Secondly, the reason you got your erroneous answer was that,
once you correctly got the derivative operator inside the integral, you
took the derivative with respect to t instead of x.  I'm surprised you
did this since you fluent enough with calculus to know better.

	dx!/dx	= d/dx [integral from 0 to inf (t to the power of x *
			e to the power -t) dt]
		= integral from 0 to inf (d/dx [t to the power of x] *
			e to the power -t) dt
	d/dx [t^x] is NOT equal to x * t^(x-1)
	dx!/dx	= integral from 0 to inf (t to the power of x * log t *
			e to the power -t) dt

I will leave the solution of this integral as an exercise for the reader.

-Steve Clark

{princeton | astrovax}!siemens!steve