Re: indeterminate and infinity expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg67615] Re: indeterminate and infinity expressions
- From: "David W.Cantrell" <DWCantrell at sigmaxi.org>
- Date: Sun, 2 Jul 2006 06:27:39 -0400 (EDT)
- References: <e85es4$k8e$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Søren_Merser <merser at image.dk> wrote: > I need to evaluate the expression below: > > In[1]:= Log[(#/yhat)] + (1-#) Log[(1-#)/(1-yhat)] & /@ {0,1} /. > yhat->123 Out[1]= {Indeterminate, -Infinity} First, Søren, if you really want others to help you, please be much more careful in your posting. There were several errors. Evaluating your In[1], exactly as you gave it, returns {-Infinity, Indeterminate}, which is perfectly correct. Your claimed Out[1] had the list in the wrong order. But looking at your In[2], which is missing /. BTW, it seems that your In[1] was missing an initial # and that yhat was to have been replaced by .123, rather than 123 . To get what you want, use Limit. Here's my suggestion: In[8]:= Limit[x Log[(x/yhat)] + (1-x) Log[(1-x)/(1-yhat)], x->#] & /@ {0,1} /. yhat -> .123 Out[8]= {0.131248,2.09557} David > 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
- Follow-Ups:
- Re: Re: indeterminate and infinity expressions
- From: Søren Merser <merser@image.dk>
- Re: Re: indeterminate and infinity expressions