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.

8
votes
0answers
311 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)$$ ...
7
votes
0answers
778 views

How to create protected single-file stand-alone CDF applications

After hours of work trying to understand how much protection I can get when creating stand-alone CDF applications I have come to the decision that the best protection to my work is provided by ...
6
votes
0answers
67 views

How to trigger an “ErrorBox behavior”?

Here's an example of what I mean by an "ErrorBox behavior". In the front end, if one evaluates the expression ...
6
votes
0answers
151 views

Mimicking Console and Output Matlab/Rstudio-Style Environment in Mathematica?

I am trying to crudely approximate the RStudio or Matlab Workspace environment in Mathematica by having a specific notebook function as the "console notebook" where I execute commands and another ...
6
votes
0answers
98 views

How is CellContext->CellGroup supposed to work?

After reading the documentation on the subject, I still cannot get CellContext->CellGroup to work. Here's a simple example. (Unfortunately, I cannot easily ...
6
votes
0answers
472 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 ...
5
votes
0answers
171 views

How to Write Stand-alone Mathematica Projects/Programs

I wish to write several stand-alone projects/programs using Mathematica because of its easy-to-use graphics. I could use Python for this, but Mathematica has built-in graphics that would be better ...
5
votes
0answers
94 views

Use Mathematica with Go Language

I would like to know if I can use Go and Wolfram Language? Example C ...
5
votes
0answers
97 views

Techniques in debugging with preview of possibly large expressions + garbage collection issues

First of all, all appreciate all suggestions how to rephrase the title to make it more friendly. Here's the background: Let's say your top level procedure flow is complicated, involves url calls, ...
5
votes
0answers
232 views

Can I define an axiomatic (Boolean algebra) system and prove theorems using Mathematica?

The general question is Can I define an axiomatic system and prove theorems using Mathematica? The more concrete one is about Boolean algebra. I consider this axiomatic Boolean algebra system (...
4
votes
0answers
819 views

How to find the a minimum cost perfect matching

Crossposted on Wolfram Community A a minimum cost perfect matching is very useful tool.This three links about this demand just related me,let alone all MMA.SE. How to get some pairing with smallest ...
4
votes
0answers
204 views

Is Mathematica a good choice for a scientific project with Machine Learning?

I'm a chemist with some rudimentary programming skills and in the middle of the year I'll be starting a project concerning machine learning, so, I'm sorry if I'm going to ask two questions in this ...
4
votes
0answers
222 views

How to convert a URLFetch to a URLRead or URLExecute?

Consider the following function: ...
4
votes
0answers
279 views

Code formatting

This question is a follow up from Formatting notebook files In Programmatic formatting for Mathematica code - possible? masterxilo proposed to use ...
4
votes
0answers
202 views

Finding all Minimal Cut Sets for Site Percolation?

Bug introduced in 9.0 and persisting through 11.3.0 FindVertexCut and FindMinimumCut are new in 9.0. I want to disconnect the ...
4
votes
0answers
214 views

What am I missing in this highly oscillatory integral?

I want to numerically integrate this equation (in python without calling Mathematica): $\int_0^\infty {\rm d}k f(k) J_v(r k) J_n(s k)$ where $f(k)$ is a non-smooth function, $J_v$ are the Bessel ...
4
votes
0answers
90 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 ...
4
votes
0answers
997 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 ...
4
votes
0answers
456 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
144 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 ...
4
votes
0answers
93 views

How to insert expression matching the format?

I would like programmatically to insert/write an expression at the current insertion point, but matching the current format, such as font size and style, so that it looks like the user typed it. ...
3
votes
0answers
288 views

Epsilon algorithm to accelerate sum's convergence in a functional approach

I am trying to learn to use Mathematica in an efficient way. Thus, I decided to spend some time on functional programming. I would like to implement the so-called epsilon algorithm, that is used to ...
3
votes
0answers
73 views

What's the role of the lines order in defining a function?

I'm totally surprised by the finding I had never noticed before. This code works as obviously intended ...
3
votes
0answers
604 views

Code Review: ECDSA for Mathematica

The code below contains functions related to ECDSA (Elliptic Curve Digital Signature Algorithm) with standard parameters secp256k1. The implementation is based on ...
3
votes
0answers
158 views

Help to finish a Sperner lemma application

This is the code for the celebrated Sperner's Lemma in two dimensions --- which is equivalent to Brouwer Fixed Point theorem. Incidentally, it's my first program without any help --- until I ask this ...
3
votes
0answers
131 views

What is recommended way to define my function option

In Mathematica 5.x days many packages used the following standard mechanism to read option values ...
3
votes
0answers
707 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 ...
3
votes
0answers
338 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
416 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
1k 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 <...
3
votes
0answers
274 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}...
3
votes
0answers
532 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 ...
3
votes
0answers
219 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
39 views

