MathGroup Archive 1998

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

Search the Archive

THE ANSWERS: how to pull real numbers out of a linear funktion



My question once was:


 [mg11092] how to pull real numbers out of a linear funktion ? "
I want to define a function f[x_] with the property, that

f[c_ x_] := c f[x] whenever c is a real number

and

f[c_ x_] := -c f[x] whenever c is a komplex number.

It semms to me, that mathematica can not give a variable the   attribute
"real number" or "complex number". "


These are the proposed solution:

1)
Clear[f]
f[c_Integer x_] 	:= 	 c f[x];
f[c_Real x_] 		:=	 c f[x];
f[c_Rational x_] 	:=	 c f[x];
f[c_Complex x_]		:= 	- c  f[x];


2)
Clear[f]
f[c_Complex x_]		:=	-c f[x]
f[c_?NumberQ x_]	:=	c f[x]


3)
Clear[f]
f[c_ x_] /; (Head[c] === Real || Head[c] === Integer || Head[c] ===  
Rational) := c f[x]
f[c_ x_] /; (Head[c] === Complex) := -c f[x]


4)
Clear[f]
f[r_ x_] := Conjugate[r]  f[x] /; NumberQ[r]


Thanks for all Your help,

Roland Bollmann (germany)



  • Prev by Date: RE: How draw 3D Arrows?
  • Next by Date: RE: Copying from Excel 97
  • Prev by thread: RE: are nested patterns imposs
  • Next by thread: ListPlot3D Color