MathGroup Archive 1998

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

Search the Archive

Re: how to pull real numbers out of a linear funktion ?



Clear[f];

f[c_ x_] /; (Head[c] === Real || Head[c] === Integer) := c f[x]

f[c_ x_] /; (Head[c] === Complex) := -c f[x]

{f[2x],f[2.x],f[(3+4I)x],f[8], f[2(3+4I)],f[(6+7I)(3+4I)],f[x y]}

{2 f[x],2. f[x],(-3-4 I) f[x],f[8],f[6+8 I],f[-10+45 I],f[x y]}

It is not clear what you want done if the factors are implied or the
order of  the factors is ambiguous.  For example, 

	Is f[8] supposed to be f[8] or 8 * f[1]  or 4 f[2] or 2 f[4]?
	
	Is f[2(3+4I)] supposed to be f[6+8I] or 2 * f[3+4I] or  (-3-4I) * f[2] 
or  2
 * (-3-4I) * f[1] ?
	
	Is x supposed to be restricted to being a symbol?  If so,

Clear[f];

f[c_ x_Symbol] /; (Head[c] === Real || Head[c] === Integer) := c f[x]

f[c_ x_Symbol] /; (Head[c] === Complex) := -c f[x]


Bob Hanlon



  • Prev by Date: Re: Help
  • Next by Date: Re: Mathematica frustrations...
  • Prev by thread: Re: how to pull real numbers out of a linear funktion ?
  • Next by thread: Re: How to define the LaTeX output of certain symbols?