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

2
votes
1answer
85 views

How can I plot the normalized distribution of the Riemann zeta zeros?

Given a list of eigenvalues or a list of Riemann zeta zeros, how can I plot this famous plot found here: On the page referred to, You need to click on "Programs", "The Riemann zeta function" and ...
1
vote
1answer
200 views

What is the equivalent of FORTRAN 77 COMMON BLOCK in Mathematica?

I am in the process of converting a FORTRAN 77 program to Wolfram Language. I have several COMMON BLOCK statements in FORTRAN 77. My question is how to deal with them in Wolfram Language? My ...
0
votes
1answer
73 views

Formulate an equation to find a fixed point [closed]

I have the following equation: Subscript[x, n + 1] = Subscript[x, n]^2 + c with Subscript[x, 0] = 0. This equation is restricted ...
-7
votes
1answer
78 views

My program to model exterior ballistics doesn't doesn't produce the plot I expect

Here is my program to model exterior ballistics. It doesn't doesn't produce the plot I expect. How can I fix it? ...
2
votes
0answers
76 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}, ...
1
vote
1answer
35 views

ReplaceAll - Position of list arguments not displayed properly [closed]

This code A[1, 2, 4, 5] /. A[a___] -> Position[{a}, 4] return {} Why this code not return 3 (a position of number 4) ? I ...
0
votes
1answer
63 views

How do I get the last three vectors to complete this cube?

Looking at this file, what vectors do I need to add to the cube:={...} in order to get a full cube?
2
votes
0answers
72 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 ...
8
votes
2answers
144 views

Name rewriting for Function fails in closure

At its heart, Mathematica is a dynamically scoped language. While the choice of dynamic scope for Mathematica is very much a defensible one, lexical scope is too useful to do without, and Mathematica ...
0
votes
0answers
37 views

Could not access a specific element of ConstantArray, why ? partw error [duplicate]

I could not access a specific element of ConstantArray, why ? The following is piece of my code: ...
12
votes
1answer
115 views

How to remove a LocalSymbol (or CloudSymbol)?

In version 10.2 LocalSymbol can be used to create a persistent store of a variable. Once this is created I don't see a method to remove it. How are are they ...
0
votes
0answers
102 views

Best practices, tools, and snippets for manipulating notebooks, cells, packages, and help access? [duplicate]

Where is the best place to find/submit lists of Wolfram Language/Mathematica best practices, idioms, and patterns, perhaps grouped by topics? I'm personally interested in those that involve using ...
0
votes
0answers
39 views

system.dllnotfoundexception unable to load DLL“ .dll”: can not find corresponding module

There are two computers. One of them works correctly, whereas the second one writes an error system.dllnotfoundexception unable to load DLL" .dll": can not find corresponding module in ...
1
vote
1answer
186 views

How can we accommodate arbitrary Unicode characters in symbol names?

I understand why Mathematica doesn't the support the [ character in symbol names, but it should be escapable in some way, like non-printable characters are in ...
2
votes
1answer
75 views

ListPlot dynamical problems [closed]

I have Manipulate, where there are FileNameSetter(to load file with data points) ...
6
votes
4answers
305 views

Plot[f,{x, xmin, xmax}], where xmax is not a const

I have a graph of the function, as in the picture. Function can be set manually, but after a certain value, it is 0. Could I find this value to put it instead of xmax=1 in Plot in order to avoid ...
0
votes
1answer
122 views

Iterating FindRoot to solve a differential equation

I am new to Mathematica style programming, better at traditional programming. I would like to know if I can create a table of results using FindRoot, where the ...
2
votes
1answer
162 views

Translate C++ in Mathematica 10.0.2 [closed]

By translating the following program written in C ++ ...
7
votes
1answer
133 views

How would one return from a place of a pure function's body using Return?

From previous answers, replies and discussions it is known, while not formally documented (even in the most recent Wolfram Language Documentation Center), that Return can be used in a two-argument ...
1
vote
2answers
70 views

How would one set up a conditional to evaluate at the last output value (wondrous numbers) [duplicate]

I know this is pretty fundamental, but I'm trying to learn Mathematica on my own and this is stumping me. I know 5 is wondrous and it takes 5 steps to reach one, but I can't figure out the input to ...
5
votes
1answer
277 views

I change a single constant and the simple script suddenly takes forever to complete

I writed a code to display the Dragon Curve fractal, and I reached my goal. The algorithm works by taking the previous two points and then adding the following one by making a 90 degrees turn left or ...
15
votes
2answers
447 views

How to generate a closed B-spline curve?

I wrote a function called deBoor using the Cox-de Boor algorithm to generate a B-spline curve. ...
0
votes
0answers
49 views

Get Domain resp. implicit piecewise definition of numeric Function

Given the following quintic polynomial ...
4
votes
1answer
127 views

Can I code a conditional jump between cells in a notebook?

How can I code the Mathematica equivalent of the following pseudocode: if[condition] ... goto[label_1] ... else goto[label_2] where ...
6
votes
0answers
72 views

How can I wrap a C++ object in WSTP?

