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.

Filter by
Sorted by
Tagged with
10
votes
3answers
2k views

Web scraping and multi-threading in Mathematica

I'm working in some web scraping using Mathematica, and today, to speed-up the process, I used bash commands (xargs with parallel options with curl and wget) using ...
0
votes
0answers
58 views

My notebook backup function works fine. I am just asking for your critical review before submitting to FunctionRepository

Why the name and what does it do exactly? Youre probably asking yourselves why I named it NotebookBackupStack. All that is explained in ...
0
votes
0answers
30 views

how to delete a variable programmatically in a notebook from another notebook

how to delete a variable programmatically in a notebook from another notebook? c = b; I have already tried Remove[c] but ...
511
votes
37answers
117k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
11
votes
1answer
1k views

Communication between parallel kernels

Greetings. This is my first post here, also, I am not a seasoned programmer, so any advice pertaining to coding that is not directly related to the problem (stated below) is welcome. I am having ...
2
votes
2answers
74 views

Could anyone please help with defining a vector function of tons of variables?

Could anyone please help with effectively defining a vector-valued function of tons of variables so that ...
10
votes
2answers
451 views

What is the most efficient way to define a Loop until function?

Mathematica has the While function which is very convenient when we need to process some code until the attainment of a certain state (identified with a condition). ...
8
votes
7answers
519 views

Remove element from list and store it in variable?

In many programming languages there are functions that remove an element from a set while giving back that element. E.g. I'd like to have a function FetchFromStack ...
3
votes
1answer
134 views

Extracting values from a Bézier curve in Mathematica

given a list of points I've created a Bézier curve, and now I would like to understand how to extract a "middle point" from a curve or get a list of points (not the input ones, the ...
1
vote
1answer
96 views

How to convert this Mathematica expression to another, as described here?

I am working on a function of which the core will consist of something like: ...
1
vote
2answers
107 views

TogglerBar linked to Buttons that override input list

This question is about extending the solution provided here. How do I allow the user to change x outside the TogglerGrid function so that the TogglerBar shows the new values of x? I've set it up ...
23
votes
1answer
1k views

What are some approaches to measuring code coverage?

I understand that Mathematica can have some peculiarities in this area, but just in case... I'm talking about things like measuring coverage of MUnit tests to get an idea of code quality.
5
votes
1answer
70 views

How can I separate expressions in Module without suppressing output?

I want to show a progress indicator while statements in a Module are processed. Outside a Module this ca be done like this: ...
24
votes
5answers
2k views

How to implement dual numbers in Mathematica?

I wonder how can I implement dual numbers in Mathematica, so that all functions work well with them (as with complex numbers). Particularly, for each function $f$, $f(\varepsilon)=f^\prime(0)\...
8
votes
3answers
275 views

How to implement split-complex numbers?

For those who do not know, the split-complex numbers are an analogue to the complex numbers where J is defined such that $J^2=1$ but $J\ne\pm1$, so they are all of the form $a+bJ$. By using ...
3
votes
2answers
86 views

Implementing Dual Unit from Dual Numbers

I'm trying to implement the dual unit $\epsilon$ defined by $\epsilon^2 = 0$ into Mathematica but I'm having trouble defining $\epsilon^n = 0$ for $n\geq 2$. In this answer they simply use ...
8
votes
0answers
54 views

Does ArgumentsOptions do anything we couldn't do without it?

ArgumentsOptions was new in version 12.2. I looked at the application on that page, and it makes code very difficult to understand. What if anything does ArgumentsOptions do for us that we couldn't do ...
0
votes
1answer
43 views

Program works, but then fails when I write it inside Module [duplicate]

I'm new to Wolfram Language; I'm trying to get used to it by writing a bunch of code and programs, being one of them the algorithm for the bisection method. When I write the algorithm outside of a ...
2
votes
1answer
75 views

In NMinimize, how to incorporate constraints on positive semidefiniteness of a matrix which is not the matrix variable being optimised?

The problem I want to solve the following problem for symmetric matrix $X$: $$ \begin{aligned} \min_{X\succ 0} \; & -\log(\det(X)) & \\ \text{subject to} \; & \begin{pmatrix} X &...
9
votes
3answers
273 views

How to programmatically change CellStyle of all Cells from "Input" to "Code"?

I have a special notebook styled for only creating functions and their packages. I often lazily do Evaluate Notebook instead of finding and opening all cells I need ...
5
votes
2answers
210 views

Modified Heat Transfer in Fluid Flow

I am trying to simulate Modified Heat Transfer in Fluid Flow (based on Buoyancy-Driven Flow in a Square Cavity ). The modified heat transfer takes the form: with the solid volume fraction: The ...
14
votes
5answers
1k views

How to ensure that Polygon[list] plots a simple polygon?

Consider the following code which plots a triangle. p = {{0, 0}, {.2, 0}, {0, .2}}; {Cyan, Polygon[Dynamic[p]]} // Graphics Then adding (for example) ...
3
votes
1answer
110 views

Is it possible to improve a code related with iterative closest point (ICP) algorithm?

