# Tagged Questions

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.

1answer
70 views

### Implicit region is not “valid” in ParamatricNDSolveValue function?

I am trying to solve a geometric problem with relation to my Schrodinger equation and its boundaries. Here is my code: ...
2answers
216 views

### How can I create a 3D representation of an object with known coordinates and adjacency table in mathematica?

Basically I want to create an object with specified coordinates and adjacency table, like in page two of this article. I'm completely new to using Mathematica, any help would be great! EDIT: So I ...
1answer
325 views

### How to download pictures from webpage automatically?

Today, I read a good web page about love which owns many beautiful pictures. It is fussy for me to download every picture hand-by-hand, so I'd like to use Mathematica to do this case automatically. I ...
0answers
87 views

### Retrieve rendered graphics via WSTP

I am planning on using Mathematica as calculation and rendering backend for an application, i.e., call Mathematica via WSTP and use EvaluatePacket to have it ...
3answers
143 views

### How to extract both first and last rows of each group from unbalanced panel data

This is a follow up question form my last question click here. I have unbalanced panel data such as : ...
1answer
228 views

### How can I overload a function with multiple bracket-slots so f[a][b] and f[a] can coexist?

Maybe this is not even possible: I want to create a function f that can have two input brackets like: f[a_][b_:1]:= a*b and ...
1answer
217 views

### How can a function know in which function it was evaluated?

Hello my second question here might be very hard. I am asking for something "magical", if i define a function g and i call it inside a function f, how can g have information about the outer function ...
2answers
94 views

### Need help updating an old Mathematica worksheet

I found a notebook that symbolically applies the multiple time scales method to any differential equations. I don't like just using other people's code so I am going through the author's work line by ...
2answers
496 views

### Find permutations with constraints without using Permutations

