Linked Questions
125 questions linked to/from Alternatives to procedural loops and iterating over lists in Mathematica
0
votes
3answers
4k views
How do I show the combined plot from the do-loop?
I have a do-loop to do the calculations from a set of data and plot the graphs with different results, that was obtained from the calculations. I was able to get multiple graphs but I want to ListPlot ...
5
votes
4answers
4k views
Finding the area of a circle using monte carlo simulation [duplicate]
I wrote the following code to find the area of the circle $x^2+y^2=1$ using monte carlo simulation :
...
2
votes
1answer
3k views
3
votes
3answers
1k views
For-loop not working as I expect
I want to do this:
When 10 <= t < 130, give t -> 1;
When 130 <= t<300, give <...
2
votes
5answers
2k views
Assigning a particular value to array elements
I have an array of 10000 elements. I want to randomly assign energy to these 10000 elements using Gaussian or Exponential distribution, such that each time a particular element is selected its energy ...
5
votes
3answers
488 views
What is the right way to write a function that includes other functions?
I want to include multiple sub functions:
$b(x) = 10x$
$w(x) = s + b(x)$
$c(x) = x^2$
into two main functions:
$ua(x) = w(x)-c(x)$
$ub(x) = w(x)-c(x)^2$
As a reaction to this answer, I wrote ...
4
votes
4answers
258 views
How to avoid writing $K$ loops?
I want to evaluate a mathematical function of $K$ variables each of variables varying between 1:N. One way to do this is writing $K$ loops and varying variables accordingly, as shown below:
...
6
votes
2answers
174 views
Achieve performance that is competitive with numpy [duplicate]
What are the best practices to ameliorate time performance of Mathematica?
As a practical example how we can decrease timing below?
...
7
votes
2answers
526 views
4
votes
3answers
1k views
Stop Computation - Is Exit[] overkill?
The following example either finds a factor of the number $n$ or returns a message saying that the number in question is prime (I specifially wrote this to demonstrate my question below).
...
3
votes
3answers
2k views
Draw grid lines at multiples of k
Here is a beginner's question: when creating plots with mathematica, I want the grid lines to be at multiples of a constant value. E.g. in the following plot, the vertical grid lines are at multiple ...
4
votes
3answers
473 views
Alternative forms to Table for iterating over replacement rules
I have a multivariate polynomial x. I get coefficients of various monomials using CoefficientRules, which returns a list of ...
6
votes
3answers
489 views
How to populate a large sparse array efficiently
I am trying to populate a large 2D sparse array and sum up all the columns at the end. I tried generating a set of rules and then generate a matrix using SparseArray or break the data into chunks but ...
0
votes
1answer
7k views
How do I store values in a for loop into an array and then plot that array? [duplicate]
What my title said and I want to plot the values of the array. still new to mathematica and programming so its hard to formulate my question just right
3
votes
1answer
931 views
3 hour calculation? ParallelMap & ParallelTable
I'm having some problems with slow Mathematica code... I'm basically doing a computation that's is expected to take 3 hours (!) in my Core i7 with 4 processors... I'm basically computing an index (of ...