I am trying to write a code related with ICP algorithm. The purpose of the code is matching a target data with a reference data by translational operation in XYZ axes (3-degree-of-freedom (DOF) ...
3
votes
2answers
163 views

Numerical solution of the 2D-spatial nonlinear Allen equation

I would like to solve the 2D-spatial Allen equation in rectangular coordinate, which is a nonlinear reaction-diffusion PDE of the type $$\partial_{t}u=\epsilon(\partial_{xx}+\partial_{yy})u + u - u^{3}...
0
votes
1answer
81 views

How to use AppendTo in do loop?

list = {1, E, (3/2)*E^2 + (3/8), (5/2) E^3 + (25/8)}; AppendTo[list, 2*E*list[[{x - 1}]] + (2*x - 3) (2*x - 4) (2*x - 5) (1/4)*list[[{x - 2}]]] Let x from 5 to 10, ...
0
votes
2answers
137 views

How to read value from a plot

Let's say I have plot. What is the command for getting the specific value at a point that I choose? Exampe: Plot like --I-. command(1) = 0 command(2) = 0, command(3)=1, command(4)=0
0
votes
0answers
52 views

Block Behavior, but for Function Assignment instead of Variable Assignment

We can define a function using a variable b that does not appear as an argument, and then using Block, change the output of the ...
1
vote
1answer
55 views

generate quadratic functions to evaluate membership of points

How can I make a printable list with different quadratic functions and with points that belong or not to them so that a young person can check whether or not the point belongs to the parabola? my code ...
62
votes
4answers
5k views

How do I evaluate only one step of an expression?

I am looking for a simple, robust way to evaluate an expression only one step, and return the result in a held form. The definition of a single step is ambiguous, and this itself is probably worthy ...
0
votes
1answer
59 views

The list of coefficients of the "polynomial", which has the order of derivatives instead of degrees

I have some equation eqn = (A + B).x''[t] + Transpose[x'[t]].(2 A - 3 B + 1).x'[t] +(СС - 5).y'[t]+ Sin[x[t]+y[t]] I need to collect all the coefficients at ...
5
votes
3answers
161 views

What is the underlying interpolation in "BrightBands"/"DarkBands" color scheme?

Using the bookmarked conversation mentioned in this answer, I was able to extract the colors (and their parametric positions) of the Mathematica color scheme ...
5
votes
3answers
104 views

Plot the lines (nodes) for the given value from NDsolve output

I want to plot lines for a specific single value from the output in Nsolve (we need to find these nodes from the output ufun, then plot them). ...
-1
votes
1answer
262 views

Keywords for the Wolfram Language [closed]

For a programming language, certain keywords are reserved; i.e., these tokens can't be used in any other context while programming in that particular language. Here is a list of C language keywords ...
1
vote
1answer
65 views

Appropriate syntax for constructing frequency table and histogram from experiment with three or more dice?

if I say to input 3, how do I get MMA to make me a table with all the cases on the left, in the center their frequency and on the right a histogram,bar chart, or some other way to represent the above. ...
0
votes
1answer
63 views

LocatorPane - restrict to circle

I have cobbled together a solution that does exactly what I need, but I don't fully understand how it works: ...
2
votes
0answers
63 views

family photo album,how to optimize its realization?

I am Beezy, the eldest daughter of the couple. I have a lot of photos on paper and I want to make a photo album for my parents, but the task is titanic. First I use a scanner, to scan the photos that ...
1
vote
0answers
58 views

Storing python output to variables in Wolfram

Would like to use the external language input in python to save variables I can potentially use in Mathematica. Any chance there is a way to do this? I do understand there might be a solution with ...
0
votes
0answers
57 views

Importing n different pdf files and sending them to n different emails

How with MMA could I do to load from a folder called "jobs" "n" different pdf files and send them to "n" different "gmail" emails stored in a mails.txt file in ...
10
votes
4answers
366 views
0
votes
1answer
207 views

I have just begun to use mathematica and was hoping someone could help me understand these error codes

" I have an assignment where I am required to use bisection or false position method depending on various inputs and I think I have a reasonable code that should work but I am not sure why I keep ...
0
votes
0answers
67 views

Label/GoTo and Compound Expressions

My Mathematica notebooks are often many pages long and, for clarity, I generally write only one expression on any line. In operation, such notebooks need to jump around within the full length of their ...
0
votes
1answer
112 views

Classify across ten methods

Mathematica supports ten different methods for Classify. The ten methods are: "ClassDistributions", "DecisionTree", "GradientBoostedTrees", "LogisticRegression&...
0
votes
0answers
35 views

How to save previous calculation

I want to calculate the longest chain up on million applying repetily the Collatz function until it reach one. I was able to solve this using the following code: This is the definition of the ...
23
votes
6answers
4k views

Creating the Yin Yang symbol with minimal code

The following code creates the Yin Yang symbol ...
37
votes
2answers
4k views

Debugging memory leaks

I've written my incredibly complex, incredibly elegant analysis function, that works great on small test data. But when I run it on my real (bigger) data set it keeps running out of memory. It turns ...
15
votes
3answers
708 views

Use OptionValue to deal with nested options

OptionValue allows for recent versions of Mathematica (I think as from 7) to easily access optional parameters if they are explicitely given to a function or their default values otherwise. For big ...
82
votes
4answers
3k views

The clearest way to represent Mathematica's evaluation sequence

WReach has presented here a nice way to represent the Mathematica's evaluation sequence using OpenerView. It is much more clear way to go than using the standard <...
-1
votes
1answer
48 views

Dirichlet theorem [closed]

I'm programming Dirichlet theorem - here(p mod d=a, p is a prime number) via procedural programming and I don't have any idea, how to start. I would like to have function, which gets three numbers (a,...
15
votes
1answer
287 views

Programming language prototyping in Mathematica

Are you aware of any projects using the Wolfram language resp. Mathematica as an environment to explore the design of programming languages - in particular languages with a focus on mathematics (...

1
2 3 4 5
30