Skip to main content

Questions tagged [procedural-programming]

Questions about Mathematica's procedural programming paradigm.

Filter by
Sorted by
Tagged with
0 votes
1 answer
111 views

I have a question. Why does my result start with J = 2? I write another loop but it start 1 i confused-i need help ...
Hossain Sultani's user avatar
4 votes
1 answer
166 views

I have a list of solutions Subscript[x, 1][t], i = 1,...,n (n given). I would like to use these variables to define new variables such as: ...
derdin1's user avatar
  • 63
0 votes
1 answer
168 views

I want Mathematica code the does what the following pseudocode does. ...
Rack Cloud's user avatar
2 votes
2 answers
580 views

The problem like this: find all integers n, 1 ≤ n ≤ 10, 000 such that n is the sum of two cubes of positive integers in two different ways. I want to solve the problem as a procedure in mathematica.
bajoneet's user avatar
1 vote
1 answer
97 views

Just get {10} from code below. jason[x_] := Module[{}, {b = 1}; b = b*Nest[# + 1 &, 1, x]; b] jason /@ Table[i, {i, 1, 10}] This gets it right with Do ...
kile's user avatar
  • 2,012
3 votes
1 answer
129 views

I'd like to do a calculation which is basically a looping routine to evaluate a recursively defined function. For example: ...
Moisés Lemos's user avatar
0 votes
1 answer
130 views

My question is, if there is a command/function that gives me the first value for which an expression becomes false?! For a simulation of several rounds of the game battleships(ger. Schiffe versenken) ...
Physiker11111's user avatar
1 vote
2 answers
128 views

Update A very crude attemp ...
CasperYC's user avatar
  • 1,672
3 votes
2 answers
406 views

How can I convert my multiple outputs of a while loop in a table form and save it for later use. Here is a sample code: ...
primefinder's user avatar
1 vote
1 answer
423 views

I'm using Mathematica, and I want to integrate a function f[wr] in wr using some method that works with a Table/Do/For in the variable wr. I tried to use something like the Riemann's sum, to evaluate ...
Lucas Lopes's user avatar
2 votes
2 answers
293 views

How can I plot these straight lines in a picture? ...
saltkun's user avatar
  • 43
5 votes
7 answers
1k views

I am trying to code a while loop that uses AppendTo to append the loop variable to an empty list. ...
Timetraveler 11's user avatar
2 votes
3 answers
231 views

I want to generate random positive hermitian matrices, I start with such a code ...
Agnieszka's user avatar
  • 697
0 votes
1 answer
81 views

I am sure I am missing something trivial :-( Still any help is welcome. ...
user34047's user avatar
  • 335
2 votes
1 answer
132 views

I have a code line having two Do loops, one within other. In certain situation arising within inner loop, I want the outer Do ...
user49535's user avatar
  • 1,225
1 vote
0 answers
112 views

Eout = E^x ; For[kz = 1, kz < 4, kz++, Print[Eout1[kz] = Eout]; Print[kz]] The output is E^x 1 E^x 2 E^x 3 But what I ...
a019's user avatar
  • 887
3 votes
1 answer
476 views

I have a long Mathematica code in a notebook, denoted by NB1. Since it is a very long code, and I need only some of the outputs from NB1 to be used in another ...
Tugrul Temel's user avatar
  • 6,439
0 votes
0 answers
66 views

It appears to me that loop in mathematica is very slow (compared with matlab). Since many people still use mathematica to finish their work, there must be some techniques to bypass this problem. ...
Charles6's user avatar
1 vote
1 answer
2k views

Can I use for loop for two variables as example show below at the same time? for (int x = 0, y = 0; x < 10 && y < 10; x++, y++)
a019's user avatar
  • 887
0 votes
0 answers
72 views

I am trying to use the Dynamo notebook (https://www.ssc.wisc.edu/~whs/dynamo/dynamo_3S_v1.4.1.nb) in a loop over parameters. Basically, this software takes one matrix as input, solves ODEs and some ...
schrodingerscat's user avatar
0 votes
1 answer
282 views

I want to make a function that performs a multiplication with Inner i number of times using a ...
Alonso Perez-Lona's user avatar
1 vote
1 answer
232 views

I hope my title makes sense. The idea is the make a function in which a set of variables, $l_1$, $l_2$, etc. are accessible inside the innermost body of a nested (/folded) function. Each of these ...
user avatar
0 votes
0 answers
209 views

I am new to Mathematica and for fun am trying some of the challenges. The one I am working on now is: ...
Shamoon's user avatar
  • 113
0 votes
1 answer
475 views

...
vijay's user avatar
  • 47
0 votes
1 answer
928 views

I'm currently computing nested for loops. I count up a few counting variables and compute a value for each set of counting variables, then that value is added to an array. It is a way of adding up ...
LooseyGoose's user avatar
2 votes
3 answers
248 views

Beeing used to programming in C-like languages I am struggling with iterations and loops with mathematica. I am trying not to use the For command, as already lots of people recommended. I am trying ...
JacquesLeen's user avatar
1 vote
1 answer
267 views

I have imported an Excel spreadsheet with dimensions {row, col}= {92, 28} into Mathematica, I want to plot 27 datasets from the spreadsheet: column 1 with column 2, column 1 with column 3, ..., column ...
Aman's user avatar
  • 159
0 votes
1 answer
285 views

I have written a simulation for a percolation test. Then, I am using another notebook to control this simulation to generate 1000 results with a different random seed for each one of them. The ...
Teng's user avatar
  • 341
2 votes
1 answer
107 views

I have several lists containing variables, e.g. list1={x1,x2,x3}, list2={y1,y2,y3}, etc. I would like to define a function in those variables, i.e. ...
Bran's user avatar
  • 275
3 votes
2 answers
1k views

This is an example of procedural programming borrowed from Paul Wellin's book. It's a simple implementation of the Newton-Rhapson method. I overloaded the findRoot ...
Thadeu Freitas Filho's user avatar
0 votes
2 answers
146 views

I have the code for a loop to run. Right now it can check if a number is a square and at the same time check if it is congruent 0 mod 47. My questions is, how can I alter the code to see if it is ...
argamon's user avatar
  • 181
2 votes
1 answer
185 views

If anyone cares, this is supposed to be a very simple implementation of a Metropolis algorithm for a uniform distribution. I want to plot the variance of the sampled values as a function of an ...
Ryland Forsythe's user avatar
0 votes
2 answers
138 views

Apologies if this is a trivial question. It comes from an overall problem I am having with Mathematica. Specifically, within a Do I generated the elements of a (...
simon's user avatar
  • 47
0 votes
1 answer
474 views

I have created a list as shown in picture. the digits inside f are values of a and q respectively. I want to solve the Mathieu equation.....
Kamal Kumar's user avatar
1 vote
3 answers
912 views

I am trying to write a nested for loop that prints the pairs 00 through 55, with each digit running from 0 to 5. In other words, I want the output to appear as so: 00, 01, 02, 03, 04, 05, 10, 11, ......
H. S.'s user avatar
  • 51
0 votes
1 answer
115 views

I have a code given by ...
Mehrab's user avatar
  • 171
1 vote
1 answer
383 views

Sorry to post a long piece of code. There are two places in here where I Print[] 'path2' when the count == 984, because for some reason, that list is getting ...
Jerry Guern's user avatar
  • 4,672
2 votes
1 answer
107 views

For a problem I am working on, I need to create sets all the prime factors of a large set of integers (at least on the order of 1$-$1,000,000 but more on the order of all integers 1 to $10^{12}$). ...
TinyTim's user avatar
  • 23
1 vote
1 answer
114 views

I want to be able to define a set of iterators for nested Do loops, such as ...
Kai's user avatar
  • 2,259
2 votes
2 answers
130 views

I want to create a simple function that prints all prime numbers from 1 to x. I have the following code, which doesn't cause any errors from the kernel but it doesn't return anything: ...
Jaigus's user avatar
  • 257
4 votes
1 answer
911 views

I am novice to Mathematica. I want to convert Mathematica code from my textbook to Java or Python to trace coding.
Cecelia's user avatar
  • 61
0 votes
1 answer
112 views

I want to make a program which tell whether a number perfect or not.So i tried like that: ...
Emon Hossain's user avatar
0 votes
1 answer
56 views

I am trying to create an $ n \times n $ matrix, which has cosine terms. I would like to select the values of the arguments of cosine terms from a random set of values that I have generated. My code ...
Fracton's user avatar
  • 141
2 votes
3 answers
2k views

Consider the linear system AX=B,where A={{3, 0, 2}, {-3, 2, 2}, {2, -3, 3}},B={{3}, {-1}, {4}} and x=...
raihan hossain's user avatar
0 votes
1 answer
199 views

I define a test function in order to stop my While loop: ...
user55777's user avatar
  • 649
0 votes
1 answer
174 views

I encounter a problem when computing the following equations: ...
Yuyi Zhang's user avatar
2 votes
4 answers
323 views

I need to create several graph for different values of a parameter $h$. The code is the following ...
Api's user avatar
  • 93
3 votes
3 answers
284 views

I hope to explore Mathematica by using it for Advent of Code puzzles this year, so spoiler alert for anyone interested in solving https://adventofcode.com/2018/day/1 for themselves. Part 2 of ...
William John Holden's user avatar
1 vote
1 answer
280 views

I'm trying to generate a list of random submatrices with matrix norm 0.1, however I'm getting stuck; currently my code looks like this, where I run over a while loop. ...
MKF's user avatar
  • 633
0 votes
1 answer
84 views

It's my first time to use mathematica, and I hope to iterate the following equations. Ci0=-Ci-1,0 ((i-1+q)p a-p q c)/((i+q) p-p q) C0j=-C0,j-1 ((q p b-(j-1+p) q d)/((q p-(j+p) q) Cij=-(Ci-1,j ((i-...
Yuyi Zhang's user avatar

1
4
5
6 7 8