Loop Definition and 1000 Threads

In computer science, a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly. Various keywords are used to specify this statement: descendants of ALGOL use "for", while descendants of Fortran use "do". There are other possibilities, for example COBOL which uses "PERFORM VARYING".
A for-loop has two parts: a header specifying the iteration, and a body which is executed once per iteration. The header often declares an explicit loop counter or loop variable, which allows the body to know which iteration is being executed. For-loops are typically used when the number of iterations is known before entering the loop. For-loops can be thought of as shorthands for while-loops which increment and test a loop variable.
The name for-loop comes from the word for, which is used as the keyword in many programming languages to introduce a for-loop. The term in English dates to ALGOL 58 and was popularized in the influential later ALGOL 60; it is the direct translation of the earlier German für, used in Superplan (1949–1951) by Heinz Rutishauser, who also was involved in defining ALGOL 58 and ALGOL 60. The loop body is executed "for" the given values of the loop variable, though this is more explicit in the ALGOL version of the statement, in which a list of possible values and/or increments can be specified.
In FORTRAN and PL/I, the keyword DO is used for the same thing and it is called a do-loop; this is different from a do-while loop.

View More On Wikipedia.org
  1. Chandlerw88

    MATLAB MATLAB For Loop Help: Plot SVAJ Accel Graph w/ Norton 5th Ed

    I have created a code in MATLAB that can plot the acceleration graph of the SVAJ diagram for 3 of the SCCA Family of Functions with a theta range from 0 to Beta. I cannot for the life of me, figure out what I am doing wrong, maybe some fresh eyes can help me. Ignore the 'trial', I'm trying to...
  2. C

    I One loop corrections to Compton scattering

    At next to leading order, a photon may couple to gluon via means of a quark loop insertion. Consider the process $$ \gamma(k_1) + g(p_1) \rightarrow \gamma(k_2) + g(p_2)$$ Apparantly there are eight diagrams at one loop contributing to this process and two are zero on grounds of colour...
  3. T

    MATLAB Arduino-MATLAB communication using SerialEvent() for PID Loop

    Hello, I have an arduino code for driving a peltier pile to a given set point (TEMP_SP). I am trying to input the set temperature from Matlab GUI (with different protocols, user will enter n temperatures and the time intervals, arduino will implement the PID controller and output the...
  4. Kanashii

    Finding the second derivative using central difference formula

    Homework Statement Develop aprogram that will determine the second derivative of pi(16 x^2 - y^4) at y=2 with step sizes of 0.1, 0.01, 0.001…. until the absolute error (numerical-analytical) converges to 0.00001. Use the 2nd order Central Difference Formula. User Input: y, tolerance Output: h...
  5. moenste

    Energy dissipated in the loop during mag. field change

    Homework Statement A closed wire loop in the form of a square of side 4.0 cm is mounted with its plane horizontal. The loop has a resistance of 2.0 * 10-3 Ω, and negligible self inductance. The loop is situated in a magnetic field of strength 0.70 T directed vertically downwards. When the field...
  6. L

    Minimum Speed for a Roller-Coaster Car to Complete a Loop without Seat Belts

    In an amusement park, the new roller-coaster ride The Loopy Looper is com- posed of a number of full loops, where the car goes round upside down. The car is attached to the track, but there are no seat belts. Consider one such loop, which can be taken as a circle with radius r. The mass of the...
  7. moenste

    What is the current induced in a wire loop placed in a changing magnetic field?

    Homework Statement A closed wire loop in the form of a square of side 4 cm is placed with its plane perpendicular to a uniform magnetic field, which is increasing at the rate of 0.3 T s-1. The loop has negligible inductance, and a resistance of 2 * 10-3 Ω. Calculate the current induced in the...
  8. Pao44445

    Finding Voltage Using Junction & Loop Rules

    Homework Statement find the voltage between a and d and terminal of each batteries Homework Equations Junction Rule and Loop Rule The Attempt at a Solution I got three equation JR : I3 = I1+I2 LR : 45-I3-47I3-34I1 = 0 45-I3-47I3+85-I2-18I2 = 0 I can't solve these...
  9. FelixTheWhale

    Magnetic Field of Current loop around the Core

    Hello friends, I am trying to find how calculate the magnetic field created by current loop considering that there is a some geometry of material that can enhance the magnetic field. I thought it can be solved by multipling by permeability μ but realized that the iron core changes the picture of...
  10. JustinT

    A different type of roller coaster loop problem

    Homework Statement A roller coaster at the nearby amusement park Physics Hill, has a large circular loop where cars travel at the top of the loop at 25.0 m/s causing the riders to enjoy an acceleration of 3g. Assuming the height of this loop is the same as the diameter, how high is the loop...
  11. jiaying

    MATLAB Matlab -- how can i use a FOR loop if I have 2 variables changing

    Hey,for following code the 3rd loops i need to have 2 variables m and q .Could anyone help? for t=1:maxiterations toterror=0; for j=1:numfeature totslope=0; for i=1:m&&q=1:numfeature z=0; for jj=1:numfeature...
  12. moenste

    The balance reading when direction of mag. field changes

    Homework Statement The diagram shows a rigid conducting wire loop connected to a 6.0 V battery through a 6.0 V, 3.0 W lamp. The circuit is standing on a top-pan balance. A uniform horizontal magnetic field of strength 50 mT acts at right angles to the straight top part of the conducting wire in...
  13. K

    I Tensor networks, spin networks and loop quantum gravity

    Loop Quantum Gravity, Exact Holographic Mapping, and Holographic Entanglement Entropy Muxin Han, Ling-Yan Hung (Submitted on 7 Oct 2016) The relation between Loop Quantum Gravity (LQG) and tensor network is explored from the perspectives of bulk-boundary duality and holographic entanglement...
  14. A

    Centripetal Force, Friction, Loop de Loop, and Normal Forces

    Two questions I had: 1. How is the force of friction of the tires pointed inwards to cause centripetal acceleration? If the tire is rotated when trying to turn, the car is still traveling with a velocity perpendicular to the circle and force of friction would still be counteracting the...
  15. M

    Engineering Solving Circuits with Resistors: Finding Req and Applying the VIR Chart

    Homework Statement https://s10.postimg.org/lb6n94ua1/20161007_190700.jpg Homework Equations V=IR The Attempt at a Solution So far I haven't had any problems finding the Req. However, I am having trouble with the VIR chart. Can anyone confirm whether or not I did it correctly. My thought...
  16. A

    I Spin Foam models in Loop Quantum Gravity

    Hi all, I fairly basic question about spin foam models in loop quantum gravity. I just want to verify that spin foams represent effectively represent all of spacetime (in a quantum form), and that the idea is that general relativity can be obtained in the classical limit? Not sure if that's...
  17. R

    Why Can I Assume Constant Velocity for a Falling Loop in a Magnetic Field?

    Homework Statement This is a question regarding Problem 7.11 in Griffiths Electromagnetism book, which considers a falling square loop of aluminum through a uniform magnetic field pointing into the page with only part of the loop in the field at t=0 (see picture below). To solve this...
  18. M

    Polarization-electric field hysteresis loop of a piezoelectric film.

    Hello, I have piezoelectric film. I want to characterize ferroectricity. which exact equipment and circuit are used for measuring polarization-electric field hysteresis loop. Thanks
  19. moenste

    Ball speed at the top of the loop

    Homework Statement A compressed spring is used to propel a ball-bearing along a track which contains a circular loop of radius 0.10 m in a vertical plane. The spring obeys Hooke's law and requires a force of 0.20 N to compress it to 1.00 mm. (a) The spring is compressed by 30 mm. Calculate...
  20. A

    Moving a loop within a changing magnetic field

    Hello, Short description: In my country's physics olympics, if a loop of wire is moved in a changing magnetic field, the time derivative of the area (while calculating emf with lenz law) is the velocity of the loop (as if we're taking the time derivative of the AREA SWEPT). This has became an...
  21. A

    Magnetic field due to a current carrying loop

    Homework Statement The actual question was to somehow derive the expression for a magnetic field at the center of a current carrying loop. Homework Equations The Biot-Savart's law equation dB = (mu/4π)*(i dl x r)/r^3 (I'm not actually good at typing in the equations, so please just forgive...
  22. G

    Calculating Induced EMF in a Bent Loop with Changing Magnetic Field

    Homework Statement The figure below shows a closed loop of wire that consists of a pair of equal semicircles, of radius 7.0 cm, lying in mutually perpendicular planes. The loop was formed by folding a flat circular loop along a diameter until the two halves became perpendicular to each other...
  23. J

    I Loop Quantum Gravity and Virtual Particles....

    Hi all, Following up on another post - for a layman, can someone describe the status of virtual particles in Loop Quantum Gravity models? Since LQG avoid UV divergences, and has a different structure from field-based theories, are virtual particles still talked about? (in the context of closed...
  24. KonaGorrila

    MATLAB How to get the last variable of a for loop in MATLAB

    Aloha guys, I am just having trouble getting MatLab to output only the last variable of my "for loop." If anyone can help all I am looking for is an example of notation. p.s. I have done this before just not in a while and will continue to look through my old scripts and functions. just not in...
  25. Marcin H

    Loop Current Method/Loop Analysis Confusion

    Homework Statement Homework Equations Loob Analysis V=IR The Attempt at a Solution So I think I have the right equation here, but I am a bit confused on some parts. I am not too sure why i2=i1-ix. The way my professor explains it doesn't make much sense. Also (TYPO) in the second...
  26. K

    I Can Loop Quntuam gravity be merged with Asymptotic safety

    can Loop Quntuam gravity be merged with Asymptotic safety scenario in gravity into a single theory of QG, one that has both concepts ? i.e if you start with Loop Quntuam gravity in 4D, can you show that it is also implies Asymptotic safety scenario in gravity in 4D? are there any papers...
  27. T

    Does a Magnetic Moment μ exist for any closed current loop?

    I'm asking the above question as I imagined a current loop made out of a curving wire that cannot fit into a flat plane. Where does the direction of μ point then? Also, is there only one μ value for any current loop, independent of the chosen axis of tilting? Or can a current loop have...
  28. wolram

    B Why Quantum loop or string theory

    I was wondering why Quantum loop theory is still being followed FAIK it does not predict any thing yet, the same for string theory which seems to have lost its predictability, if these theories fail being tested where will we be It seems to me like super symmetry is the theory that every one...
  29. E

    MATLAB What is wrong with this WHILE loop?

    Here is my code: while a ~= 3 || b <= 1; a = a - 1; (other expressions); end; For this code, the 'while' loop should stop when 'a' reaches 3, however it does not, even though 'a' starts with a higher value than 3. The 'other expressions' part are calculations that manipulate 'b', the only...
  30. C

    Solving a Physics Problem: Find Velocity of Block at Bottom of Loop

    Homework Statement This is for my ap physics summer work and is giving me some trouble and could use any help A small block, with a mass of 250 g, starts from restart the top of the apparatus shown above. It then slides without friction down the incline, around the loop then onto the final...
  31. C

    Understanding the Use of '==' in While Loops: Explanation and Example

    Homework Statement for teh circled part , why there's again =='y' ? i didnt see the variable 'y' anywhere other than the circled part ...What does it mean ? Homework EquationsThe Attempt at a Solution Is the code wrong ?
  32. ShayanJ

    A Vertex, Propagator and Loop counting

    I'm reading these lecture notes but there is something I don't understand. In page 15, it starts to consider vacuum diagrams of various orders and tries to associated a factor to them according to the rule: ## diagram \sim (\frac \lambda N)^p(\frac N \lambda)^v N^l=\lambda^{p-v} N^{l+v-p}##...
  33. M

    Determining the Poynting Vector for Loop Antennas

    So I came across the following image (from Wikipedia) where the electric and magnetic field lines are depicted for a dipole antenna. From the field lines, it is possible to determine the direction of the poynting vector, using the right-hand rule. If all possible combinations of poynting...
  34. Larry Gopnik

    MATLAB Updating variables as they go through a loop

    Hi all, This might be a simple question but I cannot seem to find any solution online I'm currently building a MatLab code for my project which involves in the ageing of certain artefacts and paintings, I've got most of it built but can't solve the simplest of problems of the start of the...
  35. M

    Determining the force on a loop cause by an infinite line

    Homework Statement An infinitely long line of current $I_1=6[A]$ is following along the positive z-axis in the direction of +$\hat{a_z}$. Another current is following a triangular loop counter clockwise from the points A(0,2,2), B(0,6,2) and C(0,6,6). Homework Equations To start I applied...
  36. J

    Circular loop in magnetic field

    Homework Statement A circular single loop of wire with a diameter of 20.0 cm lies in the plane of the paper in a region of space that contains a 1.75 T magnetic field pointing out of the paper. a) Determine the magnetic flux through this loop. b) If the diameter of the loop changes from 20.0...
  37. M

    Mathematica "Do" loop with "If" conditional

    Hi, I have a function defined by: F[x_,y_,z_]:=3 x+y-2Y[z] where Y[z_]:=3/z I'd like to run Do loop to calculate the value of this function for specific regions of x,y,z. I can use: Do[F[x,y,z],{x,1,2,1},{y,-2,-1,1},{z,3,5,1}], But I have two questions here: First: How to save the output...
  38. wrobel

    A Finding Equilibriums on a Cone with a Chain Loop

    Imagine a right circular cone with smooth surface. The cone is stated such that its axis is parallel to the standard gravitational field g. And you have a piece a thin homogeneous chain. Then you connect the tips of the chain to obtain a loop. You put this loop on the cone: It is clear...
  39. J

    Does AC form a closed loop circuit?

    Some say that AC should form a closed loop circuit for electricity utilization but is there really an loop from the Power station(hot wire) to the Ground(neutral) and then from Ground to power station so that it forms a loop?
  40. P

    Find the electrostatic potential above loop of charge Q?

    Homework Statement An electric charge Q is uniformly distributed along a thin circular wire situated in the z = 0 plane at x2 + y2 = R2 . Determine the electrostatic potential at the point (0, 0, D). Homework EquationsThe Attempt at a Solution I figured the only components that mattered would...
  41. Biker

    Magnetic fields in circular loop

    If I have a some a wire and I took part of it and created a circle. If I want to calculate the strength of the magnetic field at the center of it. I should just use the magnetic field equation for the circular loop, shouldn't I? ## B = \frac{U_o N I}{2R} ## and I shouldn't care about the...
  42. T

    MHB PrintShampooInstructions(): Function for Looping Cycles

    Write a function PrintShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." numCycles times, where N is the cycle number, followed by "Done.". End with a...
  43. S

    B Using center of mass for loop de loop

    A quick question, I remember my professor said to use the center of mass for solving the classic loop de loop problem. For example, he wanted us to use the distance from the surface of the loop to the center of the object (instead of just from the loop to the surface of the block) for the height...
  44. S

    Magnetic field change for induced current

    Homework Statement A uniform magnetic field is perpendicular to the plane of a circular loop of diameter 10 cm formed from wire of diameter 2.5 mm and resistivity 8.5×10-8 Ω·m. At what rate must the magnitude of the magnetic field change to induce a 10 A current in the loop? Homework Equations...
  45. S

    Magnetic field strength for circular loop

    When deriving the magnetic field strength due to a circular loop at some distance away from it's center (using Biot-Savart's law), why is the angle between ds and r 90 degrees? This is a youtube video with the derivation, see 5:55
  46. gsmtiger18

    Displacement current and magnetic flux through a wire loop

    Homework Statement A long straight wire has a line charge, λ that varies in time according to: λ = λ0e(-βt). A square loop of dimension, a, is adjacent to the wire (at a distance a away from the wire). Calculate expressions for the displacement current at the center of the wire loop and the...
  47. S

    Biot-Savart's Law for cylindrical conductor

    Homework Statement The figure shows a cross section across a diameter of a long cylindrical conductor of radius a = 2.92 cm carrying uniform current 151 A. What is the magnitude of the current's magnetic field at the center of the conductor? Homework Equations Biot-Savart's Law The Attempt...
  48. A

    EMF about a loop moving toward a wire with current

    Homework Statement A picture of a related problem is attached below. My problem is the same, except that v is toward the wire, not away from it. I, r, v, b and a are given. "Find the emf about the loop without assuming that B changes at any point" My problem is that this question isn't...
  49. S

    Radiation from a Square Loop of Current

    It is well known that a circular loop of steady current does not radiate, even though each individual charge is undergoing centripetal acceleration. How about a loop of steady current that is shaped in a square? Does this structure radiate?
Back
Top