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
36 views

A way to force the code to use all cores [on hold]

I know that if Parallel commands are used , there will be a chance to use all cores. In spite of using Parallel items like ...
-1
votes
0answers
24 views

How would I go about implementing Expand and Factor on my own? [on hold]

These two functions seem to be the two (non-graphic and non-numerical) functions that I use on my own for which an efficient implementation is not obvious to me. I have tried googling around without ...
2
votes
0answers
31 views

What is “ (Dialog) Input [ ] := ” after evaluating a cell?

I have done a time-consuming run and calculation. After many hours ( about 7 hours!), the black color which shows that the cell is evaluating, turn into gray and a strange text appears like this : ...
1
vote
1answer
56 views

Scope of variables within a Manipulate expression [duplicate]

I have a problem in defining the local variables. I have this code: ...
19
votes
4answers
756 views

Detecting patterns of black and white stones on a 2D board

I'm writing a program to play a game of Pente, and I'm struggling with the following question: What's the best way to detect patterns on a two-dimensional board? For example, in Pente a pair of ...
-1
votes
1answer
38 views

How to loop in reverse order?(e.g. for i from 10 to 1) [on hold]

I have a list F = {382.856, 638.53, 915.482, 1192.44, 1469.39, 1746.34, 2023.29, 2181.91} And I want to use it to calculate V: I think it should be something ...
1
vote
2answers
102 views

How to create a list with subscript?

I have to calculate: How can I create such a collection? Do I have to set it manually(one by one) like G1=1, H1=1, G2=2,H2=.....? UPDATE: Addtional Questions: How can I store te results into ...
0
votes
0answers
77 views

Mathematica examples with many calculations? [on hold]

This what I'm trying to do with mathematica: I have to do a lot calculation, and use results from previous calculations to conduct followings. But I only know to use Mathematcia in this way: The ...
0
votes
0answers
85 views

Issue with Set function

Tables often come with column headers. Indexing the columns with the header is a natural thing to do. Although a proper dictionary is the usual solution in such a case, I find it often practical and ...
-1
votes
0answers
54 views

How to generate all symmetric positive semidefinite 0,1 matrices of a given order [closed]

The title says it all. There are many instances when we need to check some properties of such matrices. I am looking for an efficient code.
0
votes
0answers
38 views

A problem with functions and Infinite expression 1/0 encountering

Following code (function) makes integrals and then replace f[x] with Cos functions and calculate the definite parametric ...
0
votes
1answer
76 views

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
0
votes
1answer
80 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
77 views

Mathematica Implementation of Householder’s Method

I typed the Householder code in this paper, which starts on page 7. The code is: ...
2
votes
0answers
49 views

Can BreadthFirstScan be modified?

I would like to obtain a "slick" implementation of A*-search algorithm on Graph objects, using the built-in BreadthFirstScan (if that is possible at all). I noticed that BreadthFirstScan is static in ...
1
vote
1answer
94 views

Help to solve the equation with RungeKutta method [closed]

I need to solve this equation. v'[t] + v[t] == 1/(1 + Exp[-v[t]]) I tried to solve it using RungeKutta method described in Wolfram ...
7
votes
1answer
74 views

Equivalence under common permutations