I am trying to wrap a sophisticated C/C++ API in Mathematica using WSTP, but can't work out how to return a pointer to a C/C++ data structure. This object was created on the C/C++ side of the wrapper, ...
2
votes
1answer
113 views

How to keep Mouseover visible while control has focus/cursor?

I have a DateObject and InputField that I am using to collect an inputted date. Mouseover ...
0
votes
1answer
78 views
4
votes
1answer
49 views

How to auto-run user-interface in Player Pro

I am about to start constructing a UI that will be run with Player Pro. I have created the following notebook and marked it cells as initialization cells. ...
0
votes
0answers
57 views

Extract frames as image files from video files [duplicate]

I have a set of video files where the frame rate is 1 frame/sec and the file shows the evolution of a particular object with time. Now, I want to extract each frame of the video and analyze as ...
1
vote
1answer
47 views

How to reference StringExpression named parts from a package without full Context path?

I have a long StringExpression in a package returned by a function. There are some named parts in the expression that I would like to reference when I use the ...
19
votes
3answers
880 views

How to find numerically all roots of a function in a given range?

It is common that I search numerically for all zeros (roots) of a function in a given range. I have written two simple minded functions that perform this task, and I know of similar functions on this ...
1
vote
1answer
90 views
12
votes
3answers
243 views

How to implement a more efficient inverse triangular recursion?

Consider the following inverse triangular formula $$\left( \begin{array}{ccccc} & & & & N_{i-p,p}\left(u_0\right) \\ & & N_{i-2,2}\left(u_0\right) & & ...
19
votes
2answers
482 views

Implementing the PCG random number generator

PCG ("permuted congruential generator") is a recently-introduced random number generator. PCG is a family of simple fast space-efficient statistically good algorithms for random number generation. ...
6
votes
1answer
154 views

How does thing[“property”] syntax work?

Many builtin "things" support the (usually undocumented) syntax thing["property"], and usually the available properties can be listed using thing["Properties"] (thing["Methods"] might work too). ...
2
votes
3answers
93 views

How to compare and remove x-coordinates (and the associated y-coordinates) that are less than previous x-coordinates?

I am using Mathematica version 9.0 and am trying to compare and remove x-coordinates, and the associated y-coordinate, that are less than previous x-coordinates. Below is an example using sample data. ...
5
votes
3answers
201 views

Turning an expression into a function inside another function

Say I have an expression g=Sin[q]; It is easy to turn it into a function, and to perform manipulations on this function (this and variants of this were discussed ...
0
votes
1answer
97 views

Dynamic programming: Fibonacci generator

I have the following piece of code: ...
1
vote
1answer
65 views

How to define a number of infix operators with predefined relative precedences

Reading a number of questions about infix operator notations I want to ask if somebody could reimplement the problem below in a simpler way, say modifying ...
2
votes
1answer
100 views

Program to demonstrate rotation according to quaternion values

On the Wolfram|Alpha website, I type quaternion(1,1,1,1) into the search field. Wolfram|Alpha shows a 3D transformation of the quaternion values representing the orientation of an object. I have 9 ...
1
vote
2answers
170 views

intermediate steps of a Mathematica operation

How to make a multiplication or division, the intermediate steps. The numbers can be rational - decimals? it seems the OP merely wants Mathematica to show him how to multiply and divide the way ...
2
votes
1answer
92 views

Clean & efficient bounding box non-intersection test

I would like a quick test to tell me that segments $ab$ and $cd$ cannot intersect in the plane. If the maximum $x$-coordinate of $a$ and $b$ is less than the minimum $x$-coordinate of $c$ and $d$, ...
5
votes
1answer
100 views

Efficient upsampling of multidimensional array

I would like to efficiently upsample a multidimensional array. It's a 5000*5 matrix where each element is a submatrix 12*12 and it is that 12*12 matrix I want upsampled (to 24*24). The upsampling ...
1
vote
2answers
109 views

How to write a loop

I try to create a table which will describe traffic paths at a crossroads. Instead of using copy-paste repeatedly, I would like to write a loop. For example: ...
3
votes
0answers
81 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
2answers
95 views

How to define UpValues of NBSpline when the length of argument is unknown?

I mimic the built-in BSplineBasis[] to build a user-defined function NBSpline[], Namely, ...
4
votes
1answer
81 views

How to add UpValues to a symbol to make a expression expanded normally?

Here is a implementaion of Bernstein basis function. I add the following UpValues to ...
10
votes
2answers
268 views

Checking the argument of user-defined function with side-effect method

Today, I answered a question of mine that asked two month ago. Please see here Now I would like to add the argument checking in this function. Then I used a method that Mr.Wizard answered ...
5
votes
2answers
131 views

A pre-parsed HoldForm

HoldForm holds an expression's parsed form not its actual "inputted form" e.g. ...
6
votes
2answers
246 views

How do I “evaluate in place” programmatically? Need to evaluate Defer[] result in non-interactive setting

I need to evaluate the result returned from an external package, which contains Defer in it, but do this in a script without user interaction. I am not able to ...