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

0
votes
0answers
7 views

Lychrel number Algorithm [migrated]

Recently became fascinated with the search for Lychrel and palindromic numbers as recreational mathematics. for the who are unaware, the process for performing this check on a number manually is as ...
9
votes
2answers
130 views

How to generate a closed B-spline curve?

I wrote a function called deBoor by the Cox-De Boor algorithm to generate a B-spline curve. ...
0
votes
0answers
34 views
4
votes
1answer
116 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 ...
5
votes
0answers
45 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
98 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
72 views
4
votes
1answer
41 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
32 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
39 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 ...
17
votes
3answers
485 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
73 views
11
votes
3answers
203 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) & & ...
16
votes
2answers
264 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
124 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
88 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
170 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
90 views

Dynamic programming: Fibonacci generator

I have the following piece of code: ...
1
vote
1answer
61 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 ...
1
vote
1answer
73 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
163 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
77 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
94 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
100 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: ...
2
votes
0answers
65 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 ...
3
votes
2answers
77 views

How to define UpValues about the derivative of NBSpline when the length of knots is unknown?

Description In the book “Programming in Mathematica” 3rd by Roman.E.Maeder, the author gives a topic about A new Mathematical Function in section 8.4. For instance, for the following formula: ...
4
votes
1answer
55 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
241 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 ...
4
votes
1answer
100 views

A pre-parsed HoldForm

HoldForm holds an expression's parsed form not its actual "inputted form" e.g. ...
5
votes
2answers
211 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 ...
3
votes
1answer
134 views

How can you get the area of a region from an image?

Suppose we have a square of side "L" m, How can I calculate the hatched area, if the corners of the square are centers of circles. It can be generalized to any region? edit: This is the result I ...
12
votes
1answer
211 views

How to add AccuracyGoal and PrecisionGoal options in a numerical function?

There are many built-in functions that contain AccuracyGoal, PrecisionGoal and ...
-2
votes
1answer
166 views

How to get the coordinates of points within an image?

How can I get the coordinates of an image, and make Mathematica draw the image from the coordinates found? I am interested in just the outlines of the regions. Here is an example of the kinds of ...
7
votes
1answer
103 views

How to select a submatrix containing similar elements from a matrix? [closed]

( This question is related but does not ( fully ) answer my questions. - Finding the position of similar elements in a matrix ) I have not written code yet, I am in the design phase of code for the ...
10
votes
1answer
93 views

Can Query operators be naturally cast as either Ascending or Descending?

One of the challenges of coming to grips with Query's on Association's and Datasets is ...
0
votes
0answers
38 views

Programming of basin of attraction for with memory iterative methods

I have made the programming for without memory method and i got the basin of attraction but i could not make it for with memory iterative method. I am sending you the programming of with memory ...
0
votes
1answer
48 views

Write a function pollard[n, B] that tries to factor an integer n, using Pollard's p − 1 method with at most B iterations [closed]

This is what I got but it seems it's not working. When I test it, it just goes through and nothing gets returned. Is there something I'm missing? ...
6
votes
1answer
121 views

Is there a practical way to define a default value for missing keys in an Association?

It can be very useful to define background or default value for an object that can be incremented or otherwise modified. A simple (and for me, common) use is a counter: ...
2
votes
1answer
85 views

Implicit derivatives in one line. How do I do it?

I have this little script to derive implicitly $PrePrint = # /. {D[y_, x_, NonConstants -> {y_}] :> y'[x]} &; Example: ...
0
votes
1answer
74 views
3
votes
1answer
103 views

Using function to transform a list

I have a list like that: {{Integer,String},....}, integer ranges from 1 to 900 and String "I" to "IV". And I need to find which pair of {x,y} each sublist is related to, so i can get a new list like ...
1
vote
2answers
83 views

Ask about the variable and constants in partial derivative in a loop

EDITED I have a function in a list like : func={2(x^2)+x*y+3(y^2)}; I want to have a UI that ask me which parameter (x or y) is a variable in a ...
2
votes
2answers
69 views

Sum broken into two sub-sums according to a condition on the terms

I have a sum in mind, but I want to break it into two sums and get a separate total for each of the two. All cases where the square root is accurate, i.e., exact All cases where the square root is ...
4
votes
3answers
134 views

How to get multiplication of the elements of a specific list/Matrix

Assume there is a list: List1={a,b,c,d}; Then I want to get these calculation: ...
5
votes
1answer
139 views

How to check the option value?

Given that I have a function func as follow: To check the value of options, I using the step-by-step method If[] ...
4
votes
1answer
65 views

How to define an expression which is differently evaluated in calculations and printed

Let's say, we have a list: values = {1.2, 0.04, 0.9}; Is it possible to replace 0.04 by some expression, which displays as ...
9
votes
1answer
107 views

How to implement a custom random process object?

I want to implement a custom random process thing1 to pass to RandomFunction. The process I have in mind is conceptually extremely simple: two alternating Poisson ...
1
vote
0answers
78 views

Should I Remove the initial symbols of Module?

Often we use Module to construct complicate function. Consider that Module create new vars every time we run the function, should I remove the initial values at the end of Module-function?Or should I ...
0
votes
0answers
81 views

Fun/Frustration With Coding Coding Theory

I have code following from this post: http://math.stackexchange.com/questions/1317722/fun-frustration-with-coding-coding-theory I think I am done with the code, but now I face a single problem. The ...
2
votes
1answer
154 views

How to determine whether an expression can act as a “good” function?

It's not easy to see whether an expression can act as a "good" function. A good function refers to an operater that transforms symbolic entities like 1+x^2 or ...