MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

indeterminate and infinity expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67564] indeterminate and infinity expressions
  • From: Søren Merser <merser at image.dk>
  • Date: Sat, 1 Jul 2006 05:11:38 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi

I need to evaluate the expression below:

In[1]:= Log[(#/yhat)] + (1-#) Log[(1-#)/(1-yhat)] &  /@  {0,1} /. yhat->123
Out[1]= {Indeterminate, -Infinity}

Depending on the value of #, I get Infinity and Inderterminate results.

To get the wanted answer I've to split the expression into two parts 

In[2]:= ans1 = # Log[#/yhat]  &  /@ {0, 1} yhat -> .123
Out[2]= {Indeterminate, 2.09557}

In[3]:= ans2 = (1-#) Log[(1-#)/(1-yhat)] &  /@ {0, 1} /. yhat  -> .123
Out[3]= {0.131248, Indeterminate}

In[4]:= Max[#] & /@ ({ans1, ans2} /. Indeterminate -> 0)
Out[4]= {2.09557, 0.131248}

Now, is there an easier way to do it?

Regards Soren


  • Prev by Date: has Mathematica gone bonkers?
  • Next by Date: orthonormal eigenvectors
  • Previous by thread: has Mathematica gone bonkers?
  • Next by thread: Re: indeterminate and infinity expressions