What is Loop: Definition and 1000 Discussions

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. icesalmon

    Stability of an open loop controller

    Given the following Controller equation Gol(s) and Plant equation Dol(s) for an open loop system the transfer function can be expressed as a ratio of polynomials where: Gol(s) = b(s)/a(s)and Dol = c(s)/d(s). For the open loop system the transfer function Tol = Gol(s)Dol(s) = b(s)c(s)/a(s)d(s)...
  2. I

    Bernoulli equation in a closed loop system

    P1 = 5psi P2= 15psi , Z2-Z1 = 0, i assume V2 =V1 because velocity of water is the same everywhere in a pipe of constant diameter is H friction = H pump = 10psi ? Please help
  3. R

    Orientation of the Ferroelectric Hysteresis Loop -- Why is it different now?

    (Edited with suggestions from Berkeman) After reading the original 1930 paper by Sawyer and Tower (link to original paper here), I noticed that their hysteresis loops are mirrored around the y-axis from many of the ferroelectric hysteresis loops reported today ( see FE examples here, here...
  4. W

    I Loop Quantum Cosmology: Explained in Layman's Terms

    I have heard that one of the of the founders of LQC, Martin Bojowald is now rather critical of it. And sample of his criticism can be found here: https://arxiv.org/pdf/1810.00238.pdf I would be really grateful if someone could explain this in more laymen language . Any thoughts on the issues...
  5. D

    How to find the magnetic field and magnetic force due to a solenoid loop

    I'm not so sure how to begin with this problem. I was thinking of usign superposition. I think that the field on the conductor due to the parallel segments of the coil is zero, since Ampere's Law tells us that the field outside the solenoid is zero, right? For the perpendicular segments, I used...
  6. Boltzman Oscillation

    Engineering How can I find the open loop voltage gain of this opamp?

    The open loop voltage gain is given as : $$ u(s) = \frac{u_o}{1+\frac{s}{w_o}} = \frac{100}{1 + \frac{s}{40}}$$ Where u_o is the d.c. voltage gain and w_o is the pole. The op amp that is given is: And I am told to use the non ideal op amp model as follows: Well my guess is that I can find the...
  7. RicardoMP

    A Trace of a product of Dirac Matrices in a Fermion loop

    I'm working out the quark loop diagram and I've drawn it as follows: where the greek letters are the Lorentz and Dirac indices for the gluon and quark respectively and the other letters are color indices. For this diagram I've written...
  8. peace

    Mutual inductance between a very long, straight wire and a Semicircular loop

    I think I have to assume a point like P in the semicircle. The point in terms of r and θ: P (r,θ). So the magnetic field at that point: B = µI/2π(R+rcosθ) . So the magnetic flux: Φ = ∫B.dA= µI/2π ∫∫ rdrdθ / R+rcosθ . Is this the correct solution?
  9. K

    What is causing the strange ground current loop in this motor circuit?

    In the attached picture, I’ve drawn a crude schematic of the motor circuit. It is fed from a switchgear feeding 3 total motors. The feed contains 2 parallel conductors on each phase and ground. The equipment ground reads 12a going back to the switchgear, 6a per conductor. From the starter to...
  10. DaveC426913

    Using a While loop to converge on a value

    My brain is misfiring. I have a start value (integer) that I perform an operation on that will iteratively cause it to converge on some (unknown) integer value. I stop the iteration when the new value is the same as the old one (i.e. it has stopped changing). Until that happens, I keep...
  11. S

    Python: printing every other input using a for loop

    I want my output to read only the integers. Here's my attempt: number = int(input()) for i in range(2, number+1, 2): print(input())
  12. physics_domme

    A Loop Corrections: A Layman's Explanation

    I am currently a senior physics major working on my undergrad, and I just began a new research position at my school, and am teaching myself particle physics because the group I am working with is looking to expand the SM, and my project specifically is to implement Monte Carlo simulations of...
  13. A

    How to calculate a pressure drop in a branch of a loop ring pipe

    Good day I'm trying to calculate the pressure drop in each branch of the following loop ring system I used the following formula to find the pressure drop but i seems that it worked only for the ring, and the branch #2 ( the branch in the middle), the solution given by the professor show...
  14. A

    Small bead - Circular loop Problem

    Homework Statement: A small bead is fixed on a circular loop of radius R as shown in the figure below. The loop is rotating about YY axis with constant angular acceleration ‘α’. The loop starts from rest, then, the bead is in circular motion, then acceleration of the bead at instant ‘t’...
  15. S

    I Find CTCs in Kerr Metric: Visualizing Spacetime Geometry

    I have been trying to study some differential geometry and some stuff about manifolds in my efforts to learn about closed timelike curves, but thus far it has been a lot of set theory and I have yet to see the "geometry" aspect. What I really want to know is this: We know how some spacetimes...
  16. snatchingthepi

    Where does this term come from? (pulling a wire loop through a B-field)

    I can't for whatever reason figure out where the sin(theta) term is coming from in the attached picture of page 306 of Griffiths' 4th edition EM text. The paragraph says it comes from the dot product, but I just don't see where it's coming from.
  17. F

    I Why is hysteresis loss proportional to area hysteresis loop ?

    Why does hysteresis loss cause heat and why the heat proportional the area of hysteresis loop?
  18. P

    Circular loop of wire is concentric with a solenoid

    Question: In Figure (a), a circular loop of wire is concentric with a solenoid and lies in a plane perpendicular to the solenoid's central axis.The loop has radius 6.13 cm. The solenoid has radius 2.07 cm, consists of 8230 turns/m, and has a current i_sol varying with time t as given in Figure...
  19. F

    What is the maximum current in a superconductor loop?

    If we put an emf equal constant onto a superconductor loop(we consider the resister of emf equal zero), then what is the maximum of current in the loop?
  20. S

    Find the speed of a copper loop falling in a magnetic field

    Hi all, so I had this problem and on the exam and I got a solution but I had an mass-term in there which wasn't given. I used Farraday's Law of Induction to get the Voltage induced. Then I used ##rho* \frac{A}{4a} ## for the resistance and divided the Voltage by that to get the current. I then...
  21. B

    PID loop with a different command and feedback units / types

    I have a laser and I am adjusting it's position using a motor, and I am reading the laser light intensity at the top and bottom using a sensor. then I divide the top from the bottom and the goal is to get around 0.97%. This is called delta, if delta is too high, you move the motor lower and if...
  22. TOUHID11

    Calculate Induced EMF in Circular Loop: Cylindrical Coordinates

    In order to calculate for the curl of the induced electric field for a loop moving in a uniform magnetic field, and using the cylindrical coordinate system for a curl, it's my understanding that since the B field is in the 𝑧̂ direction, then so is the partial time derivative of B, and therefore...
  23. S

    Force on a copper loop entering into a magnetic Field B with speed v

    Hi, second problem in one evening, I'm sorry! But I'm also not quite sure if I did this one right. I had thought I need lenz's law but there is no current before entering the field so I just use the induced Voltage? My approach: ## V = \frac {B*A}{t} ## ## IR = \frac {B*A}{t} ## and ## A = v*t...
  24. J

    Roller Coaster Loop Problem

    So, we know that at the bottom of the loop, the car will have a normal force pointing upward and gravity pointing down. However, I have discovered that the normal force is apparently greater than the force due to gravity. Basically N = F(g) + ? What is this other force?
  25. T

    Flow Chart For a 'for' Loop In Python

    I am currently learning python and to understand the my code fully and to make notes I am trying to draw flow charts to compliment my code. My issue is I am not sure what to put in the flow charts or really how to represent them as clearly as possible. I have done a google search but I am bit...
  26. A

    Conductive loop that is contracting in a magnetic field

    $$V = \int \left(\vec{v} \times \vec{B}\right) \bullet \vec{dl} - \int _S \frac{\vec{dB}}{dt} \bullet \vec{ds}$$ From the statement I know that: B⊥v, (B x v) // dl and B // ds. $$V = \int vBdl - \oint _S \frac{dB}{dt} ds$$ v is the speed with which all the segments dl are aproximating to the...
  27. M

    Mathematica Updating a Vector in a For Loop: Troubleshooting Tips

    I am trying to update a vector. I have tried this but it's not working. Any ideas? \[Lambda] = {1, 2} For[\[CapitalLambda] = 0.1, \[CapitalLambda] <= 0.2, \[CapitalLambda] += 0.1, \[Lambda] = Catenate[{\[Lambda], {\[CapitalLambda]}}] // Print]
  28. rbergs215

    Forces in a loop on a rolling body

    So looking at the solution, FBD for A makes sense: Normal points inwards, gravity and friction oppose each other, with friction pointing up. B confuses me: the solution says there is only Normal and gravity pointing downwards, but if "the sphere rolls without slipping during the entire motion"...
  29. Q

    A One Loop Correction to a 4 pt. function in 3 dimensions

    If I have a Lagrangian of the form \mathcal{L}=-\frac{1}{2} (\partial \phi)^2 - \frac{1}{2} m^2 \phi^2 - \frac{\lambda}{3!} \phi^6, in 3 dimensions, what is the one-loop correction to the 4-point function? Am I correct in thinking that the following Feynman diagram is the representation of the...
  30. N

    Magnetic force on a wire due to a loop

    I just need to confirm my intuition that the magnetic force on the wire carrying I2 is 0. Basis for my intuition: * Right above the center of the loop carrying I1, the magnetic field lines are in exactly the same direction as the piece of wire carrying I2, so [a] x [B1] = 0. (photo from...
  31. J

    Direction of current in smaller loop on the left and on the right

    Lets say the current in the larger loop is counterclockwise. Then it doesn't matter if the smaller loop is to the right or to the left of the larger one, the induced current in it will always be clockwise. The magnetic field due to the smaller loop current always points in the negative...
  32. J

    Loop falling in a magnetic field

    (a) Let's say the loop has fallen ##y## from its initial position. Then the magnetic flux is ##B_{0}w(h-y)## and the induced voltage is ##\mathcal{E}=B_{0}wdy/dt##. Since this voltage is positive, the current flows clockwise. (b) ##I=\frac{\mathcal{E}}{R}=\frac{B_{0}wv}{R}## (c) The force on...
  33. S

    Torque on circular current loop

    So I'm having a little trouble getting to the solution to this question so here's my attempt at a solution and I'm not seeing the issue with it 1. I calculated the B-field due to the long wire (approximating the distance from the dipole to be equivalent to that in the centre since r>d) B=...
  34. F

    Calculating Centripetal Acceleration in a Vertical Loop

    $$mg(0.45) = mg(R + R \cdot cos(\frac{π}{3})) + \frac{1}{2}mv^2$$ $$v^2 = g(0.9 - 3R)$$ The centripetal acceleration during the "flying through air" will be given by gravity $$mg \cdot cos(\frac{\pi}{3}) = \frac{mv^2}{r}$$ $$R = \frac{1.8}{5}$$ But my book says $$ R = \frac{1}{5}$$
  35. S

    How Does Varley Loop Testing Calculate Fault Distance in Cables?

    Homework Statement A Varley Bridge is connected to a faulty three-core copper cable by two identical copper leads of resistance Rl. (a) Show that for the initial reading (connection to earth); 2Rx = 2Rc – Ri ........ 1 where Rc is the resistance of the cable core Ri is the initial reading...
  36. mmest

    Magnetic Field required to hold a loop in static equilibrium

    Homework Statement There is a square loop with mass of 4.0 kg and side length 4.5 m that is tilted upwards from the ground at a 25 degree angle with one side resting on the surface. The loop is a conductor that has 25 A of current going through it. The question asks to find the strength a...
  37. R

    Voltage around a loop, half inside a capacitor and half outside

    Homework Statement This is not a homework problem, I'm working through griffiths Electrodynamics on my own. Homework Equations when there is an emf source, since electrosatic fields integrate to zero around a loop The Attempt at a Solution The solution claims that since the integral of f...
  38. OmarbinNaeem

    B EMF Induction in a Loop of Wire - Does It Work?

    an emf can be induced in a coil if the magnetic flux through the coil is changed my question is does all magnetic field induces an emf in a loop of wire?
  39. S

    I "Breaking the loop" in Casimir force?

    The Casimir force involves a complicated interaction between electrons in one plate, the electromagnetic field in the gap, and the electrons in the other plate. In this process, it makes no sense to talk of cause and effect, since all entities affect each other all the time. Would it make sense...
  40. A

    Magnetic field on a loop due to another loop

    In the attached picture, the outer wire is carrying a current I(t), and it's asked to find the induced EMF in the inner loop. Now I have indeed calculated the B-field along the z-axis due to the outer loop. My lecturer then puts z=0 into that expression and then multiplied it with the area of...
  41. O

    Defining a BH loop in Ansys Maxwell?

    Does anyone have an idea how to insert a BH loop like the one I have attached in Ansys Maxwell and not get an error like in the other picture which is also attached? I have seen it multiple times in different texts but can't define one myself without getting this annoying error. Also the...
  42. S

    What happens to the current in a loop when a magnet approaches

    Homework Statement There is a magnet that approaches the loop as in the figure. There is already a counterclockwise current in the loop. What happens to the current in the loop? Is my reasoning correct? Homework Equations The Attempt at a Solution Since the flux is increasing in the loop...
  43. kroni

    A Simulating Quantum Loop Theory: Can S-Knots Be Represented Numerically?

    Hello, I am contacting you because I would like to know if there is a way to simulate quantum loop theory. Indeed, the S-Knots are much more complex objects than graphs because between the points there is a curve that can be knotted. S-Knots are graph embeddings in 3D and I do not see how such...
  44. Luxucs

    Faraday's Law with Zero Resistance Current Loop

    Hi there, I was recently helping a friend of mine with a fairly standard electromagnetic induction problem (a basic sketch of the set-up is attached) where we have a current loop with resistance ##R## moving through a magnetic dipole and had to roughly sketch out the current induced in the loop...
  45. J

    Speed at the top of an elliptical roller coaster loop

    Homework Statement This isn't really a homework but a project I'm doing that's due soon. In our multivariable calculus class, we're creating a 3D roller coaster, and I need to explain the physics behind the roller coasters. For a roller coaster loop, if it were perfectly circular, we would...
  46. O

    How to define a hysteresis loop in ANSYS MAXWELL?

    I am trying to simulate an electric motor in ansys maxwell software, but I can't define the whole loop in four quadrants for the material used in the rotor however it is essential to do this since the motor is of hysteresis type and works on the principle of working point moving all around the...
  47. K

    Calculating controller gain in a feedback loop

    Homework Statement FIGURE 3 shows the block biagram of the control of an electric heating system. The heater is driven from a voltage-controlled power supple, the voltage V1 being derived from a potentiometer. The output temperature, θo is subject to distrubances, θd, because of changes in...
  48. FreeForAll

    Driving an RC car in a vertical loop, What formula to use?

    I once drove my RC car in a vertical loop in a concrete drain pipe. If you know the diameter of the pipe, and the weight of the vehicle, what is the formula used to determine the minimum speed required for it to complete the loop?
Back
Top