Linked Questions

0
votes
1answer
579 views

Assigning value to an array in nested for loop [duplicate]

I want to write a code like X={}; index=1; max=3; For[i=1,i<=2,i++, For[j=1,j<=2,j++, X[[index]]=i*j; index++ ] ] But I am not getting ...
0
votes
1answer
46 views

An elementary question about For loop [duplicate]

Assume we have this For loop: For[i=1,i<10,i++, i^2]. How can we put the squared values ...
472
votes
37answers
107k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
187
votes
3answers
42k views

Alternatives to procedural loops and iterating over lists in Mathematica

While there are some cases where a For loop might be reasonable, it's a general mantra – one I subscribe to myself – that "if you are using a ...
40
votes
8answers
3k views

Can this be written well, without loops?

Inspired by this question I would like to know if the following code can be written without explicit loops (For, While, etc.) in a clean, efficient and non-contrived way. I have been unable to do so. ...
59
votes
5answers
6k views

Are there any cases when For[] loops are reasonable?

To my mind the only reason for the existence of For[] loops in Mathematica is to allow new users with some experience in procedural programming languages to write ...
7
votes
8answers
540 views

Finding C[i]'s expression in DSolve solution

An example, the command DSolve[y''[x] - 4 y[x] == 1, y[x], x] gives solution ...
9
votes
2answers
677 views

Optimizing Mathematica Code

I have implemented the whole Baum-Welch Algorithm for training Hidden Markov Models as described in Rabiner's paper Here is my code that calculates the Forward Probabilities` ...
5
votes
3answers
1k views

How to speed up a process

I am wondering how to speed up the following code: Currently it takes more than two sec to be processed. ...
6
votes
1answer
530 views

An efficient way to translate a triple for-loop from Matlab to Mathematica

This is my first post on StackExchange, so if I violate any etiquettes, I apologize in advance. I am a senior engineering student who has been using Mathematica for a year now. For one of my classes, ...
5
votes
7answers
340 views

Computing only Prime Powers with NestList

Is there a simple way to compute only prime powers of a function f with NestList? That is, I want to compute: {f[x_0], f^2[x_0]=f[f[x_0]], f^3[x_0], f^5[x_0]...} ...
3
votes
2answers
1k views

For Loop and Sum

I am requested to do a sum of the first fifty positive even numbers by using For loop. The For loop that I created is ...
7
votes
2answers
505 views

CUDA image processing

I am having an issue with image processing involving CUDALink. ...
13
votes
1answer
646 views

Pascal records and Mathematica programming

Background: "experienced" Pascal-programmer (DOS-era, never got into OOP) proud owner of Mathematica ver 11.2 have used Mathematica for years to do my share of number crunching and plotting to ...
5
votes
2answers
567 views

Runge-Kutta implemented on Mathematica

I am trying to solve differential equations numerically, so I am trying to write a 4th -order Runge-Kutta program for Mathematica (I know NDSolve does this, but I ...

15 30 50 per page
1
2 3 4 5 6