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

4
votes
1answer
106 views

Construct a function that can generate a geometry by extruding a section

Toady I want to construct a geometry shown as below: I know the Mathematica has the functions like Cylinder, Sphere and so ...
0
votes
0answers
27 views

How to use ColorData[“Atoms”, “Panel”] as a clickPanel for ElementData[]

simple version ColorData["Atoms","Panel"] is a click-panel for RGBColors. With a single codeline, it can be transformed in a click-panel for ElementData[]. ...
0
votes
0answers
52 views

deleteduplicates Delete elements of a list [duplicate]

I have a math problem about Mathematica, I am looking help from you. I hope that you could help me. The Math Problem: list= { {0,0,1},{1,0,0},{0,1,0} ,{1,2,3}}; ...
7
votes
4answers
285 views

Computing the average over the values of the boxes surrounding a box in a grid

Recenty,I encounter a problem described as below: I have a table that owns many boxes,and each box has a sequence like 1,2,3,4,etc.In addition,every box has a value. Now I want to make the ...
9
votes
3answers
107 views

Implement settable properties

I am looking for advice on implementing the following. (It is possible that the answer is that it is simply not a good idea to do this.) I would like to have an object similar to ...
1
vote
0answers
39 views

Settings to disable global scope

I am building a fairly large application in Mathematica, and globally scoped variables are causing issues. I would like globally scoped variables to be out-of-scope for my expressions, except by ...
2
votes
1answer
134 views

How can I rewrite my code to make it simpler?

Two months ago,I written a function IRobot to caculate the $I_{xx},I_{yy},I_{zz}$ and $I_{xy},I_{xz},I_{yz}$,shown as below: ...
0
votes
3answers
109 views

How can I use NestWhileList instead of While in this case?

OK, the problem occurred when I challenged with Project Euler No. 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. My code is: ...
6
votes
1answer
140 views

Using least independent rectangle area to separate every point

Description I want to add vertical line and horizonal lines between data to make every point have an independent rectangle area. In addtion, every independent rectangle has a number ...
3
votes
1answer
62 views

EndOfFile error

I have a LARGE file (14.6 GB) that I want to separate into several smaller files. Because of its size, using Import/Export is not feasible, I think the most reasonable way of handling this would be ...
1
vote
0answers
126 views

Is learning haskell still necessary to MMA users? [closed]

I'm major in Math and I had learned haskell for one week. But I'm unaccustomed to its coding style. I saw many people said if you want to master functional programming, then you shall use haskell. ...
1
vote
4answers
97 views

multiple sequential definitions, defining own set function

I want to define a function for doing multiple definitions, where I apply the same function f to all values, and definitions are done not at the same time but after ...
3
votes
2answers
135 views

Plotting: DensityPlot produces artifacts

I am trying to plot the electric potentials of bouncing balls using the following code: ...
0
votes
2answers
85 views

How to localize the symbols x,y, A, B in the following program? [closed]

I see a example in Paul Wellin's Programming with Mathematica An Introduction, 4th edition: ...
6
votes
1answer
254 views

What is wrong about Abs[x]-a? Is it a bug?

Why is the Out[74] not {1 - a, {x -> -1}}? ...
0
votes
0answers
66 views

Timing Differences

In More efficient implementation for comparing coefficient lists in a Do-loop link, george2079 posts in his first answer a piece of code that takes 352 seconds to compute. When I run this same piece ...
1
vote
1answer
50 views

Elements of a List according position in axis

({{a, b}, {c, d}}) a, b, c and d are Lists of 300 length. Their first 4 elements must specify their position in the column (1 column, 2 column, etc) and the ...
0
votes
1answer
119 views

How to represent the lines that are formed by the intersection of two planes?

I am trying to set up Brillouin zone and representing the lines that are formed by the intersection of two planes is part of my step. I have tried the sample sections from the graphics guide book, but ...
0
votes
1answer
101 views

For-loop only executes first line in body

I have a simple For[] loop: ...
1
vote
2answers
173 views

More efficient implementation for comparing coefficient lists in a Do-loop

I'm wondering how to speed up the following code so it actually computes for $n=2$: ...
0
votes
1answer
197 views

Obtaining the envelope of an oscillating function and perform fitting

There is an elegant way to obtain the envelope of an oscillation function explained here http://mathematica.stackexchange.com/a/27854/15966 My question is how to modify the code below so I can fit ...
0
votes
0answers
37 views

Automatic Cuda/CPU code; Fast programme run [duplicate]

I have developed my thesis codes by means of Mathematica software in a .nb file format. Despite using the available Parallel code capabilities and doing all the numerical integrations by means of ...
1
vote
4answers
129 views

Plot roots of B(z) according to angle small to large

I have the following function: B[z_]=((z*(z - 0.5)*(z + 0.5))/((1 - 0.5*z)*(1+0.5*z))) I want to plot the roots this polynomial according to angel like below ...
1
vote
0answers
71 views

How to construct a coordinate system that owns detailed calibration in the 3D enviroment?

Recently,I write a program to demonstrate the forward kinematics of the SCARA robot.The code showed as below: Using this function to construct the BigArm and ...
0
votes
2answers
46 views

