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

3
votes
1answer
89 views

Image background subtraction using parallel computing

I am developing a program for pattern recognition. I want to use the parallel computing to get a real time application. I have two cameras where each one gives n frames/second. I need to process the ...
7
votes
1answer
98 views

why CopyFile cannot overwrite existing file?

CopyFile return $Failed when the file exists on destination. is there any way to force CopyFile to overwrite the existing one? the way I use now is DeleteFile and ...
2
votes
1answer
86 views

Please explain this while-loop

Code: ...
4
votes
0answers
137 views

Tutorial video on the Wolfram Language [closed]

A 3 hour video explaining the workings of the Wolfram Language is now available at: http://www.wolfram.com/broadcast/s?sx=Gaylord downloading the pdf or notebook here of entire lecture is very ...
4
votes
1answer
141 views

Association and rudimentary object-oriented programming

Doesn't Association provide us rudimentary object oriented programming via constructs like ...
9
votes
6answers
500 views

Best way to find permutation with specific total

Can anyone suggest a good way to find permutations of 12 digits, 0 to 4, totalling 24. I.e. two such permutations:- {2, 1, 4, 1, 2, 2, 2, 2, 2, 2, 1, 3} // Total ...
7
votes
2answers
149 views

Connecting to LeapMotion

Thanks to those who helped me with my previous question. I will help others too where I can. In the meantime I have a general question whether anyone has had success connecting Mathematica to the ...
6
votes
2answers
161 views

Manage a network of Arduinos using Mathematica and xbee

I'm trying to take 5 analog reads from two or more Arduinos at different times. So to do that my listening port via xbee is COM8, then I start a ...
5
votes
4answers
317 views

Is there any way to assign multiple values?

I am looking for something like "byref" assignment in programming languages. Let's assume I have: x1=x2=....=xn if I want to change their values ( say to 3 ) I need to set all of them like: ...
6
votes
1answer
133 views

Where can I put my conditions?

I just learned in this answer that you can put conditions inside a With and thus use computed values in them, like this: ...
8
votes
2answers
294 views

Recursive partitioning: Is there a better way to do this?

Consider the following function, which recursively splits a list into equal length sublists (the length of the list is assumed to be a power of the second argument): ...
6
votes
2answers
254 views

How to transform a matrix to upper-triangular with operation- tag elegantly?

Description: Recently, I have a thought that writing a function to show the transformation process when a matrix is transformed to upper-triangular. My trail ...
1
vote
1answer
138 views

Help in Bifurcation Diagram

My dears, I need to plot a bifurcation diagram for the following non-linear systems represented by the next Mathematica code ...
0
votes
1answer
83 views

How to plot multiple orbits with more than two functions

Using a program given to me (which was designed to have a particle orbiting another of infinite mass), I tried to extend it to the motion of two particles orbiting a common centre of mass. I have a ...
1
vote
0answers
75 views

Elementwise operation, part deux [closed]

There are many answers to this question: which are forms of Mathematica's map, but languages like Scheme (I think also Python in recent years) also provide a ...
3
votes
1answer
229 views

How to use Mathematica for traditional programming

I am new to the structure of Mathematica. I understand that in the notebooks, one enters the symbolic expressions and evaluates them. But I need to generate some simulated data and do that a few ...
3
votes
3answers
74 views

Composing function returning list and function taking multiple arguments

What is the easiest way to compose a function that returns a list of $n$ elements with a function that takes $n$ arguments. If I know this $n$ a priori, I can do something like ...
3
votes
1answer
112 views

Writing this loop in Mathematica

OK, so I've never had to write a line of Mathematica code (except for using it interactively as a calculator), but for this it looks like I have to. If someone could provide me with the code for the ...
0
votes
0answers
82 views

How do I perform the following numerical integration

I have the following integral to evaluate numerically: $$x(t) = \frac{1}{f(t)}\int_0^{t_b} t^m (t + n)^o \sin(pt) \mathrm{d}t \quad m,n,o,p \in \mathbb{R}$$ ...
2
votes
1answer
70 views

Using HoldFirst but not wishing to hold everything

I have a DynamicModule in which I go through some data analysis and keep or reject the results. Here is a toy example of what I am doing. ...
6
votes
1answer
307 views

Plotting a moving ball for projectile motion with animate

Here is my code for plotting an orbit. What I want to do is have the "planet" shown as it orbits in the simulation. Can anyone help with this? ...
1
vote
1answer
65 views

How to understand the extensional usage of Flatten? [duplicate]

Recently, I have been reading Mathematica program that written by many advanced Mathematica user, like Mr.Wizard, J.M., Kuba,etc to improve my programming capacity In the On generalizing Partition[] ...
2
votes
1answer
85 views

Probability evaluation fails with equals condition

