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.
1
vote
1answer
44 views
Mapping multiple functions
This question was part of a course on Mathematica written in 1998.
Each of the functions f1, f2, and f3 defined below has a root near
x=2. Map an anonymous function involving FindRoot[] onto ...
-2
votes
2answers
67 views
Forecast Future Stock Prices - Brownian Motion - Again
excuse me, I think I have here a technical problem with Mathematica
yesterday I posted the question with the title: Forecast Future Stock Prices - Brownian Motion
I am still not very experienced but ...
23
votes
7answers
702 views
Having used Mathematica as a “gateway” language, where to from here?
I have been using Mathematica for about a year. It is the first language that I have attempted to learn. I'm still very much a newbie, but there are moments I feel more like I am waving than drowning. ...
-1
votes
0answers
49 views
Doing vector manipulations in Mathematica (Part 2) [closed]
Inspired by the answer from Simon Woods, here, Doing vector manipulations on Mathematica, I thought of doing the intended vector manipulation in the following way but it didn't work!
...
19
votes
0answers
99 views
How safe is the use of Block and Internal`InheritedBlock
For many questions on this site answers are given which suggest to use Block and, especially for more advanced topics, ...
6
votes
2answers
143 views
Dynamic graph visualisation using JLink/Java and GraphStream
Visualising the addition of new nodes and edges to a graph to 'watch it grow' is to something Mathematica is not suited to by default. However this type of animation really helps convey the emergence ...
1
vote
2answers
64 views
Counting a cardinality of a subset satisfying special property
Suppose that we have a set of 9 2-dimensional vectors $c$ by
m=3;
n=2;
c=Tuples[Range[m],n];
We want to define a subset $S$ of vectors in $c$ by the following:
...
8
votes
1answer
104 views
Notebook[] vs. DocumentNotebook[]; display a Notebook[] inline, like a DocumentNotebook[]
If you evaluate a DocumentNotebook[] expression in the front-end, it nicely displays inline, inside of an output cell in the current notebook:
For my purposes, ...
3
votes
1answer
28 views
Combination of CellPrint and PrintTemporary, or DisplayForm for Cells
I'm programmatically generating some formatted output that generates a cell in the form of a Cell[] expression. For instance, the output might be
...
4
votes
2answers
108 views
How can I write a Do loop that iterates over N iterators when N is not known a-priori?
For any positive integer $n$ which is not specified a priori, I can make $n$-tuple vector $v$ by v = Array[a, 1, n]. Now, given that $n$ is a positive integer which ...
0
votes
1answer
105 views
What is wrong with this Cobweb plot [closed]
Something is wrong with my cobweb plot code but I couldn't figure out where do the mistakes come from.
So basically we have the iterative map $x_n == x_{n-1}^{2} - 3 \mu$. I would like to draw a ...
3
votes
1answer
114 views
Using single replacement rule to convert algebraic expression
I have been trying this problems for hours and cannot find any helpful clues.
How can I convert $Sinh[3\theta]+Sinh[\theta]$ to a rational function of x given $2Sinh[\theta] = x-x^{-1}$ by using only ...
1
vote
1answer
135 views
Solve this equation symbolically
I am trying to solve the equation for the quantity r = y/x symbolically:
3/y^4 == 3/x^4 + a/(x + 2 y)^4
with the requirement that we need to perform the ...
2
votes
1answer
127 views
Range of stability for iterative map
Using linear stability analysis, I would like to compute the range of stability of the fixed points and the 2-cycles of the following iterative map: $x_n = x_{n-1}^{2} - 3\mu$.
Setting $x = x^{2} - ...
1
vote
2answers
178 views
Doing vector manipulations on Mathematica
This is hopefully a simpler version of this previous unanswered question of mine.
Let me just focus on the two expressions $F_2^{(s)}$ and $F_3^{(s)}$ given in A.3 and A.4 of page 19 of this paper. ...
4
votes
3answers
95 views
Modify this code using Module and While
I have written a recursive function and would like to re-write the code using Module AND While to compare the timings.
Here is my recursive function for f[n], where 6 n f[n] = f[n-1] + n! for n>0 and ...
0
votes
0answers
34 views
Generating partitions of a set with a specified size of the parts [duplicate]
I tried the following (inspired by the answer here)
myList = {a, b, c};
Needs["Combinatorica`"];
SetPartitions[myList]
and I got this answer,
...
4
votes
4answers
144 views
Unexpected behavior of Unevaluated
Maybe it is about time I read some proper text about the main loop. Maybe I should not care (so much) about Unevaluated (as Leonid suggests). But I think this is an interesting question anyway.
This ...
0
votes
0answers
45 views
Generating partitions of a set [duplicate]
Is it possible to get Mathematica to generate all possible partitions of a set of objects?
(..or equivalently if it can be made to do the cumulant expansion or at least the Gaussian special case of ...
2
votes
0answers
99 views
I am missing a function like HoldPattern
Temporary message: I am planning to edit this question, making the examples less confusing and by moving the things that are confusing to a separate question
For any confusion about expressions that ...
2
votes
1answer
85 views
Is it possible to treat starting values as variables?
I have a problem where I am using FindRoot a gazillion times over a grid of parameters. I need to allow the starting values to vary a bit with the parameters to get it to converge. Here is a simple ...
8
votes
3answers
106 views
What does `: Hold[$IterationLimit]` mean?
In this answer, what does the : Hold[$IterationLimit] part of the following construct do?
...
4
votes
2answers
140 views
why set values in this way doesn't work?
question is as follows
define a list
ttt={1,2};
and if I set values in this way
{ttt[[1]],ttt[[2]]}={3,4}
then the value ...
0
votes
2answers
54 views
How can i execute several Commands in one text file and use it in notebook?
I want to execute several commands in one text file and use it in notebook by Get[] command.
for example:
...
9
votes
3answers
213 views
Comparing Mathematica expressions like diff
I am looking for a way to compare (or "diff") two Mathematica expressions, similarly to how to diff utility can compare two text files and report the differences.
Has anyone already written such a ...
-1
votes
1answer
118 views
How can I decrease number of lines of code in a notebook? [closed]
I have too many lines of code and I want to reduce the line count.
For example, I have a notebook with 2000 lines of code, and i want to hide some of it so there are less than, say, 200 lines. Can ...
2
votes
1answer
87 views
How to run Mathematica using Mac Terminal
My question is so trivial and I'm sure most people in here know exactly how to do this, however I still don't know how to run Mathematica in Mac terminal!
I need to use all the cores of my computer ...
-1
votes
2answers
142 views
How can I find a function that fits some points? [closed]
I have some points and want to find a function from them. For example, $(-2,4),(0,0),(1,1),(5,25)$. I don't have a function that generates the points.
11
votes
2answers
125 views
Triggering actions when a variable is set
Some built-in variables trigger actions when their values are changed:
...
0
votes
0answers
45 views
How can I import sound from within a Manipulate expression?
I want to import sound from a file, record, and import sound.
...
0
votes
0answers
15 views
Conflict among Permutations and Graph utilities once Combinatorica is loaded [duplicate]
I have tried to figure out and solve the problem of compatibility of Permutations and Graph utilities of Mathematica once the Combinatorica Package is loaded, but I failed :(.
Could anyone explain me ...
0
votes
2answers
58 views
characteristic polynomial based on differential equation
I have this differential equation:
$$\ddot{x}-\frac{1}{6} \dot{x} - \frac{1}{6}x = e^t$$
When I DSolve it looks like this:
...
1
vote
3answers
95 views
Minimize user defined function
I have a user defined function h[i_,j_] and I would like to find its minimum value over all integers $1 \leq i \leq 100$ and $1 \leq j \leq 100$ and $j \leq i$. I would just like Mathematica to try ...
13
votes
2answers
307 views
Fastest way to measure Hamming distance of integers
I am looking for a fast and robust way to calculate the Hamming distance of integers. The Hamming distance of two integers is the number of matching bits in their binary representations. I expect that ...
2
votes
2answers
96 views
9
votes
3answers
148 views
Custom functions by delegating options in a specific way and using core functions
I'd like to create a custom function that does essentially the same as a core function of mathematica but uses different default settings.
Example: I want a Plot function that uses Mathematica's core ...
5
votes
3answers
113 views
Unencoding encoded URLs in a function
Is there a built-in function for decoding encoded URLs in Mathematica?
I would like to convert an encoded URL, for example
...
12
votes
3answers
237 views
Accessing list elements by name
First, a bit of a long introduction to my problem:
I only have a few weeks of Mathematica experience. I am creating a mathematica application that calculates some material properties of steel based ...
2
votes
1answer
76 views
Combining two notebooks
I have a notebook which contain all the variables and defined functions. I want to do two tasks. As an example, I want to find the density and energy which have equations in terms of above mentioned ...
4
votes
0answers
55 views
Is there a way to check whether two notebooks share the same variables?
When I code in Mathematica, I often re-use code from old notebooks which fulfilled a specific purpose; for example, one testing for soft matches in strings, or one that identifies outliers on a graph ...
27
votes
9answers
6k views
Generating a Sierpinski carpet
I am trying to draw a Sierpinski_carpet. I have code that works, but I think there is a more elegant way to do than my way. Maybe I couls use Tuples or ...
5
votes
1answer
182 views
NestList and Euler's method
I am new to mathematica and so just experimenting with various programming constructs. Recently have been looking at NestList and how I could use this to implement ...
12
votes
3answers
495 views
Fastest way to calculate matrix of pairwise distances
It is a very common problem that given a distance function $d(p_1,p_2)$ and a set of points pts, we need to construct a matrix ...
1
vote
1answer
80 views
Automating sequential import of data from web
I am trying to import data from multiple web pages hosted by a single online source. The data is posted by the source as one data set per web page for each week of the year. I would like to import the ...
20
votes
4answers
547 views
What tools can help in realizing tail recursion?
I had nice discussions with Leonid and Rojo that got me interested in tail recursion. Tail recursion is not always easy to realize with Mathematica, so it would be nice to have some tools to help with ...
1
vote
0answers
133 views
Data structure for a list of actions
The idea: I need to generate a sequence of events then run a "propagator" over the list of events where the "propagator" will update the state of the following event. I can then write functions that ...
10
votes
3answers
392 views
What is Mathematica's equivalent to MATLAB's filter function?
The MATLAB code
filter(0.5,[1, -0.5], [1:10])
is equivalent to
Rest@FoldList[(#1 + #2)/2. &, 0, Range[10]]
I don't ...
11
votes
1answer
195 views
Need help coding/creating a recursive list
I have two lists A and B, each with 99 real numbers. I want to form a list, C, whose ...
1
vote
2answers
283 views
Running a Numerical Simulation on a System of Differential Equations with unique initial conditions
I have a system of differential equations as follows:
...
1
vote
2answers
124 views
Select rows from table by keys
I am looking for a way to iteratively select all sublists with the same ID (my 1st column, residual columns are AbsoluteTime entries). First, I obtained the list of ...