How to output (anything) if any error happens

I have long code which goes through iteration process. some times I get error messages. I want to get the iteration numbers (or any kind of output indications) when errors happen. for example, how ...
0
votes
1answer
117 views

Differences between 'Solve' and 'LinearSolve' [closed]

Using the function 'Solve' I can do the following: Solve[a x + y == 7 && b x - y == 1, {x, y}] I get the following output: I want to get the same output using 'LinearSolve' instead. How ...
5
votes
1answer
172 views

Higher RAM handling by 32bit Mathematica [closed]

Can 32 bit Mathematica run program which requires more than 4GB RAM ?
1
vote
2answers
83 views

Clearing arguments passed to a Module

Is there a possible way to clear the arguments passed to a module to release some memory. I believe that arguments passed to modules are passed by value rather than pass by reference. e.g. I have the ...
0
votes
1answer
111 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 ...
4
votes
4answers
552 views

Skip other If conditions

I'm trying to write a code to "random" move in a matrix but it can't go to a certain position if it has a certain value (in this case I'm using the number 2). How do I make it to skip all other If ...
8
votes
1answer
99 views

CSS Selectors for Symbolic XML

Symbolic XML is a convenient way of managing XML in Mathematica, at least for casual use or small tasks. Here and elsewhere you can find examples of XML handling in Mathematica, including XSLT/XPath ...
2
votes
0answers
46 views

Simulating a system of nonlinear ODEs?

I was trying to simulate a system of ODEs on Mathematica in an effort to try to understand how to muck around with Mathematica but for some reason the following lines of code do not yield any results; ...
0
votes
0answers
77 views

mdifying a code for nested matrices

I have a matrix such as: ...
0
votes
0answers
34 views

Can the value of a variable be made to persist between front end sessions? [duplicate]

For example, say I create a notebook with a cell a = 5 + 2 and then I close Mathematica, reopen the notebook, enter a new cell ...
1
vote
0answers
112 views

Finding Values of All Nine Constants in q-hypergeometric Equation

I suspect that an identity of the form $$\sum_{j=-n}^{j=n}(-1)^jq^{j(5j+1)/2}=\sum_{r=0}^{n}f_{ar+bn+c}(-1)^{n-r}q^{(n-r)(dr+en+f)/2}\frac{(q;q)_{gr+hn+j}}{(q;q)_{n-r}}$$ for $a, \dots , j$ integer ...
1
vote
0answers
87 views

Whats Mathematica exactly is? [closed]

Is it a software to learn mathematics and programing? Or what? Sorry for my ignorance and my English. I'm not clear about what is.
0
votes
1answer
75 views

ParallelTable not firing

...
0
votes
0answers
41 views

What is a good alternative to this numerical example taken from FindFit?

I am using MMA V9.0 What do you suggest for this numerical example? I am not getting good results trying to use my own procedure to find a "best" fit using the 1-norm. The 1-norm example for ...
14
votes
4answers
1k views

How to implement the Observer design pattern?

As a programmer with a history with procedural languages, the Observer design pattern inmediately springs to my mind when attacking certain class of problems, mostly UI/notifications related. A ...
3
votes
1answer
120 views

Why even try the semantic constraints, if expression can't match the pattern structure?

This result is unexpected: Trace[MatchQ[{7}, {_?NumberQ, __}], NumberQ] (* -> {{NumberQ[7], True}} *) Why evaluate ...
0
votes
1answer
121 views

Using Findroot within a loop

I am trying to get solution to an equation in a loop. The isolate equation works ...
2
votes
0answers
120 views

DynamicModule inconsistent behavior; was: DynamicModule persistent UI changes

Update: I'll restate the question in hopefully more terse and clearer terms. To illustrate the issue, run this and save the resulting notebook: ...
1
vote
4answers
116 views

How to count number of {True,True} outputs?

Do[Print[{x + y + z == 3, x + y > z}], {x, 1, 2, 1}, {y, 1, 2, 1}, {z, 1, 2, 1}] If I run this syntax I get a series of Outputs, I am trying to Count only the ...
5
votes
3answers
220 views

Split list of states by run lengths and discontinuous changes in state

I was asked to look into writing some simulation code for a user, where the simulation output (x) would oscillate between three possible states: ...
0
votes
0answers
70 views

How to save the results in an identical Excel file (.xls) in each iteration of a Do loop

Assume the following code (Below code is just an example to clearly illustrate my problem): ...
0
votes
0answers
91 views

Mean Squared Deviation for Population Data

I've been using the Lotka-Volterra equation to estimate population sizes and need to find the MAD (mean absolute deviation), MSD (mean squared deviation) and mape (mean absolute percentage error) for ...
9
votes
2answers
897 views

Is it possible to create iOS apps with Mathematica?

I am fairly new to Mathematica and don't have much experience with other programming languages, but I can already see that Mathematica and the Wolfram language are far easier to use than most others. ...
2
votes
0answers
48 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
84 views

Scope of variables within a Manipulate expression [duplicate]

I have a problem in defining the local variables. I have this code: ...
20
votes
4answers
929 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 ...