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
1answer
132 views

Holding Input Windows

I am creating a Mathematica document which contains a list of proofs in various fields of Mathematics so that I can easily review whenever I would like. First, I create a large set I call 'proofs' ...
0
votes
1answer
225 views

How to combine two usages of # into one and speed up the code?

I have a function num with two variables, matf and matg. How can I combine the last two lines of code below into one? The code is aimed to find out the maxiaml count bel when we give each $i3 = ...
0
votes
1answer
192 views

Pattern match with Table for matrix dimension check

In Mathematica, often an expression involving matrices will encounter dimension mismatch errors, like we are multiplying a 3x2 matrix to a 3x4 matrix. Below we define a new symbol Dim, which can be ...
0
votes
1answer
231 views

Why does memory run out when adding same-sized matrices in a loop?

I have written a module that it generates a 101x101x51 zero matrix at first. At every iteration, it generates a list by funct1 and based on this list, if list is empty it gives the previous result. ...
0
votes
1answer
57 views

How to count column occurrences in a matrix?

I have a matrix of data, and I want to count the number of columns that match, and have some way to organize them by frequency. But I don't want to count the entire column, but consider the matrix ...
0
votes
1answer
65 views

How to properly use conditionals inside NDSolve

Currently I am working with Mathematica to learn the program, and I'm confused what exactly is wrong with this code. ...
0
votes
1answer
86 views

Eigen energies of 2D time independent Schrödinger equation

