Re: How to treat this false singular point?
- To: mathgroup at smc.vnet.net
- Subject: [mg68414] Re: How to treat this false singular point?
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 4 Aug 2006 03:59:28 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <easkcp$g3j$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
simon yang wrote:
> Dear everyone,
> I have a function:
> f[x_]:=(x-x1)Log[Abs[x-x1]] + (x-x2)Log[Abs[x-x2]] + ... +
> (x-xn)Log[Abs[x-xn]],
> {x1,x2,...,xn}={100,200,300,...} for instance
> How to get value: f[x] as there are different singular at different x?
> I know at x=xn, f[x]==1, But Mathematica return: "Indeterminate", What
> should I do?
> what others do in C++, Fortran ?
Use some *If* statements around each term for instance.
In[1]:=
f[x_] := If[x != 100, (x - 100)*Log[Abs[x - 100]], 0] +
If[x != 200, (x - 200)*Log[Abs[x - 200]], 0] +
If[x != 300, (x - 300)*Log[Abs[x - 300]], 0]
In[2]:=
f[50]
Out[2]=
-50*Log[50] - 150*Log[150] - 250*Log[250]
In[3]:=
f[100.]
Out[3]=
-1520.18
In[4]:=
f[200]
Out[4]=
0
In[5]:=
Plot[f[x], {x, 0, 500}];
HTH,
Jean-Marc