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.

1,348 questions
Filter by
Sorted by
Tagged with
75 views

Programming for a loop and plotting

I am not so familiar with Mathematica programming. Here is my problem. I have defined the parameters in the first step: $G = 0.6, \Gamma = 0.5, r_1 = 1, r_2 = 1, \theta_1 = \pi/4, \theta_2 = \pi/4$,...
126 views

How to define custom differential operator using the arguments of the expression?

This is essentially a follow-up to the question/answer here: How to define a differential operator? Suppose I wish to define an operator DiffOp, e.g., ...
94 views

Declaring global variable in module/ Looping in mathematica [closed]

I'm new and still learning about mathematica. I'm having some trouble with my code. This is my current code that i'm having trouble with: ...
1k views

Could Mathematica solve a differential equation asymptotically?

Is there any possibility that Mathematica could give asymptotic behavior(s) of a differential equation as it independent variable tends to a certain value? Because I didn't know how to decompose this ...
42 views

Symbols in Mathematica (#, & etc) [duplicate]

I am constantly finding a lot of examples of usage of symbols # & etc in the code. But I could not find any information what they actually mean and how to ...
97 views

I want to improve my algorithm of knowing eigenvalues of the matrix H(k)

I want to improve my algorithm. I want to know the eigenvalues of below n-dimensional matrix H. When n=10, the matrix H is like below. Now, $To$ and $M$ are constants and $T1$ and $T2$ are functions ...
727 views

Recursion - Concentric Circles

I'm trying to develop my Wolfram programming skills and set myself an exercise of creating concentric circles using a recursive delayed function: ...
146 views

Use NestList instead of Do loop

I am learning Gibbs sampling and imitating this explanation. Can we use NestList,FoldList or any other iterative function ...
425 views

How can I create an enumeration variable by groups?

I copied the title and concept for this question from here. I have ...
46 views

How to find NextScheduledTaskTime of a scheduled task?

Prior to 11.2 there was a function NextScheduledTaskTime which does what it says on the packet but only for cloud objects and not local scheduled task objects. ...
76 views

Emulating a Scientific Workplace toollbar? [duplicate]

It is possible to have a notebook with the tools of the Basic Math Assistant palette in a toolbar similar to Formatting tool bar it already has? I would like it to work so when I open another notebook ...
262 views

Looking for an effective way of generating integer sequences

I am looking for an effective way of generating all sequences of length $m$ of integer numbers $\{n_1,n_2\dots n_m\}$ such that 1) $0\le n_i\le N$; 2) $n_{i+1}\ge n_i$ for odd $i$; $n_{i+1}\le n_i$ ...
126 views

Testing Head inside a Module [closed]

I hava a Module in which a want to give a single String or a List as a parameter and I want to change a single String to a List containing this String. So I did the ...
146 views

Batch processing of data files

I have a large set of data files containing x-y coordinates. I have written a notebook to extract angles and other relevant lengths from a single data file before exporting the results into a new ...
97 views

Traveling Salesman Problem

Could anybody help me to convert to Mathematica 11.0? ...
340 views

How can I get the unique solution?

The eight queens puzzle has 92 distinct solutions. If solutions that differ only by the symmetry operations of rotation and reflection of the board are counted as one, the puzzle has 12 solutions. My ...
99 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, ...
79 views

Why does AtomQ[y] define y? [duplicate]

Mathematica Version 11.2 desktop / Windows 10 Pro 64-bit ...
114 views

Generalization of the probability of union

hi How can I do for mathematics to expand this equation for any value of the variables i, j, k
201 views

Does anyone know how to speed it up? More efficient way to derive a new graph from a given one

Let us consider a graph1. ...
706 views

Simulation of diffusion in a grid

I want to simulate a diffusive process in a 2D grid, for a central initial value of 1 to the adjacent cells initially at 0. At each time step, the value of the +1 level adjacent cells are increased ...
697 views

Unexpected behaviors in built-in functions

Existence of this topic is discussed in this mathematica.meta post. I'm sure I am not the only non-beginner in WL who from time to time finds themselves not being able to predict an outcome of a ...
261 views

Possible states of a 1-out-of-3

I need to choose one or more cases of three, since $2^3=8$. How to make a program that is possible as shown in the table My attempts TableForm[Tuples[{p, q}, 3]] ...
1k views

Generate white noise in 2D

I am trying to generate a random (white noise) signal, as mentioned in the section Frequency Synthesis of Landscapes (and clouds) on this website. The problem I have is that I do not know if ...
44 views

Looping variables not replaced by their values

Sometimes Table[ ] leaves the looping variable in the output, instead of replacing it by the values. For example ...
544 views

Appending array in loop with If statement is not working [closed]

I want to print all non-zero answers to an array so I can then print them to a file. ...
354 views

How to convert from C to Mathematica?

I am trying to understand what is explained in this webpage, in the section entitled "Generating noise with different power spectra laws". After reading that section, I thought I could do it in ...
350 views

Is building an event-based parser possible/reasonable in Mathematica (WL)?

Too long? Go to Problems section Background I like to learn by doing small, sometimes artificial, projects. Among other things I had 'parsers', and 'stream methods / streams in MMA' on my to learn ...
72 views

How to express and solve this minimization problem in Mathematica?

Let $T>0$, $H>0$, $D$, and $No>0$ are known parameter. Let $\{p_1,p_2,\cdots, p_T\}$ are the optimization variables. Let $\{w_1,w_2,\cdots, w_T\}$ are known parameters. Now, I want to ...
54 views

Finding one function from NDSolve of two nonlinear PDE simultaneously!

I want to NDSolve two below partial equations : ...
109 views

220 views

Code for Factorial Function

Below I have my code that I created for finding the factorial of a number. The output I am getting when I enter MyFact is ...
471 views

I have ...
24 views

a question about cdf player embedable demonstration [duplicate]

I have now my first application to be exportable as a cdf. If I safeguard as a cdf it works. But if I embed it in an html page It proposes to download the cdf player which is already on my computer. ...
158 views

Extracting notebook history programmatically

I know there is a way to open Notebook history dialogbox using Cell > Notebook History, but since there can be a lot of history the dialog box can run very slowly with lags. Is there a way to get a ...
56 views

Some side problem in a manipulate notebook

Sorry for the length of the code but the question is only on the Manipulate part. Here are some functions to evaluate apportionment methods ...
601 views

3D tree in Mathematica?

Searching the web for information about the affine transformation, I found the one page, which called my attention for the tree that show and is this but unfortunately do not give information about ...
144 views

A nice way to fold a non constant recursive function

The following code works exactly as expected. It constructs the Balinski-Young apportionment method. It is composed of two parts 1) the construction of the Balyski-Young function ...
116 views

curious simplification problem

Consider the following expression: If[x==x, 1, 2] This returns 1, as you might guess. However: If[x<x, 1, 2] Returns ...
91 views

Partial floatification - is it possible?

Suppose, I have a system of equations like 2y[Pi] + 3 y[E] == Sqrt 3 y[Pi] + EulerGamma y[E] == Zeta Now, I want a numerical solution to this, but I don't ...
4k views

Principal submatrix and Principal minor of a matrix

A submatrix of a matrix is obtained by deleting any collection of rows and/or columns. For example, from the following 3-by-4 matrix, we can construct a 2-by-3 submatrix by removing row 3 and column ...