# Questions tagged [programming]

Questions on writing non-trivial programs in Mathematica. Do not use this tag for questions on plotting/graphics or for questions on doing mathematics with Mathematica, where the focus is more on the math than the program.

1,434 questions
Filter by
Sorted by
Tagged with
23 views

### Problem wiith If statements inside For loop [closed]

Consider If statement If[1 == 2, 1] which is false and so does not evaluate, and If statement If[2 == 2, 2] which is true ...
64 views

78 views

### FindRoot & Non-negativity constraints

I employ FindRoot to solve a large optimization problem. I formulate the optimization problem in terms of first-order conditions (in that specific problem, methods based on the objective function do ...
41 views

...
344 views

### Writing a program that divide numbers until I hit a one digit number

Well, I have the following question: How can I write a program such that an input number $n$ is divided by the number $k$ as long as the resulting number does not have one digit, if the resulting ...
32 views

...
35 views

### ComplexExpand in Module doesn't work as it should, when there is function at the left

I'm new with mathematica and I'm having a problem. I hope you can help me. I made a module to built a system that I can use to find some condition for given polynomial is a Shur polynomial. (Actually ...
138 views

### Help coding an Abelian Sandpile

I'm attempting to code an abelian sandpile. I thought a good way to go about it would be utilizing recursion, which I've never tried in MMA before. The code currently runs but doesn't seem to work (it ...
90 views

...
156 views

### Trying to build a sequence of logical statements ||

I need to build a sequence of n conditions separated by ||. Something like, f = #1===f1[#2] || #1===f2[#2] || ... || #1===fn[#2] & where the number n (integer, of course) is not fixed. ...
31 views

### A problem with Cases and Pattern recognition: unexpected behavior

I need the following command (to isolate exponents and variables): F[X_] := Cases[ X , G[x_]^m0_. -> {x, m0}] This example gives the correct answer: ...
557 views

### Why does Mathematica ignore 1 as an exponent? Or as a coefficient?

Two different examples of same problem: In: Cases[{f^2, g^3, k^p, h}, x_^n_ -> n] Out: {2,3,p} # The result misses the ...
154 views

### Defining a function which is numerical on all vectors of arguments

There is an attribute NumericFunction in Mathematica that can do the following job: ...
90 views

### Problem using TableForm and Do loops

The following code is supposed generates a table based on different calculations for a given q (e.g. q[1] for this example): ...