Linked Questions

5 votes
2 answers
414 views

I often want to write functions that take as an argument either a) a rule or b) a list of rules. As an example, when using Replace with just one rule, it does not ...
Theo Tiger's user avatar
  • 1,273
0 votes
2 answers
158 views

I want to write a function which takes multiple arguments varying from 1 to n, where each argument is a triplet. sublistProduct[{$a_1,b_1,c_1$},{$a_2,b_2,c_2$},...] = { $\Pi_{i=1}^{i=n}a_i ,\Pi_{i=1}...
drdebmath's user avatar
608 votes
19 answers
161k views

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
38 votes
9 answers
5k views

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
MrDas's user avatar
  • 483
45 votes
4 answers
5k views

I have a function that takes two inputs and processes them for a single output. What I need is one that can take a varying number of inputs. and process them to a single output. Is this possible in ...
Nothingtoseehere's user avatar
58 votes
3 answers
2k views

Mathematica has a notion of pattern specificity, which is a partial ordering on patterns. The rules (e.g. DownValues, SubValues,...
Kim Morrison's user avatar
  • 1,291
14 votes
4 answers
1k views

This function finds n given the nth prime: findPrime[n_] := If[PrimeQ[n], i = 1; While[Prime[i] < n, i = i + 1]; i, False]; This works: ...
Jerry Guern's user avatar
  • 4,672
17 votes
2 answers
795 views

I am trying to reproduce the API of a function (written in R) that accepts an arbitrary number of arguments and handles it the same way as it would handle a single argument that is a list of different ...
Eric Brown's user avatar
  • 4,491
7 votes
4 answers
1k views

I have two functions $f,g:\mathbb{R}^2 \to \mathbb{R}^2$ and I define a third one $h:\mathbb{R}^2 \to \mathbb{R}^2$ as the composition $$h(x,y) = g(f(x,y))$$ I'm trying to get this function into <...
AvatarOfChronos's user avatar
12 votes
1 answer
2k views

I'm interested in creating a function or rule that generates its own set of rules. For instance, it would take as an input the expression h[m, n] and the indices <...
pploops's user avatar
  • 123
2 votes
2 answers
255 views

I have a list of 2 by 2 matrices and I want the list of their traces. I have been using Map[Tr,mylistofmatrices] But I wonder if there is a way to make ...
user64620's user avatar
  • 581
1 vote
3 answers
355 views

Suppose I have two lists of parameters: $\delta=\{\delta1, \delta2, …\}$ and $\gamma = \{\gamma1, \gamma2, …\}$. The question is: how can one use $\delta$ and $\gamma$ (the parameter vectors) within ...
Seb's user avatar
  • 735
3 votes
1 answer
664 views

first time user and not quite familiar with how to enter my code here properly, but this isn't lengthy.. I have a previously defined function that computes the total time it takes to ride a bike with ...
Brandon's user avatar
  • 481
4 votes
2 answers
512 views

I have some very long and complex expressions which involve a set of $n$ variables, and I want to be able to permute the labels of the variables. I will give a simple example, instead of my awful ...
Jojo's user avatar
  • 1,288
1 vote
3 answers
185 views

f2[x_, y_] := x^2 + y^3; g[t_] := {t^2, 3*t+1} $g$ returns a list, but $f_2$ is a two variable function. So, we cannot compose these functions: ...
tchappy ha's user avatar

15 30 50 per page