Converting Standard For Loop to Mathematica Code for 2D Iteration?

  • Thread starter Thread starter rhythmiccycle
  • Start date Start date
  • Tags Tags
    2d Mathematica
rhythmiccycle
Messages
9
Reaction score
0
here is the pseudo java (processing) code I'm trying to run


Code:
float x0,y0,x,y,t;

x0 = 2; //arbitrary value
y0 = 5; //arbitrary value

x = x0;
y = y0;

for(int t = 1; t <= 100; t++){   //one hundred iterations
    t =atan2(y,x);
    x += cos(t);
    y += sin(t);

    print( x, y)

}

I'm trying to run something more complex than this, but the code above shows the main point where I can't convert standard "for loop" programming to mathemitica.


please help me write an equivalent code in mathematica.
 
Mathematics news on Phys.org
Perhaps better posted in the Math and Science Software section.

Note/Warning: read
http://reference.wolfram.com/mathematica/ref/ArcTan.html
for information on the order of arguments in ArcTan to tell
whether you need ArcTan[x,y] or ArcTan[y,x].

x0 = 2;
y0 = 5;
x = x0;
y = y0;
For[t = 1, t <= 100, t++,
t = ArcTan[y,x];
x += Cos[t];
y += Sin[t];
Print[ x," ",y];
];
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...

Similar threads

Replies
2
Views
3K
Replies
11
Views
3K
Replies
6
Views
2K
Replies
4
Views
1K
Replies
18
Views
4K
Replies
1
Views
2K
Replies
16
Views
2K
Back
Top