I have lists which consists of sublists of equal length. The outer list is regarded as a multiset (that is, permutations of the sublists don't matter, but repetitions do), but the order in the ...
0
votes
0answers
22 views

Does RuleDelayed work inside MessageName?

using : Mathematica 9.0.1.0 Hello ! Does RuleDelayed work inside MessageName ? This code: ...
1
vote
1answer
101 views

How to replace a list with the result list after each iteration [closed]

I have some initial values such as L1 list: L1={10,20,30,40,50}; I want to use the L1 ...
4
votes
1answer
68 views

How to set the position of the palette when use CreatePalette[]

When using CreatePalette[], the palette created always shows up on the upper left corner. Is there a way to make it show up at the center of the screen, just like ...
2
votes
0answers
86 views

How to restrict the mouse cursor to stay within a box?

I'm trying to use Mathematica to write small games, and I find that it would help to restrict the player's mouse into the game window (just like other games do). Is there any way to achieve this? ...
0
votes
1answer
45 views

Problem with Label in a Do loop, “nolabel” [closed]

Can someone tell me why this code doesn't work and how to fix it ? Thanks. ...
1
vote
3answers
165 views

How to update a list in a function in each iteration

There is a list with numbers 1 to 8 ( p1 ) and another list (j) which contains 4 numbers which shows different 4 positions of ...
1
vote
3answers
157 views

How to replace identical positions in two different lists

Assume that I have two lists like : list1={1,2,3,4,5}; list2={a,b,c,d,e}; I want to replace some elements from list1 into ...
-1
votes
1answer
80 views

Transformation of a simple logic statement

I'm designing a logic circuit and I was wondering if the following two things are equivalent: (x <= y) and (x < (y + 1)) I can't think of any set of numbers that would make these two things ...
0
votes
1answer
44 views

How to put some values from a list into a function in a Do loop

I want to program a code in MATHEMATICA in order to calculate some values in different iteration. For example, assume this list: list={1,2,3,4,5} Now assume that ...
1
vote
2answers
66 views

Avoid making repeated Random Integer in different iterations

Assume following code : Do[ i1 = RandomInteger[{1, 5}]; i2 = RandomInteger[{1, 5}]; While[i1 == i2, i2 = RandomInteger[{1, 5}]] , {k, 1, 4}];` This ...
0
votes
1answer
66 views

Defining a new matrix product of matrix function

Suppose I have two matrices A, B, whose entries are functions of x. Suppose they are 2*2. In the product, each entry is of the form $\sum_k A_ik B_kj$. There are two summands corresponding to k=1,k=2. ...
1
vote
1answer
99 views

Requesting explanation of FitModel code

I am struggling with understanding the code given in this original post I understand how the tests are conducted, both of them. However, I do not understand this part: ...
0
votes
1answer
160 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, ...
11
votes
5answers
1k views

What is the fastest way to extract a substring from a huge string?

I develop an algorithm to find the most common substrings of a given length n up to a certain distance l in front of a pattern p in a huge sequence S. E.g. I want to find the most common hexamers ...
0
votes
2answers
82 views

Finding lags of time series with `Do`

I have generated two time series, S[t] and P[t] as follows: ...
1
vote
1answer
48 views

Hide MathKernel Tab on Taskbar when using C++ [duplicate]

I am connecting to MathKernel.exe using C++ via MathLink on Windows. Hence, to create the link, this is what I use: ...
0
votes
0answers
68 views

Integrate double definite integral [duplicate]

I am trying to evaluate an integral numerically and plot its result. My mathematica code is: ...
13
votes
2answers
389 views

Most influential and/or disrupting features introduced with new versions of Mathematica

This is something that has been bugging me for ages. With every upgrade, Mathematica has added new functionalities and amendend some of its bugs. In the process, though, some older functionality has ...
1
vote
1answer
212 views

Euler's method for system of differential equation

I need to program Euler's method to solve a system of two diffferential equations of first order. Fist, I have programmed the Euler's method for just one differential equation: ...
1
vote
0answers
65 views

Read expression from Mathematica via Mathlink C++

This is a simple C++ program to send an expression to the_Mathematica_ Kernel and get its response. ...
3
votes
2answers
65 views

Defining an anonymous function using another function but with fewer arguments

In MATLAB you can use an anonymous function with another function to define a new function with fewer arguments as long you define the excluded argument before, e.g. ...
0
votes
1answer
66 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? ...
2
votes
2answers
120 views

Solving a dynamic program via recursion

I'm trying to use recursion to solve a joint inventory/ dynamic pricing problem as in monahan, petruzzi and zhao 2004. I tried to solve for y[t] and ...
1
vote
1answer
43 views

MLEvaluate() Function Gives Error

I am trying to link my C++ program to Mathematica Kernel. I am trying to use the MLEvaluate() evaluate but I receive an error while compilation. My codes are as below: ...
3
votes
0answers
138 views

A* algorithm for finding shortest path in a graph

FindShortestPath finds the shortest path between two vertices in an edge-weighted graph, allowing a choice between the Dijkstra and Bellman-Ford algorithms. In my (limited) understanding, both of ...
2
votes
0answers
85 views

Using NVIDIA 3D Shutter Glasses with Mathematica

Mathematica has great capabilities to display 3D Graphics rendered to the 2D screen. This should make it perfectly suited to use the Graphics3D system together with an NVIDIA Graphics card, a 3D ...
4
votes
1answer
132 views

Using Mathematica in Conjunction with LyX. Path Issues?

I am attempting make life easier, and, instead of using Mathematica at the same time that I'm using LyX (a front end for LaTeX), I was hoping that I could just use LyX and use the CAS option to do ...
11
votes
1answer
312 views

Generating Gelfand-Tsetlin patterns

I am doing some research on some combinatorial object called GT-patterns. They are generated from three parts of data. Two integer, partitions (sequences of weakly decreasing numbers), $\lambda = ...
1
vote
1answer
165 views

Programming- cryptography

I have defined the following function in Mathematica to get a SET OF m SETS (these sets are the codes {p,q,d,e,n} for the ...
0
votes
1answer
285 views

How can I draw this particular phase diagram in Mathematica? [duplicate]

Sketch the phase diagram for systems with the following velocity functions where a and b are constants with ...
1
vote
0answers
65 views

DifferentialEvolution scaling factor randomization

Using NMinimize for finding global minima, one can choose the DifferentialEvolution method. You can find a (not so) detailed ...
0
votes
1answer
70 views

How to write series of Do[ ]'s with a single Table[ ]?

Edited to provide more information (sorry I don't know how to format matrices here) I would like to replace: m = 4; ...
3
votes
2answers
123 views

Bare symbol invocation fails but not if used with an argument

How to achieve the following behavior on a symbol f? Background: The main goal is to use the symbol to tag an abstract data structure where downvalues are used to store information. Only defined ...