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.

learn more… | top users | synonyms

42
votes
0answers
636 views

Is this 30% slowdown in Mathematica 10 due to DownValues lookup time?

Running several numerical self-programmed packages I realized already some time ago that Mathematica 10 needed between 20 and 40% more time. I did already report this of course with a simple example ...
18
votes
0answers
245 views

How to perform document classification (i.e. extracting topics from text)?

I need to build a multi-label text classifier. There are a bunch of techniques for doing this, and it's called automatic document classification. I'm trying to use the EM technique (expectation ...
14
votes
0answers
294 views

What Mathematica features and idioms have n^2 complexity or worse

Here are a few: AppendTo[data, elem], Sort[data, test], in some cases use of ___ (as ...
9
votes
0answers
151 views

Can code optimize code?

Are there functions, programs or packages that deal with optimizing mathematica code i.e. re-writing ineffecive or convoluted code. -This question has haunted me since I joined SE. The background for ...
5
votes
0answers
143 views

How to download and combine S&P 500 stock prices

I want to download historical S&P 500 stock prices and combined them into one big file, having only one column of date referencing all stocks. Here is what I have do so far. ...
5
votes
0answers
198 views

Convert logical relational expression to / from disjunctive and conjunctive forms?

I would like to convert logical relational expressions in disjunctive form, e.g., $$(x \lt -1) \lor (-1 \lt x \lt +1) \lor (x \gt +1)$$ into conjunctive form, e.g., $$(x \ne -1) \land (x \ne +1)$$ ...
4
votes
0answers
77 views

Implement a piecewise function elegantly and efficiently

Given that $$ g(x)= \begin{cases} max(x_{min},x-m) & 0.5x \leq max(x_{min},x-m) \\ 0.5x & max(x_{min},x-m)<0.5x<min(1,x+m) \\ min(1,x+m) & min(1,x+m)\leq 0.5x \end{cases}$$ ...
4
votes
0answers
63 views

How to save the result in the Notebook (.nb) and shut down the computer when the calculation is done

I have a notebook(.nb) which its calculation is time-consuming and long. I can not observe it if the calculation is done or not. Therefore, I want to : (1) Save the results in the notebook(.nb) ( I ...
4
votes
0answers
209 views

Call Haskell from Mathematica and return the results inside Mathematica

I would like to learn Haskell using Mathematica's environment. I know there is the RLink protocol. Is there a similar protocol for Haskell?
4
votes
0answers
84 views

Is there a way to check whether two notebooks share the same variables?

When I code in Mathematica, I often re-use code from old notebooks which fulfilled a specific purpose; for example, one testing for soft matches in strings, or one that identifies outliers on a graph ...
3
votes
0answers
62 views

How to assemble and disassemble a function into steps

I've watched many programmers (both novice and expert) write functions in Mathematica and have observed a common behavioral pattern. This pattern has many elements that would be automated and thus ...
3
votes
0answers
150 views

How to restrict the mouse cursor to stay within a box?

I'm trying to use Mathematica to write small games, and I find that it would help to restrict the player's mouse into the game window (just like other games do). Is there any way to achieve this? ...
3
votes
0answers
266 views

A* algorithm for finding shortest path in a graph

FindShortestPath finds the shortest path between two vertices in an edge-weighted graph, allowing a choice between the Dijkstra and Bellman-Ford algorithms. In my (limited) understanding, both of ...
3
votes
0answers
128 views

Using NVIDIA 3D Shutter Glasses with Mathematica

Mathematica has great capabilities to display 3D Graphics rendered to the 2D screen. This should make it perfectly suited to use the Graphics3D system together with an NVIDIA Graphics card, a 3D ...
3
votes
0answers
238 views

How to compute the Lovász number for the given graph in Mathematica?

Here is a graph whose adjacency matrix is ...
3
votes
0answers
120 views

Force Dispatch to generate dispatch tables

Dispatch creates hash tables only for lists of length larger than 3. Is there any way to force MMA to create hash tables even for lists of length smaller than 4? ...
3
votes
0answers
232 views

Malliavin Derivative with Mathematica is it possible?

Is it possible to define a Malliavin calculus with Mathematica 9? Consider a random variables on the Wiener-space $\Omega=\mathcal{C}([0,1])$ of the form ...
3
votes
0answers
143 views

I am missing a function like HoldPattern

Temporary message: I am planning to edit this question, making the examples less confusing and by moving the things that are confusing to a separate question For any confusion about expressions that ...
2
votes
0answers
71 views

Mod[1.2, 0.2] is not equal to zero

I'm new to mathematica but this doesn't seem to make any sence In[1]:=Mod[1.2, 0.2] Out[1]=0.2 Why is it not zero? Edit: This is what I wanted to do: ...
2
votes
0answers
79 views

Distance Time Warp (DTW) function implementation in mathematica

The DTW (Distance time warp) is given here http://en.wikipedia.org/wiki/Dynamic_time_warping There is an implementation of DTW in R as well as MATLAB. However i am unable to find something for DTW in ...
2
votes
0answers
30 views

How to syntax check that all instance of symbol must be contained in Subscript[]

I have a function f[expr] that is only allowed to take an expression expr that is a polynomial in ...
2
votes
0answers
76 views

Maximizing Large Multivariable Function over Region with Parameter Constraints

Brand new Mathematica user here. I have a complicated function to maximize, and thought I would try software like Mathematica instead of taking derivatives by hand. I found some Mathematica ...
2
votes
0answers
65 views

Simulating a system of nonlinear ODEs?

I was trying to simulate a system of ODEs on Mathematica in an effort to try to understand how to muck around with Mathematica but for some reason the following lines of code do not yield any results; ...
2
votes
0answers
53 views

What is “ (Dialog) Input [ ] := ” after evaluating a cell?

I have done a time-consuming run and calculation. After many hours ( about 7 hours!), the black color which shows that the cell is evaluating, turn into gray and a strange text appears like this : ...
2
votes
0answers
54 views

Can BreadthFirstScan be modified?

I would like to obtain a "slick" implementation of A*-search algorithm on Graph objects, using the built-in BreadthFirstScan (if that is possible at all). I noticed that BreadthFirstScan is static in ...
2
votes
0answers
201 views

Lazy evaluation/loading of parts of an expression

Is it possible to have an expression x such that its elements are only evaluated when they are individually accessed, for example when evaluating statements like ...
2
votes
0answers
280 views

Forecasting future Stock Prices II

I intend to do the following: I want to forecast future stock price under the following assumptions: The stock price is governed by the stochastic differential equation: dS = μSdt + σSdWt whereas ...
2
votes
0answers
150 views
1
vote
0answers
36 views

How to package a function for export?

I often post code for functions on Stack-Exchange, and then later find that they are unexecutable - that people can't use them because I mistakenly omitted some private functions or values that are ...
1
vote
0answers
59 views

Updating procedural fitting algorithm to more efficient style?

For some time now, I have used this procedural programming approach to fit data in my research that is too cumbersome for the built in Mathematica functions. (Although this simple example works fine ...
1
vote
0answers
58 views

Programming for matrix manipulation

I want to write a programme which operates on nd x nd matrices. The programme looks the matrix as a n x n block matrix where ...
1
vote
0answers
93 views

Expectation Maximization Algorithm

I would like to use the expectation maximization algorithm within Mathematica. The issue is that I am very basic user and progress slowly with understanding functional programming.. I have found this ...
1
vote
0answers
44 views

Settings to disable global scope

I am building a fairly large application in Mathematica, and globally scoped variables are causing issues. I would like globally scoped variables to be out-of-scope for my expressions, except by ...
1
vote
0answers
100 views

How to construct a coordinate system that owns detailed calibration in the 3D enviroment?

Recently,I write a program to demonstrate the forward kinematics of the SCARA robot.The code showed as below: Using this function to construct the BigArm and ...
1
vote
0answers
119 views

Finding Values of All Nine Constants in q-hypergeometric Equation

I suspect that an identity of the form $$\sum_{j=-n}^{j=n}(-1)^jq^{j(5j+1)/2}=\sum_{r=0}^{n}f_{ar+bn+c}(-1)^{n-r}q^{(n-r)(dr+en+f)/2}\frac{(q;q)_{gr+hn+j}}{(q;q)_{n-r}}$$ for $a, \dots , j$ integer ...
1
vote
0answers
96 views

Read expression from Mathematica via Mathlink C++

This is a simple C++ program to send an expression to the_Mathematica_ Kernel and get its response. ...
1
vote
0answers
90 views

DifferentialEvolution scaling factor randomization

Using NMinimize for finding global minima, one can choose the DifferentialEvolution method. You can find a (not so) detailed ...
1
vote
0answers
89 views

Compiled version of user-defined function

I have a function for parameter estimation with these codes: ...
1
vote
0answers
105 views

Sum slowing down computations

I am trying to compute higher order Casimir invariants for some representations of certain groups. I can get the quadratic, cubic and quartic but beyond that things are taking too long to the point I ...
1
vote
0answers
146 views

Why doesn't ParallelMap improve the performance of FoldList?

This question arose during my analysis of the following problem: filling gaps. (The code used here is Simon Woods's work.) FoldList seems to not cooperate with ...
1
vote
0answers
256 views

Data structure for a list of actions

The idea: I need to generate a sequence of events then run a "propagator" over the list of events where the "propagator" will update the state of the following event. I can then write functions that ...
1
vote
0answers
233 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
75 views

I cannot pass any script to `math`, in a command line

I want to run some lines of Mathematica code by a command-line call for math. As a test, I save just the following code in a file ...
0
votes
0answers
44 views

Question about treillis structures

I have difficulties finding a command to plot multiple segments connected in nodes in Mathematica. Ultimately, my goal is to modelise something like this by entering nodes coordinates. Also, the ...
0
votes
0answers
78 views

Solving for a Transfer Matrix

I am currently working on a program that will solve a transfer matrix and extract several elements. Particularly, the transfer matrix is characterized by four elements in a ...
0
votes
0answers
66 views

Using Animate/ListPointPlot3D on more than one list

I have a couple orbits defined which have been mapped into one array as shown: ...
0
votes
0answers
20 views

what's the difference between CreateKernelLink() and CreateKernelLink(String Arg)?

I have a .NET program which will connect to MathKernel. When the program runs, there will be a icon of MathKernel on the taskbar. ...
0
votes
0answers
82 views

How do I perform the following numerical integration

I have the following integral to evaluate numerically: $$x(t) = \frac{1}{f(t)}\int_0^{t_b} t^m (t + n)^o \sin(pt) \mathrm{d}t \quad m,n,o,p \in \mathbb{R}$$ ...
0
votes
0answers
161 views

Converting a matlab program into Mathematica 10

I sought help from this entry at Calling MATLAB from Mathematica to see if I could CONVERT a mathlab program which simulates polymer dynamics that is provided at the download section at ...
0
votes
0answers
38 views

Path must include /TypeSystemLoader.m?

I have encountered a number of odd issues using the Wolfram Workbench 3.0 Debugger. Whenever I try to step into a Switch[] statement, I get the following error message: "Problem Occurred - Debug ...