# Tagged Questions

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.

192 views

### The Flat Attribute, Unevaluated and the Evaluation Process

To make this question easy to follow let's give some symbols a couple attributes. Attributes[f] = {Flat}; Attributes[s] = {Orderless}; Now consider the following:...
1k views

### Getting serious about Mathematica programming

I'm at a point in my Mathematica journey where I need to be a little bit more strategic about my coding. Presently, I have a bunch of notebook files organized using the filesystem of the OS and ...
476 views

### What Mathematica features and idioms have $n^2$ complexity or worse [closed]

Here are a few: AppendTo[data, elem], Sort[data, test], in some cases use of ___ (as ...
689 views

### Matrices and polynomials: MMA 8 vs. 9?

I want a function to take a polynomial from a list, plug a certain matrix T into that polynomial, and return the answer as another matrix. My program uses the applyPoly function suggested by a user in ...
220 views

### Differential operator involving permutations

I would like to construct an operator in Mathematica of the following form, $$D_i=\partial_i +\sum_{i \neq j}^n\frac{1}{x_i-x_j}p_{ij}, \quad i=1,...,n$$ where $p_{ij}$ is a (symmetric) permutation ...
316 views

### Pseudo-code for rules of probability?

I am having a hard time in Stats understanding some basic rules of probability and set-theory, namely $P(A|B)$, $P(A\ \textrm{and}\ B)$ and $P(A\ \textrm{or}\ B)$ where $A$ and $B$ depend on each ...
317 views

### How to group lists that own one common element?

I have produced a list of sub-lists by the following: ...
114 views

### Conditioning on group of functions

I have two sets of functions which I want to implement them in a single function with an option indicating which set of functions should be used. Suppose that I have two lists like:(updated example) ...
2k views

### Mutual Information involving two matrix states

I basically retrieved the following technique of evaluating the mutual information involving two matrices from this site at http://bmia.bmt.tue.nl/People/BRomeny/Courses/8C080/default.htm The ...
343 views

### How to automatically restart Mathematica kernel after out-of-memory error

I want to run a Mathematica code repeatedly, even after the kernel shuts down when it is out of memory, because I have designed my program to continue appending the data to a file. Currently, I have ...
106 views

### Map and Scan ignore HoldFirst

I am trying to write a simple function that takes a list of data and outputs it to a file. I'd like the name of the file to be the same as the variable that holds the list. It seems that giving a ...
516 views

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 <...
411 views

### A fast, robust DropWhile

For reasons that have never been entirely clear to me, Mathematica has had a built-in TakeWhile function since version 6.0, but has no equivalent ...
274 views

### Optimal image quality using Rasterize Function

Based on previous posts about plotting two y axes on the same x axis, I wrote this function: ...
122 views

### how to generate repeatable Unique streams?

I need to label some data in arbitrarily nested ragged lists, with a stream of unique labels. It's very convenient if the labels are consecutive integers, starting at ...
250 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 F=F(\omega)=\displaystyle\int_{0}^{T}h_{t}...
279 views

### Making an animated simulation without procedural loops

I'm still new to Mathematica and this is the first time I've wanted to do something more complicated than plotting and changing parameters of mathematical functions. I want to make a simple ...
148 views

### Difference between Directory[] and NotebookDirectory[] .. a trailing /?

The following was the code: Directory[] NotebookDirectory[] The output was ...
236 views

### On reimplementing the Select function [duplicate]

I am working through the course Programming Paradigms via Mathematica. One of the exercises asks that you construct a function that mimics Select,even with three ...
158 views

### Is it possible to write a function immune to symbol redefinitions in any Block surrounding its invocation?

Normally, semantics of symbols used in a function definition can be changed by their redefinitions in Blocks surrounding the function invocation: ...
825 views

### Dynamic Programming with delayed evaluation

By using dynamical programming, we can save intermediate steps for recursive relations, as in f[n_]:= f[n] = f[n-1] + f[n-2] However, this only stores ...
394 views

### Replace with position and order number

question conversion1 : Convert "[AA]AB[AA]BB[AA]B[AA]CCC" to "[A1A2]A3B1[A4A5]B2B3[A6A7]B4[A8A9]CCC" conversion2 : Convert <...
144 views

### Is it possible to use the global definition of a symbol as part of its new local definition set in a Block?

Consider the following expression: Block[{Print = CopyToClipboard}, doSomething[]] Now all calls to Print from ...
367 views

### Handling Overflow

I have a notebook which takes in a user-defined function and starting value and tracks the orbit of the particle under iteration of the function. The problem occurs when the user enters a starting ...
491 views

### Interpolating function as a model in Mathematica's procedures for fitting

Is it possible to use interpolating function with parameters as a model for NonLinearModelFit (and other integrated methods for fitting)? Similar question was ...
50 views

...
509 views

### Adapting “Find and Replace” functionality to work with Patterns

I was thinking if there is something like Find and Replace (Crtl+F) functionality adapted to work with patterns. Probably not, but it seems possible to create this with some effort and skills in <...
108 views

### Rounding only reals in an expression containing, reals, integers and symbols

I am trying to make a function that would make rounding real numbers in an expression possibly consisting of real numbers, integer numbers and symbols. An example of such an expression is below: <...
1k views

### Mathematica TCP socket client toward Trading Platform

I'd like to connect Mathematica with my Italian electronic trading platform. To connect I need to open a TCP socket client towards the trading platform and send a string command. The high-level ...
413 views

### How to determine cluster membership using FindClusters?

I have a 1000 by 3 data matrix in which for each person we have 3 scores. I want to cluster those persons into 8 cluster using Agglomerative method. I did the clusetring by: ...
163 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 <...
107 views

### Generating Palindromic_number [duplicate]

I'm trying to construct Palindromic_number, I came up with this code: ...
645 views

### How can I generate a nested array like this one?

Well, this is how the array looks like: I came up with this code: n = 10; Nest[ArrayPad[#, 1, 1 - #[[1, 1]]] &, {{1}}, n] /. {1 -> "*"} Any better ...
262 views

### Is there a method to enumerate the keys/values of SystemUtilitiesHashTable

Lacking from the simple API of SystemUtilitiesHashTable is a method to enumerate the keys/values. ...
195 views

### What is the fastest way to maintain a large set of expressions?

In my algorithm I need to maintain a set (an unordered list of distinct elements) of expressions supporting two operations: Test an expression for membership in the set Adding a new expression to ...
133 views

### Odd edge-case behavior of Block

In this example, Block is used to localize the variable cache as used in the function g when called from the function ...
2k views

417 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 ...
617 views

### Mapping multiple functions

This question was part of a course on Mathematica written in 1998. Each of the functions f1, f2, and f3 defined below has a root near x=2. Map an anonymous function involving FindRoot[] onto ...
1k views

### Forecast Future Stock Prices - Brownian Motion - Again

excuse me, I think I have here a technical problem with Mathematica yesterday I posted the question with the title: Forecast Future Stock Prices - Brownian Motion I am still not very experienced but ...
6k views

### Having used Mathematica as a “gateway” language, where to from here?

I have been using Mathematica for about a year. It is the first language that I have attempted to learn. I'm still very much a newbie, but there are moments I feel more like I am waving than drowning. ...