Problem with PopupMenu: Its values don't update dynamically

I have a problem with PopupMenu inside DynamicModule, its values don't update dynamically as they supposed to. The example below ...
2
votes
0answers
67 views

Calling a notebook from a different notebook

Basically I have a notebook (let's call it nb1) that when evaluated yields one number when I specify some parameter $\alpha$ (in nb1). I want to call nb1 in a different notebook (nb2) using for ...
2
votes
0answers
45 views

Fold/ NestList/ etc in MCMC loop for optimisation

I am trying to simplify and optimise an old loop code I wrote. Since Fold and NestWhile use the results of the last iteration in the new iteration, I would like to use them in order to get rid of Do ...
2
votes
0answers
127 views

Extracting the curl-free component of a vector field

I am trying to extract the curl-free component of a discrete vector field. My plan is to take the Fourier transform of the vector field and then extract the radial component in Fourier space. The ...
2
votes
0answers
72 views

Package for static Mathematica code analysis to produce a Cayley tree?

I am looking for a package which can display a static dependency tree of code from a single Mathematica notebook or from a list of Mma notebooks. (Of course, to prevent such a tool from producing tons ...
2
votes
0answers
86 views

How to set up Switch with variable number of conditionals?

I would like to use a Switch command with IntegerPartitions[n] of terms with n ranging from 3 to 12 and n chosen at run time. I have: ...
2
votes
0answers
84 views

How to implement a regular grammar in Mathematica 10.0 onwards?

I would like to see a new answer to this question: How to implement a regular grammar? considering the introduction of GrammarRules in 10.0 ( 2014 ). ( I don't know if this question satisfies the ...
2
votes
0answers
86 views

Does Mathematica have a method for achieving the same goals that Aspect Oriented Programming does?

I imagine that this question has been asked before, yet I'm not able to find an answer using the form of the question I believe might be asked. Is there a mechanism for duplicating the ...
2
votes
0answers
222 views

Flattening the output of Solve[]

I want to flatten the output of solve into a an un-nested list. For instance, Solve[y[x] == x^2 + c, c] yields ...
2
votes
0answers
81 views

A question regarding shadowed symbols

The more I study, the less I understand. This is the HelloWorld package: ...
2
votes
0answers
196 views

Dynamic array in Mathematica like malloc in C++

I have a table to describe a crossroad. Each traffic line has it own Q(flow), V( speed) and direction. I'm saving data in array, which hardcoded (very simple code data = {{66, 55, 3}, {44, 33, 2}, {...
2
votes
0answers
138 views

Findminimum fails in loops

Introduction to the problem: the function F[x][u,v,w] I'm currently dealing with a very strange minimalization problem. I have a function F[x][u,v,w] which is ...
2
votes
0answers
215 views

How can I launch kernels in series using mathlink

I have written below code to launch n kernels connected to one another in series using mathlinks. Before you read the code allow me to be more precise what i want to achieve: Source kernel(k1) will ...
2
votes
0answers
148 views

How to use RunProcess to run python interpreter

In a related question How to use RunProcess to import external function? @taliesin provides a very nice answer illustrating using RunProcess to launch a GO http server. Has anyone, or does anyone ...
2
votes
0answers
121 views

How to efficiently find parts of a string with beginning and ending specified?

I'm trying to find specific URL addresses from a html document. The addresses can be found between the strings "href=\"" and "\" class=\"listing". The problem is not including strings like this: "href=...
2
votes
0answers
216 views

How can I do multiple (double) integral with periodic boundary conditions?

I am trying to do a simple double integral $\int_0^l \left[\int_0^l h^3 h_{xxx}dx\right]dx$ with periodic boundary conditions $h[0,\tau]=h[l,\tau]$ $h_x[0,\tau]=h_x[l,\tau]$ $h_{xx}[0,\tau]=h_{...
2
votes
0answers
563 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 ...