Firstly, I am aware that a similar question of this type was asked, but it was not helpful as it was only one dimensional (so please don't mark my question as a duplicate) The trouble I am having is ...
0
votes
1answer
32 views

How to combine two or more groups while selecting form the unbalanced panel data if the number of obs is less than a scalar in certain groups

I have an unbalanced panel data. I want to calculate group statistics for each group. However, if ith group has less than K obs, then I want to combine ith and (i+1)th groups to calculate group ...
0
votes
1answer
86 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 ...
0
votes
1answer
41 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 ...
0
votes
1answer
89 views

converting DO loop into NestList form

I would like to rewrite this Do loop using NestList. Can you help me? ** DO loop ...
0
votes
1answer
33 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 ...
0
votes
1answer
67 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 ...
0
votes
2answers
160 views

Exctrating data information from a file.txt

I really did previous long search in the site and I couldn't find any answer that might help me. So I am asking it. I have the following data set, ...
0
votes
1answer
63 views

How can I assign a vector unknown function to solve the ODE system?

I noted that using non-scalar variables is convenient when a system of differential equations is governed by a process that may be difficult to express symbolically. Taking a example from the tutorial ...
0
votes
1answer
53 views

Programming a series involving alternative log expressions

This is likely my error but I cannot see it. I define a vector: x1 = {{{2, 2}}, {{2, 1}, {3, 1}}, {{3, 2}}, {{2, 1}, {5, 1}}} If x1[[ i, 1,2]] is 2, I would like to find $(\log$ x1[[ i,1,1]]$^2$). ...
0
votes
1answer
147 views

Turning a 2D 3 body problem into 3D not so easy?

I have programmed a 3 body problem, that can in theory work for more than 3 bodies. I apologize in advance for the length of the code that I posted, I don't really know how much one would need to ...
0
votes
1answer
120 views

Need help in understanding code [closed]

I am just beginning with Mathematica. I have received this code to study. I am not able to follow this particular section. I have tried looking it up on many forums, with no answer. Can you help? ...
0
votes
1answer
135 views

Using a LocatorPane

I have a network of a power grid where the edge are the power lines and the vertices are loads or generators. I was wondering how I can import an image into Mathematica to derive some sort of ...
0
votes
1answer
90 views

How to produce functions [closed]

I want to produce n functions. For example, assume that by giving n=3, 3 definite integrals will be created, like the following: ...
0
votes
1answer
322 views

Mathematica Implementation of Householder’s Method

I typed the Householder code in this paper, which starts on page 7. The code is: ...
0
votes
1answer
435 views

Heat Transfer equation by numerical methods

I want to solve the following heat conduction equation using numerical methods: D[u[x, t], t] -alpha*D[u[x, t], {x, 2}] == 0 u[x, 0] == 1/(1 + x^2)^0.25, u[-10, t] == u[10, t] == 0, ...
0
votes
1answer
972 views

Evaluate function of two variables using nested Do loops

Is there a more efficient way of evaluating a function of two variables on a rectangular grid the the following nested Do loops? ...
0
votes
1answer
274 views

A problem on generating convex hull

For example, I typed the following: ...
0
votes
1answer
109 views

Collecting roots of different equations and create a list

I solve two equations and have two solutions one by each equation. I want to create list of these roots. Could anyone please help me? Appreciate it. m02R150 = FindRoot[P1 == 0, {E1, 0.07, 0.1}] ...
0
votes
2answers
146 views

How to obtain a smaller-sized output from Solve

I am solving a system of 15 simultaneous linear equations using Solve. On running the code, I get a message saying "A very large output was generated" with options ...
0
votes
1answer
311 views

Problem with Eventlocator Method for NDSolve

I want to solve the ode and plot the solution v[x] for different values of parameter a where ...
0
votes
1answer
415 views

How to solve a problem in relative motion?

I have a project due tomorrow that I have been struggling with for a month. I am utterly stumped, any help would be appreciated. The problem is: There is a ferris wheel, 30m in radius, set 80m ...
0
votes
1answer
18 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

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? ...
0
votes
0answers
56 views

How to spend any image in “2D” or “3D” to an image mesh, ie as a wire frame in black and white?

How to spend any image in "2D" or "3D" to an image mesh, ie as a wire frame in black and white? For example some of these: edit :example output
0
votes
0answers
75 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 ...
0
votes
0answers
50 views

Calling a custom function in slave kernel process connected through mathlink

I am performing a small experiment to check if we can call/execute a custom package function in slave kernel launched from master using mathLink. I have created a dummy application called ...
0
votes
0answers
38 views

Evaluate notebook using text-based interface

I am trying to evaluate a notebook using a text based interface so that it can be submitted to a computing cluster. I have seen this stackexchange page and attempted to use ...
0
votes
0answers
33 views

Debug package with command line arguments

I'm creating a package that takes as arguments input from the command line using $ScriptCommandLine. What's unclear to me is how to best debug this package. How do others perform these tasks? I ...
0
votes
0answers
33 views

$MessageList inside and outside Block[]

Why does 1/0 $MessageList return ComplexInfinity whereas ...
0
votes
0answers
38 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 by using EvaluatePacket have it ...
0
votes
0answers
48 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 ...
0
votes
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: ...
0
votes
0answers
70 views

Stringing functions together

My professor introduced Mathematica to my class for the first time this week and gave us the following assignment. Also a disclosure that this is the first computer science class I have taken and the ...
0
votes
0answers
58 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: ...
0
votes
1answer
128 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: ...
0
votes
0answers
57 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. ...
0
votes
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 ...
0
votes
0answers
38 views

How to simultaneously change variables shared by several functions?

I designed a fit program, the framework follows: a matrix build function: Q[a_,b_,c_,d_]; several matrix manipulate functions shared the variables {a,b,c,d} like this: ...
0
votes
1answer
75 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. ...
0
votes
0answers
82 views

I cannot pass any script to `math`, in a command line

I want to run some lines of Mathematica code by a command-line call for math. As a test, I save just the following code in a file ...
0
votes
0answers
51 views

Question about treillis structures

I have difficulties finding a command to plot multiple segments connected in nodes in Mathematica. Ultimately, my goal is to modelise something like this by entering nodes coordinates. Also, the ...
0
votes
0answers
146 views

Solving for a Transfer Matrix

I am currently working on a program that will solve a transfer matrix and extract several elements. Particularly, the transfer matrix is characterized by four elements in a ...
0
votes
0answers
45 views

Find the maximum/ minimum of the function f(x,y,z) = x+2y+3z on the curve of intersection of the plane x-y+z = 1 and the cylinder x^2+y^2 = 1 [duplicate]

How to write the program for: Find the maximum/ minimum of the function f(x,y,z) = x+2y+3z on the curve of intersection of the plane ...
0
votes
0answers
74 views

Using Animate/ListPointPlot3D on more than one list

I have a couple orbits defined which have been mapped into one array as shown: ...