For questions on writing functions (pure or using Set/SetDelayed) for any purpose, including the features that may be incorporated in those functions, such as options, patterns and conditions.

learn more… | top users | synonyms

5
votes
1answer
86 views

Defining a custom Plus for a specific class of arguments

I'm trying to develop an domain-specific language with Mathematica. I want to define a customized behavior for the Plus function when applied to my data. For ...
0
votes
1answer
29 views

Changing default behavior of Series to give slightly different SeriesData

I am working with complicated expressions expr that contains the symbolic function f[x] which I know to have a pole at ...
0
votes
1answer
56 views

How to get `Series` to recognize user-defined function has pole

Edit for clarity: How does Mathematica's function Series know that Gamma[x] has a pole at ...
7
votes
0answers
67 views

Maximum number of literal values for SetDelayed?

Under what circumstances should I expect Mathematica to turn a delayed assignment into an immediate assignment? I have put together a minimal example (available here) which demonstrates this behavior. ...
6
votes
0answers
111 views

Is there a function to generate a minimal clique cover?

This is a graph problem known as the "Clique Edge Cover" or "Intersection Number" problem, and the goal is to find, from a given graph like $E=\{\{a,b\},\{a,c\},\{b,c\},\{b,d\},\{c,d\}\}$ and ...
4
votes
0answers
152 views

Strange behaviour of MMA in derivatives of some standard functions

There are some peculiar things to be discovered in derivatives of some standard functions in MMA: Strange behaviour Example 1: Abs We have ...
3
votes
0answers
55 views

Listable on first level

I have some function which take List as input. f[l_List]:=someActions[l] I need apply this function to a list of lists. Now I ...
3
votes
0answers
82 views

Getting Arg[z] to go from $0$ to $2\pi$

I'm defining branch cut functions, and I'm using $arg(z)$ as a building block. So I just spent an hour at the whiteboard assuming that $arg(z)$ goes from $0$ to $2\pi$, and then I implement the code, ...
3
votes
0answers
58 views

How to combine DifferenceRoot objects for odd and even-indexed terms

I'm trying to analyze a certain infinite sequence $S$, indexed by positive integers starting from $1$. It can be split into two subsequences: $S^{odd}$ by removing all even-indexed elements and ...
2
votes
0answers
54 views

How to make a new analytic function work seamlessly with Mathematica's analysis functions?

I am defining a new analytic function of six variables. I have algorithms to evaluate it numerically, and have amassed a large catalog of analytic properties. It is easy for me to program the ...
2
votes
0answers
124 views

correct usage of ParallelTable

I am trying to parallelize my script. Here is a MWE of how I have done it: ...
2
votes
0answers
80 views
2
votes
0answers
317 views

Generating a function which outputs possible chemical reactions

I want to make a list of chemical reactions and I write them down in a $\require{mhchem}\LaTeX$ format. They are of the following form $$NA_n^i+MB_m^j \rightarrow \hat NA_{\hat n}^{\hat i}+\hat ...
1
vote
0answers
38 views

A more efficient way of fitting a non-linear model that returns an entire list?

I have a function that takes two parameters, del and nu, and returns a list npoints long ...
1
vote
0answers
55 views

Function behavior based on Head

I'm figuring how to implement a function behavior based on the Head of its argument. I mean ...
1
vote
0answers
134 views

Issue with Coefficient command

I'm trying to used the Coefficient command to extract the numerical values in front of a Chebyshev polynomial. I know that there is a numerical way to do this, presented in numerical recipes, which I ...
1
vote
0answers
162 views

Positive integrand giving negative answer

I'm integrating a positive function f(t) times sin(t) from 0 to pi/5 and get -38. Actually f is slightly negative for a short time (smallest value ~ -0.0005), but far from enough to explain this. ...
1
vote
0answers
76 views

How can I compile function with Apply?

For example, I tried to compile this function but Mathematica gives "The only function arguments supported are Times, Plus, or List", I have no a way to compile this. ...
1
vote
0answers
208 views

Return Functions from parallel execution of module

I wrote a module which numerically solves an ODE using NDSolve. The result from this is e.g. either ...
0
votes
0answers
58 views

How can I avoid a scoping problem when differentiating?

I simplify my real problem as follows: I define a rule function as Clear[rule]; rule[i_] := tt -> i; the real rule function is not this simple. I define a ...
0
votes
0answers
54 views

Maximum and mean of a multi-variate function over a restricted lattice

I have a function Q, and I want to find the maximum value, the corresponding arguments for the maximum value, and the mean over a certain range of arguments. I ...
0
votes
0answers
79 views

How to save the results in an identical Excel file (.xls) in each iteration of a Do loop

Assume the following code (Below code is just an example to clearly illustrate my problem): ...
0
votes
0answers
116 views

A problem with functions and Infinite expression 1/0 encountering

Following code (function) makes integrals and then replace f[x] with Cos functions and calculate the definite parametric ...
0
votes
0answers
64 views

How can I use a For loop in a recursive function?

I am creating a simple radix2 FFT algorithm (based on Cooley-Turkey) by using a recursive function to obtain the fft. The function is supposed to work on a list (assuming the length is a power of ...
0
votes
0answers
74 views

creating some smooth density functions

I would like to create some density functions based on some distance measure $D$. As a base density function lets say I have a Gaussian density $f$ with mean $-1$ and variance $1$. I would like to ...
0
votes
0answers
66 views

How to insert a function into OptionsPattern?

I’ve written a function TableauForm to draw a standard Young Tableau. This problem is related to this one, however, the difficulty is that, a function has to be applied to the list in my case. This ...