Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4369
| From | Ethan Dyer <ethansdyer@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Basic questions on _Plus and recursion |
| Date | 2011-08-13 10:54 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j25l59$p0a$1@smc.vnet.net> (permalink) |
Hi. I'm sure these are common issues, but I haven't found them. Here are the two, unrelated questions. Thank you for the help.
1) I want to use _Plus for a function with arbitrary arguments. ie I want: f[a+b]=f[a]+f[b], f[a+b,c+d] to go to f[a,c]+f[a,d]+f[b,c]+f[b,d], ... Is there a standard way to do this?
2)Here I want to pull out scalars from a function. Something like this:
f[x__] :=(Times@@Select[{x},Scalar[#]==1&]) (f@@Select[{x},Scalar[#]!=1&])
Where i have defined a function Scalar to =1 for some symbols.
for instance say I had defined Scalar[a]=1 then f[a,b,c]= a f[b,c].
The above does not work, as it gives infinite recursion. Is there a way to do this properly?
Thank you again. Sorry if these are too common.
Ethan
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Basic questions on _Plus and recursion Ethan Dyer <ethansdyer@gmail.com> - 2011-08-13 10:54 +0000
csiph-web