Tagged Questions

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

Does mathematica have “Realized Covariance” function?

Does mathematica have "Realized Covariance" function? I see that the function called "CovarianceFunction" may be a little close to this, but it is not so easy to see the actual "realized" property ...
4
votes
1answer
36 views

what's the meaning of “-mathlink” as part of Arg for LinkLaunch?

LinkLaunch["MathKernel -mathlink"] LinkLaunch["MathKernel"] The both code line above can launch a MathKernel. What's the difference of them? what's the meaning of ...
0
votes
0answers
14 views

what's the difference between CreateKernelLink() and CreateKernelLink(String Arg)?

I have a .NET program which will connect to MathKernel. When the program runs, there will be a icon of MathKernel on the taskbar. ...
0
votes
0answers
53 views

What is the meaning of //N in mathematica? [duplicate]

As the title says, What is the meaning of //N? i can't remember it.I tried looking in documentaion center, but it came up with nothing. Help appreciated.
2
votes
0answers
60 views

Distance Time Warp (DTW) function implementation in mathematica

The DTW (Distance time warp) is given here http://en.wikipedia.org/wiki/Dynamic_time_warping There is an implementation of DTW in R as well as MATLAB. However i am unable to find something for DTW in ...
1
vote
0answers
48 views

Programming for matrix manipulation

I want to write a programme which operates on nd x nd matrices. The programme looks the matrix as a n x n block matrix where ...
3
votes
2answers
120 views

Why the function cannot achieve the expected result?

Today, I write a toy code (Framed the prime in a list) to practice Mathematica programming ,which as shown below: Trail 1: ...
4
votes
2answers
457 views

How to create a function like in Python

I want to call a function that would perform a function rather than assigning an expression to them. I.e. ...
4
votes
2answers
363 views

Colorize Grayscale Image

I have a grayscale image that contains two objects. The grayscale pixel values can be divided into three intervals where two of them represent objects and the third represents the background. The ...
1
vote
2answers
45 views

Using conditionals to check if LinearSolve found a solution

Is there some way to check if LinearSolve found a solution using conditionals in Mathematica 9? I need to solve a large number of linear equations, but I am only interested in the cases where there ...
0
votes
1answer
85 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 ...
2
votes
1answer
70 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
85 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
80 views

Please explain this while-loop

Code: ...
4
votes
0answers
110 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 ...
2
votes
1answer
68 views

Association and rudimentary object-oriented programming

Doesn't Association provide us rudimentary object oriented programming via constructs like ...
9
votes
6answers
469 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
130 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
138 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
303 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
129 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: ...
6
votes
2answers
257 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
244 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
117 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
81 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
74 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
203 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
64 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
107 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
78 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
65 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. ...
5
votes
1answer
213 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
59 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
84 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
147 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
153 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
73 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
31 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
61 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
26 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
109 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
357 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 ...
0
votes
0answers
63 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
127 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
103 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
140 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
587 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
3
votes
2answers
202 views

approximate value for the area between the curve

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 endpoint, midpoint and right ...
1
vote
1answer
112 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 ...