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

-1
votes
0answers
46 views

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

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

A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
0
votes
1answer
78 views

How to produce functions [on hold]

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
74 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
48 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
87 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
72 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
26 views

Determine if a point is inside two planes [closed]

If I have a point and two planes defined by three vertex each how can I know if the point is inside the two planes? note: I need to code the solution in java.
0
votes
0answers
21 views

Does RuleDelayed work inside MessageName?

using : Mathematica 9.0.1.0 Hello ! Does RuleDelayed work inside MessageName ? This code: ...
1
vote
1answer
100 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
39 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
163 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
156 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
41 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
64 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
64 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
154 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
81 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
67 views

Integrate double definite integral [duplicate]

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

NDSolve_ODESolve_Plotsolution [duplicate]

I am trying to use mathematica to solve this problem. Thank you! Given the ODE $$ -\frac{a^2 V_0}{2} f''(x)-V_0\cos\big(\frac{2\pi x}{a}\big) f(x)=E f(x) $$ (a,V_0) are positive real constants. Find ...
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
195 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
64 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
63 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
59 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
118 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
132 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
83 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
129 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
310 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
164 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
263 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
61 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 ...
0
votes
1answer
79 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' ...
8
votes
3answers
194 views

Pairwise distances of points and classification using GraphDistanceMatrix

The challenge Given $n$ points in $\mathbf{R}^3$ and a cutoff distance, $d$, I would like to determine all pairs of points that are separated by less than the given cutoff distance, $d$, and all ...
10
votes
2answers
474 views

Finding all possible solutions to a math mind game

In the example below the letters shall be replaced by numbers. The numbers are from 1 to 9, and each letter has the same number ...
15
votes
2answers
356 views

Schedule programing problem with integer linear programming

I know how to model this question on paper, but I don't know how doing it in Mathematica. Imagine , there is a university student who want to choose courses for this semester and he got the ...
1
vote
2answers
137 views

Plotting in the “Manipulate” function - simple coding

Hello Mathematica community, my name is Preston! I have a real quick question that should be easy to answer. Alright, so for a research project that I'm involved it at my university, I need to ...
4
votes
2answers
223 views

Can Mathematica functions have static variables?

In C, one can have variables that are declared static. These are not re-initialized every single time a function is called. ...
3
votes
1answer
94 views

How to test whether an expression is a valid variable?

I would like to test whether an argument is a valid variable for functions like Solve and DSolve. For instance several ...