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.
4
votes
3answers
144 views
Creating Multi-Tabbed Grid with Preserved Contents and Overview Grid
I am in the process of creating an application/panel that will aide me in scheduling hours for my staff of ten or more. I am hoping to create a multi-tabbed grid within which I may collect data about ...
1
vote
1answer
116 views
Problem with function as an argument
I want to write a function like the following:
s[u_, v_, x_, val_] := u[val]/NIntegrate[u'[x] v[x] + u'[x] v'[x], {x, 0, 1}]
So I can evaluate something like
...
3
votes
2answers
411 views
Optimize inner loops
I'm Mathematica newbie so please be gentle :)
I have this, heavily non-optimized part of code, which I would like to speed up. I have put all matrices to be RandomReal, but in my code they take ...
0
votes
1answer
215 views
How can I make many runs of a simulation and plot all the results with one expression evaluation?
I have many cells, starting with this first cell:
...
1
vote
0answers
99 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 ...
3
votes
1answer
126 views
Why is MapIndexed better than mapping over a range?
Background
I'm working on an application in which I need to create and control two sets of locators. I know from reading the Mathematica documentation and certain posts on Mathematica.SE that this ...
2
votes
1answer
217 views
Cournot Equilibrium
I'm trying to determine reaction functions of a Cournot equilibrium for $n$ firms using the same optimal condition, using the fixed point method.
This is the method I'm using:
...
9
votes
5answers
339 views
Incrementing a number where each digit has a different base
Let's say I have a list, for instance {10,5,3}, indicating the bases for each digit of my 3-digit number. Using this basis, if I wanted to increment {8,4,1} a couple of times, here's what I would get:
...
2
votes
0answers
117 views
4
votes
3answers
326 views
How to make brute force coding more efficient?
Hi guys and guysettes,
The little Mathematica I've been using/seen so far, it seems to be all about neat "one-liners" using the underlying functions and working with lists & maps to solve issues, ...
5
votes
1answer
112 views
How to create a Hyperlink within the current Notebook?
Using “Create Hyperlink” dialog window I can create a link to a tagged cell in my notebook (it's “Destination notebook: Current notebook” radio button).
Now, I can't figure it out how to create such ...
7
votes
3answers
329 views
Rewriting For loop to FoldList or similar
In CrossValidated, the answer to a question on prediction of number of viewers of Gangnam Style is given in R. I have mapped the answer directly to Mathematica:
...
7
votes
3answers
205 views
Restricted accumulation of values
Please consider the following list data. I was trying to accumulate data until the result turns positive the first time and ...
7
votes
4answers
362 views
How to implement dual numbers in Mathematica?
I wonder how can I implement dual numbers in Mathematica, so that all functions work well with them (as with complex numbers).
Particularly, for each function $f$, ...
12
votes
5answers
565 views
How to improve this code for solving the “Mr.S and Mr.P” puzzle?
Mr.S and Mr. P puzzle — "Formalization of two Puzzles Involving Knowledge", McCarthy, John (1987)
We pick two numbers $a$ and $b$, such that $a\geq b$ and both numbers are within
the range ...
4
votes
1answer
153 views
Maximizing functions with Which statements
I'd like to be able to find the maximum value that my Capex function (see below) generates. This is a fairly simple function so I could just add it up but I have more complex functions of a similar ...
2
votes
5answers
296 views
How to leave function unevaluated programmatically?
Is it possible to write a function in such manner, that it can be either evaluated or left unevaluated?
This is a general question. Sample below is just a sample. No need to find solution for this ...
2
votes
1answer
603 views
Using triangulation
I have been presented with 3 known points and the power densities at those points. I need to use those points to find the location of the actual antenna which is generating the signals.
Power ...
6
votes
1answer
170 views
Return a Part by Reference? (For accessing hierarchical / structured data)
Is there a way to return a part of a list by reference, for reading and writing?
I want to do this so I can easily manipulate "rule-styled structured", i.e., hierarchical data that is loaded from a ...
4
votes
3answers
279 views
6
votes
1answer
224 views
Guides for programming CDFs
Are there any tutorials for programming high-quality CDFs, like the interactive calculus textbook presented at wolfram.com?
Mathematica's Help is extremely impressive but it really does not help much ...
1
vote
2answers
212 views
Inputting two arrays for a module in Mathematica
I am relatively new to the Mathematica enviroment and not sure where I am going wrong. I have evaluated the question and understand it, but dont know how to exactly create a module for it.
The ...
1
vote
1answer
280 views
Equivalent of Python's “all” function in Mathematica
The Python function
def isPrime(n):
return all(n % i for i in xrange(2, n))
checks if a number is a prime number by using ...
17
votes
2answers
225 views
3
votes
2answers
102 views
Localizing Pattern Names
When I want to define a function that uses a pattern, how should I localize the pattern name (i.e., x_ localizing the symbol x)? ...
5
votes
2answers
192 views
How can I use Max[] in a function that is passed a list not find the max of the list
For most functions in Mathematica, passing them a list will call the function on each element of the list. For example:
...
2
votes
1answer
178 views
Do “objects” in Mathematica have to be declared?
A while ago I learned a trick which allows one to imitate object-oriented programming in MMA using SubValues:
...
5
votes
2answers
288 views
How can I get exactly 5 logarithmic divisions of an interval?
I'd like to get exactly 5 divisions from x to y on a log scale. Can FindDivisions do this?
0
votes
1answer
322 views
Getting imaginary data from known real data using Kramers-Kronig relations [duplicate]
Possible Duplicate:
Kramers-Kronig in Mathematica
I am trying to get epsilon2 (imaginary part) from known epsilon1 ...
4
votes
1answer
231 views
How to combine a set of Plots, including self-drawn Inset/Lines/Circles?
I have a set of 9 plots which should be combined into one plot. Each of these plots contains a ListContourPlot, some circles, lines and an ...
1
vote
0answers
116 views
Fighting Less::nord at the root: Any unintended consequences?
After being plagued too much by Less::nord and companions, I've decided to try to fight it at the root: The comparison operators. I noticed that typically, the bad ...
7
votes
1answer
270 views
Communication between parallel kernels
Greetings. This is my first post here, also, I am not a seasoned programmer, so any advice pertaining to coding that is not directly related to the problem (stated below) is welcome. I am having ...
8
votes
1answer
455 views
Poisson solver using Mathematica
I am looking for some help with a Poisson solver I am writing in Mathematica. The code is quite long with Arrays plugged in, so the full details can be found at http://pastebin.com/uSrSDcW6
I am ...
10
votes
1answer
154 views
Modules that initialize themselves on first call
I use a lot of functions that extract a specific data item from a file with many data items. I want these functions to load data (slow) and return the item (fast) on first call, but just return the ...
5
votes
2answers
119 views
How to silence all messages associated with a built-in symbol?
The post title's pretty much says it all...
The reminder of this post just describes the little headway I made with this problem, FWIW.
One would hope that
...
4
votes
2answers
154 views
Split string into sub-strings of length n [duplicate]
Possible Duplicate:
Partition string into chunks
How can I split a string into sub strings of length n? For example I have a string
"ABCDEabcde1234"
...
6
votes
2answers
308 views
Web scraping and multi-threading in Mathematica
I'm working in some web scraping using Mathematica, and today, to speed-up the process, I used bash commands (xargs with parallel options with curl and wget) using ...
0
votes
2answers
109 views
How to avoid restart during development? [duplicate]
Possible Duplicate:
How do I clear all user defined symbols?
During package development things get messed up quite often. (especially when playing with notations)
Is there a simple way to ...
7
votes
3answers
197 views
how to read in a file in the same directory?
Now I am writing a small package. I have written several files and put them in the same directory. And some files need to read in or include another file in the same directory. But when I simply write ...
14
votes
3answers
469 views
Are there suitable versioning systems for Mathematica notebooks?
I am considering a project using Mathematica and openCL. I know that the openCL C source code can be tracked.
Has anyone used a versioning site or software so multiple developers can modify a common ...
4
votes
1answer
120 views
Transform sequential cell operations to programmatic workflow
Let's say I have a workflow that involves importing images and turning them into an animated gif.
Here's how I currently have it setup:
Import Images:
...
3
votes
1answer
285 views
Control over depth-first scan and breadth-first scan
Is there a way to conditionally take control/modify the flow during a depth-first scan or the breadth-first scan ?
Say, for example, if a particular node if found, consider it as a leaf-node and ...
5
votes
1answer
323 views
Multi-objective genetic algorithm in Mathematica?
Is there any implementation of a multi-objective genetic algorithm for Mathematica?
4
votes
1answer
195 views
How to organize and run functions?
I am very new to Mathematica. I thought I would try it out for my first assignment in my computer science class. Until now I have only used C-base languages including C#, Java, Objective-C, and ...
2
votes
1answer
177 views
FindMinimum, NMinimize, etc. with external process
I was hoping to be able to use MMA's minimization power to work with an external process. I want to minimize the function 'TryThisNumber[x_]' which sends the value of x to something external and gets ...
1
vote
2answers
200 views
How to insert an expression in a Mathematica program?
I need to insert a very large expression in a Mathematica program. So I first
Put[large expression,"file"]
and then use
Block[{}, Get["file"];...]
to ...
19
votes
3answers
323 views
How can I regroup elements in a list into a tree based on their values?
I have a list of elements in an outline, here is an example that is only 3 levels deep:
...
4
votes
3answers
162 views
Is it possible to replicate the “magic” of OptionPatterns[] with DynamicModule's local variables?
Creating richer interactive interfaces that are generated by a DynamicModule invariably requires more complex data structures and in particular, a larger argument ...
9
votes
2answers
146 views
How can I build an inline documentation utility?
I often have a large function to which I add inline comments, but then I can't see the forest for the trees. How can I make a tool that extracts the comments and tokens within them to generate an ...
18
votes
11answers
645 views
Generating an ordered list of pairs of elements from ordered lists
I have a pair of ordered lists. I want to generate a new ordered list (using the same ordering) of length n by applying a binary operator to pairs of elements, one from each list, along with the index ...