The following evaluation fails (the result is just the copy of the input) $$\text{Probability}[0<x\leq a | x-y=t,\{x\ {ExponentialDistribution}[\lambda ],y\ {ExponentialDistribution}[\lambda ...
0
votes
0answers
161 views

Converting a matlab program into Mathematica 10

I sought help from this entry at Calling MATLAB from Mathematica to see if I could CONVERT a mathlab program which simulates polymer dynamics that is provided at the download section at ...
1
vote
2answers
167 views

Plotting an orbit using first principles [duplicate]

I am fairly new to Mathematica, but I am trying to plot an orbit of the Earth around the sun using the equation: $\quad r(t+dt) = (2 - G*M*dt^2/r^3)*r(t) - r(t-dt)$ I need to break this into ...
1
vote
2answers
94 views

How to define a function or procedure that includes multiple steps?

I would like to define a procedure or function that takes as input an integer, s, and gives as output two nested lists. I have written code (shown below) that does this for one particular value of s, ...
0
votes
0answers
38 views

Path must include /TypeSystemLoader.m?

I have encountered a number of odd issues using the Wolfram Workbench 3.0 Debugger. Whenever I try to step into a Switch[] statement, I get the following error message: "Problem Occurred - Debug ...
1
vote
2answers
63 views

Changing a tag when one function is passed into another using UpValues

I have two complicated functions f[x,y] and g[t]. Before the main evaluation code in ...
2
votes
0answers
30 views

How to syntax check that all instance of symbol must be contained in Subscript[]

I have a function f[expr] that is only allowed to take an expression expr that is a polynomial in ...
3
votes
2answers
111 views

Apply Collatz Funtion to solve and print the answer

Good day to all! The objective of my task is apply the collatz function for a number x1 and print the exact number of iterations until ...
7
votes
6answers
419 views

How to build a list of functions

Having said that I'm no expert, I have some problems in generating a list of functions inside a loop. The functions in the list should depend on the elements of a parameters list, that are read in ...
1
vote
0answers
93 views

Expectation Maximization Algorithm

I would like to use the expectation maximization algorithm within Mathematica. The issue is that I am very basic user and progress slowly with understanding functional programming.. I have found this ...
5
votes
2answers
145 views

How to understand the process of ListCorrelate when it in two-dimensional condition?

Toady,I learn a function ListCorrelate,and I can understand process of execution his result in one-dimensional. However,the ...
0
votes
2answers
108 views

Are there ways to create local variables analogous to a local variable in C++ and other languages? [closed]

There has been a great deal of discussion on local variables in Modules and Manipulate. If I am reading this correctly, local variables in a language such as C++ or C# are not exactly analogous to ...
3
votes
1answer
154 views

How to replace While construct to NestWhile(functional-style) correctly?

Recently,I find the program of @J.M. about Get a "step by step" evaluation in Mathematica is a very useful example for learning Mathematica programming. In the function ...
17
votes
5answers
1k views

How to speed up my Project Euler code

The evaluation speed of Mathematica often depresses me. It did it again when I wrote a code to solve a Project Euler problem. https://projecteuler.net/problem=206 Here's my code: ...
6
votes
4answers
1k views

Use Mathematica to calculate the area enclosed between two curves

use mathematica Hence, calculate the exact area enclosed by these curves using Mathematica. $f(x)=x^3$ and $g(x)=x^5 - 2 x^3 - 3 x$ i have got the graph...now I'm stuck with finding the area
4
votes
2answers
238 views

Approximate value for the area between the curve

I've got this task: Use Mathematica to obtain an approximate value for the area between the curve $y=1/4$ and the x-axis over the interval $[1,2]$ with $50$ subintervals using the left ...
1
vote
1answer
117 views

How determine The most possibility probable with programming

i have a scatter chart of probable of happen some thing like below chart link of google chart i what determine the probable The most point in below chart , can use a mathematic method to determine ...
5
votes
3answers
145 views

Prevent iterator name from being confused with symbol passed into function body

I have a massive amount of code with lots of Table and Sum inside a Module. Each with their ...
10
votes
0answers
154 views

Can code optimize code?

Are there functions, programs or packages that deal with optimizing mathematica code i.e. re-writing ineffecive or convoluted code. -This question has haunted me since I joined SE. The background for ...
1
vote
0answers
156 views

What are the best tips in Michael Trott's beer/whiskey Wolfram Blog post? [closed]

Michael Trott posted this incredible tour-de-force on the wolfram blog: http://blog.wolfram.com/2014/08/19/which-is-closer-local-beer-or-local-whiskey/ The length of the post is overwhelming, so I'm ...
10
votes
2answers
225 views

Why isn't Lookup treated like other symbols?

With Mathematica 10, I wanted to overload Lookup using TagSetDelayed, but it doesn't work. For instance, if I define two objects ...
3
votes
2answers
82 views

How to define a nestable Baseform function, BaseForm output becomes BaseForm input

Mathematica won't change a number's BaseForm recursively: 63969 // BaseForm[#, 16] & // BaseForm[#, 8] & // BaseForm[#, 2] & Well, I inspected former ...
16
votes
6answers
825 views

How to understand the usage of Inner and Outer figuratively?

Description: In Mathematica the functions like Thread, Inner, Outer etc. are very important ...
5
votes
1answer
188 views

How can I make a “self-referential” replacement operation self-contained?

Fairly often I find use for replacement rules that call themselves on the right-hand side of the rule, e.g.: ...
0
votes
3answers
150 views

Avoid creation of OwnValues when inserting transformation rules into Experimental`OptimizeExpression

I have a large list of transformation rules that I want to simplify. I find Experimental`OptimizeExpression works as it gets me the answers. My question is: **I can only get this to work when I ...
42
votes
0answers
639 views

Is this 30% slowdown in Mathematica 10 due to DownValues lookup time?

Running several numerical self-programmed packages I realized already some time ago that Mathematica 10 needed between 20 and 40% more time. I did already report this of course with a simple example ...
4
votes
3answers
213 views

Skipping over iterator values in a Table

I have been using the built-in function Table for some computations. (The following is not an actual representation of the equations I am using). ...
3
votes
2answers
163 views

The value of an option inside a native function

I'm looking for something similar to AbsoluteOptions but that can be evaluated inside the function. That is, I want to read the absolute settings of options ...