EDIT: To clarify, the bottleneck right now is available RAM, so any answer should keep that in mind (I cannot store all T! lists of length ...
0answers
63 views

### Trying to write a program to find an approximate harmonic function on a given graph using relation method

So given an undirected graph with two vertices that have fixed values assigned to them, a harmonic function is a function that assigns values to all other vertices such that the value assigned to each ...
1answer
97 views

### How to improve this function that selects parameters from arbitrary distribution using Recursion?

Below, I have defined a function using Which to select model parameters based upon various conditions. My questions are: Is there any danger in writing this function using Recursion? Is there a more ...
1answer
139 views

### Perceptron: Do loop not returning a value

I am trying to write a function that finds a simple best fit line for some data (Perceptron algorithm). Sadly it returns no output at all. Here's the code below: ...
2answers
186 views

### How to plot points with error circles on map with latitude/longitude grid

I am currently working on a project to model the location of icebergs in the northwest atlantic. When an iceberg is sighted, an error circle is plotted around it (with a bivariate normal probability ...
1answer
145 views

### Using mathlink/WSTP with fortran

I would like to access Mathematica functions from within a Fortran program. I am unsure how to start (which is probably related to my lack of up-to-date Fortran knowledge). Is it necessary to write a ...
1answer
94 views

### Hypothesis Testing and Formatting Output

I am trying to write a function that tests hypotheses and gives me a nice table but I can't. I need forum's help. For example, I have the following data ...
1answer
232 views

### How to construct custom operators with precedence?

I need to combine data structures in operations analogous to addition, subtraction, multiplication and division (and more). I need more than one operation of each type, i.e. more than one method of ...
1answer
541 views

### How can I invoke the solution of NDSolve to determine a parameter in my equation just inside NDSlove?

I am trying to solve a differential equation by NDSlove for $h(x,t)$. It reads $$h_t=h_{xx}-V_h-\lambda(t)$$ where $V_h$ is a given function of $h(x,t)$ denoted by <...
1answer
78 views

### Ways to protect certain parts of expressions

I am currently working on a quantum mechanics problem where I try to find equations that relate different states of a many-body system. The states are described by sets of pairs of integers, like <...
0answers
25 views

### Iterating a model with 2nd order difference equations using Manipulate [duplicate]

I have a model including first and second order difference equations. It works for the case of first difference equation, which is below: ...
2answers
169 views

### Nested mapping of a function

If I use the construct f[#] & /@ f[#] & /@ f[#] & /@ {a, b, c} my function works, but if I use ...
2answers
146 views

### Finding column-wise ranks of values in a multidimensional list

I often have to find ranks of values in a list. However, Mathematica does not have built-in functions for that, or may be I'm just not aware of them. I can easily find ranks of a row/column vector. ...
1answer
44 views

### Why does this cause an error? [closed]

In[73]:= f[x_] := Save["C:\\Users\\user\\Desktop\\file", x <> x] f["###"] During evaluation of In[73]:= Save::sym: Argument ###:f3b5.01<>.01:f3b5###:...
3answers
436 views

### Easiest way to create a binary variable

Binary variable is often used in applied statistics. However, I had a hard time to figure out how to create it. Somebody might have better idea how to do it. I have two variables say x and y as ...
0answers
128 views

### Simulations using alternative initial conditions

With help from some of you guys here in this forum, I have developed the following code, which works perfectly. My questions are: how to automate the simulations with varying initial conditions. In ...
1answer
144 views

### Using FindMinimum with matrix input

I define the following function which spits out a number S when I feed it a dxd square matrix: ...
0answers
103 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=...
1answer
117 views

### converting DO loop into NestList form

I would like to rewrite this Do loop using NestList. Can you help me? ** DO loop ...
1answer
114 views

### Modifying Game of Life code so that the lattice can be seeded with life forms

I want to modify Game of Life code so that the lattice can be seeded with one or two new life forms like: ...
1answer
193 views

### Copy Built-in function to new name

It is know that some built-in functions are system function and changing their properties may cause trouble. Suppose for example I want to change features of Cases: ...
0answers
119 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_{...
1answer
238 views

### NDSolve with initial condition: initial conditions did not evaluate to an array of numbers of depth 1(for 1D) or 2 (for 2D) on spatial grid

I have the following naive code to solve a PDE in two spatial dimensions (x,y) with periodic boundary conditions: ...
1answer
182 views

### ControlType -> None Vs. Module inside Manipulate (i.e. making everything local)

I'm building a program on another one made available in the Wolfram Demonstration Project. I've noticed that in the original code (working flawlessly) many variables were made local inside the ...
6answers
409 views

### For a given expression: if it appears, remove it, but if it is absent, add it

While reformatting Szabolcs's code from (42660) I noticed this interesting operation: ...
1answer
78 views

### Are there methods to serialize and deserialize large calculation runs? [closed]

I have a fairly large calculation to map an electric field over large areas (square kilometers). This runs for a fairly long time. Are there ways to serialize the current state of a running ...
1answer
38 views

### New output cell generated for each run of a GraphicsGrid - is there a way to simply update the same output cell each run?

I have a Code cell that generates a set of plots in a GraphicsGrid[]. Each time I execute the Code cell, a new Output cell is generated. Is there a way to simply update a single output cell instead ...
0answers
135 views

### Code turns dark blue after trying to run it [closed]

I have a large amount of data in my N-Body Code. I imagine Mathematica doesn't really like this, but is there any other reason for my code turning a navy blue colour after I try to run it?
0answers
80 views

### Define column types in a Dataset - Failure on append and Typesystem

I have a basic function that populates a Dataset according to user specified parameters. ...
1answer
269 views

### How would I obtain a list of column names in a Dataset?

I really love the addition of Dataset to Mathematica. I would like to write a basic utility function that exports a Dataset to Excel. Is there a way to get a list of column names from a Dataset?
2answers
488 views

### How would I programmatically add a row to a Dataset?

I would like to use a Dataset to track the process of a lengthy calculation over a large volume of material. Dataset appeals to me because of the power of the queries and it also looks like it may ...
0answers
12 views

### all does not work [duplicate]

Thanks blochwave for giving me a detailed answer, but I have already used all these methods and none of them has worked well, it is clearly written in mathematica "get help" file that the Timing[] and ...
1answer
162 views

### How to speed up my code about Divisors?

This code is about PE496 In[21]:= ParallelSum[n*Count[Divisors[n^2], a_ /; n < a < 2 n], {n, 1, 10^5}] // AbsoluteTiming Out[21]= {5.987342,10724527832} I ...
1answer
192 views

### Finding CPU time of more than one expressions

I want to find the computational time (CPU time) of my code. When I use TimeUsed or Timing commands they give the CPU time of ...
1answer
101 views

### InterpolatingFunction used to work with mathematic 7 but not working with mathematica 10

This code is used to work perfectly with Mathematica 7 and now it is not working with Mathematica 10. Any help is appreciated. CL05 = InterpolatingFunction[{{0.5, 11.99999999999999}}, {1, ...
4answers
368 views

### Interactively inspecting parts of an object

There have been times when I want to find the structure of an object in order to extract some part of it. For example, extracting the x and y coordinates from a Graphics object generated by Plot. I ...
1answer
88 views

### How can I use manipulate on multiple lists within a function?

So I have my N-Body Problem set up like so, and I can plot it in ListPointPlot3D, but I cannot figure out how to stick this into a manipulate function. ...
2answers
467 views

### How to get short definition of all built in Mathematica Functions?

The first post in "Mathematica Weekly Newsletter - Tuesday, December 30, 2014" really attracted my attention as I was always looking for a complete list of built in Mathematica functions with short ...
3answers
509 views

### Collatz optimization

I'm VERY new to Mathematica programming (and by new I mean two days), and was solving Project Euler question 12, which states: Which starting number, under one million, produces the longest [...
1answer
289 views

### A problem about Steffensen method

Two days ago,I asked a question about bisection algorithm. Thanks for Michael E2 giving me a good solution My algorithm 1, I use the bisection algorithm to generate a initial value that contain a ...
3answers
1k views

### Implement the Bisection algorithm elegantly and easily

Description: Rencently, I have finished my course Numerical Analysis, so I'd like to implement many algorithm that I have learned from that course.By this practice, I hope that I can improve my ...
1answer
68 views

### Data file organized in strings

I am working in a data set : The original question, They are strings of thousands stars,and each one contains a lot of parameters, and the following item is called identifies, they are the names (...