THE ANSWERS: how to pull real numbers out of a linear funktion
- To: mathgroup@smc.vnet.net
- Subject: [mg11262] THE ANSWERS: how to pull real numbers out of a linear funktion
- From: Roland Bollmann <roland@arnold.fkp.physik.th-darmstadt.de>
- Date: Wed, 4 Mar 1998 01:39:20 -0500
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)