II. Conservation of energy (2)

As you may have noted, I got sidetracked: I am now re-visiting the Principle of Least Action, Lagrangian and Hamiltonian mechanics, and what have you. My post on that on my physics blog was, effectively, highly unsatisfactory: it explained the how, but not the why. Let’s copy those two illustrations from Feynman’s Lecture on the Principle of Least Action once more:

We have an actual path x(t) and some other path x(t) = x(t) + η(t). The actual path will minimize the value of the following integral:action integral

We recognize the Lagrangian L = KE − PE = T − V here. The value of this integral is referred to as the action. To be specific, we can write this integral as:

action integral 2

The math behind the Principle of Least Action can then be explained as follows. The η(t) function is associated with a slightly different path and, therefore, with a value for S that is, supposedly, slightly higher – or different, at least – than the value S, i.e. the value of the action integral for the actual path x(t). The difference between and S is referred to as the variation in S, and is written as δS. Of course, by now, you know that you should not confuse this δ symbol with the d or ∂ symbol that we use to denote a (partial) differential: δS is a change in a functional as a result of an infinitesimally small change in a path (or trajectory), while ∂would be some change in a function (a dependent variable) because of an infinitesimally small change in (one of) the independent variable(s). Having said that, the mathematical argument for minimizing (or maximizing) a function and a functional is remarkably similar. We can expand a function as follows:Taylor expansion of a function

We have first, second and higher order corrections to f(a) here. Also, if a is, effectively, some minimum, then we know the first order correction will be equal to zero, because the first order derivative f’(a) = df(a)/dx will be zero. Just to make sure, let me rephrase this: if a is a minimum, then the differential df(x) will be approximately equal to zero. We write:

df(x) = f(x) – f(a) ≈ f’(adx = f’(ah = 0

Now, Feynman does the substitution and, after some re-arranging (please do check it out), he gets the following first-order approximation for δS:

action integral 3

Just to make sure: V’(x) is the (first) derivative of the potential energy with respect to x. Now, we know that this thing needs to be equal to zero if, and only if, x(t) is, effectively, the true path. Feynman then shows that, for this integral to be zero, the following condition must be satisfied (the math is somewhat less straightforward, but you can check it):


This looks complicated but it isn’t. It’s just Newton’s Law: F = m·a. 🙂

[In case you wonder why V’(x) = F, check out my post on potential energy in which I show, more generally (in three-dimensional space, that is), that the x-, y- and z-component of the force is equal to F= – ∂V/∂x, F= – ∂V/∂y, and F= – ∂V/∂z respectively or, using the grad (gradient) operator, F = –∇V.]

So… Well… This is all OK, but the fundamental question remains: what is this Principle of Least Action? What is the meaning of the integrand? You may or may not remember the calculations we did for a harmonic oscillator, depicted below. The total energy here remains constant: E = T + V = constant, and dE/dt = 0.


  1. The red curve represents kinetic energy (T) as a function of the displacement x: T is zero at the turning points, and reaches a maximum at the x = 0 point.
  2. The blue curve is potential energy (V): unlike T, V reaches a maximum at the turning points, and is zero at the x = 0 point. In short, it’s the mirror image of the red curve.
  3. The Lagrangian is the green graph: L = T – V. Hence, L reaches a minimum at the turning points, and a maximum at the x = 0 point.

What’s the graph for our object going up and down as we throw it in the air and see how it comes down? To simplify the calculations, we’ll say the height at which we launch our particle is equal to x = 0. For convenience, this should also be our = t1 = 0 point. Let’s take the example of a 5 kg cannon ball which is fired up into the air and reaches a height of 50 m before it starts falling down. We can easily calculate the kinetic energy it must have had when it was fired up: its potential energy at a height of 50 m was (approximately) equal to V = m·g·x ≈ (5 kg)·(9.8 m/s2)·(50 m) = [5 N/m/s2]·(9.8 m/s2)·(50 m) = 2450 J. To reach that height, its initial velocity must have been equal to 31.3 m/s. Hence, its velocity over the trajectory as a function of time will be equal to = 31.3 m/s − g·t.

The graph below shows the shape of the T, V, T−V and T+V curves as a function of time respectively. They look the same as the graphs for the harmonic oscillator, but we need to remind ourselves we plotted the graphs for the oscillator as functions of t, not of x. Regardless, the point to note is that the total energy of our 5 kg cannon ball remains constant as well: E = T + V = constant, and dE/dt = 0. [You should check the formulas. The kinetic energy is given by the T = m·v2/2 = 5·(31.3 m/s − 9.8·t)2/2 formula, but if you’d want to calculate the potential energy, you need to calculate the height as a function of time. That can be done by solving an integral: x(t) = ∫0v(t)dt. However, we can also simply assume the kinetic energy becomes potential energy – and vice versa – over the trajectory, so we should get the same result when plotting V = 2450 − T. [We do. You should double-check it, though.]graph

So what is that mysterious quantity L = T – V, as a function of time or – in the case of our oscillator – as a function of the displacement? Why is L = T – V the integrand in our so-called action integral? Perhaps we can get somewhat wiser if we break it up:

0t (T − V) dt = ∫0t T dt − ∫0t V dt

It’s obvious the Hamiltonian H = T + V quantity is of no use here: kinetic and potential energy always add up to a constant, so there is no variation in it. Look at the difference between the true and a nearby path once again (illustration below): at each point in time (t), the height (x) will be different (except at the start and at the end, and two other points in-between). Hence, the potential energy is slightly different (almost) everywhere: sometimes higher, sometimes lower. For the object to arrive at those heights, it would have to modulate its velocity accordingly. Hence, its velocity and, therefore, its kinetic energy will also be different. virtual displacement

Feynman explains Nature’s optimization logic in a pretty neat way – first assuming there is no force (like gravity) and, therefore, no potential energy. In that case, our object would have to move at uniform velocity – so that’s a straight line on the graph – so so as to minimize the action integral which, in this particular case, reduces to a kinetic energy integral. Now, if there is a force – because of the gravitational field in this case – then our object will first rise faster first and then slow down. As Feynman puts it: “That is because there is also the potential energy, and we must have the least difference of kinetic and potential energy on the average. Because the potential energy rises as we go up in space, we will get a lower difference if we can get as soon as possible up to where there is a high potential energy. Then we can take that potential away from the kinetic energy and get a lower average. So it is better to take a path which goes up and gets a lot of negative stuff from the potential energy.” He illustrates it as follows:graph 4

But, again, the question remains: what is the action, really? It’s an integral, so it’s the surface under the T − V curve between t1 and t2. In our example of the cannon ball going up and down, the graph suggests that the number that we’ll get will be negative, because the area under the t-axis should be counted as negative.

Hmm… I am thinking of what I wrote about the action concept in another post of mine: action can be thought of as energy being available over a specific amount of time. The ∫0t T dt integral obviously reflects such product, but why the minus sign for the − ∫0t V dt? The best answer I can give is that we should think of it as energy being taken away over the same time interval. Now, Feynman talks about averages and, yes, we know that the value of ∫0t T dt will be equal to the average kinetic energy (as measured over the interval) times the interval itself. What average? Well… The average, so that’s the arithmetic mean for a function. That’s how it’s defined, remember? In case you forget, the illustration below will remind you of how it works:average value

Hence, minimizing the value of that action integral amounts to minimizing the difference between the average kinetic and the average potential energy. Of course, we know that we can add any amount to the potential energy because we re-define the reference point for which V = 0, but that doesn’t change the calculus. It’s reflected in the fact that, when solving an integral, we will always get a whole family of primitive functions which differ by some arbitrary constant only.  Let’s look at the graphs once more (below). The cannon ball is fired upwards with some initial velocity and, hence, some initial kinetic energy. Now, we can think of the kinetic energy being depleted over time, as it is used to bring our cannon ball higher up in the air, thereby increasing its potential energy. The value of the ∫0t TKE dt integral over the first half of the time interval is the surface under the KE curve. So that’s added. In the meanwhile, the minus sign in front of the − ∫0t PE dt integral implies a certain amount of energy is taken away during some time. So that subtracts from the total amount of action that is, apparently, available here.

action graph

What’s the take-away here? Our firing a cannon ball in the air surely comes with a lot of action but, at the same time, we know the true trajectory will minimize that action. So… Well… That’s it, really. I hope the Principle of Least Action makes somewhat more sense to you now.

Let me wrap this up with a final note. Throughout our discussion here, we’ve focused on a fixed time interval [t1t2]. This time interval is not random: it comes with the mass of our object, its initial velocity, and the force (gravity). Likewise, the interval in space is not random either. We know when and where our cannon ball is going to be over its trajectory. In fact, that is a tautology: we know its trajectory in spacetime. Hence, we can think of swapping the x– and t-axes and, perhaps, some alternative formulation of the Principle of Least Action in terms of variations in time rather than in space, right? Let’s start with swapping the x– and t-axes for a similar trajectory (below).dual problem

Of course, we have a rather obvious mathematical problem here: the curve on the right cannot be associated with a well-behaved mathematical function: several values of are associated with two values of t, rather than just one. That’s got to do with the unique direction of time. As I wrote in one of my more philosophical posts on physical dimensions, we need to ensure a trajectory is a well-defined function, which implies we should have one value for x for every value of t, but not necessarily one value of for every x, except where we allow our particle to travel back in time which… Well… We shouldn’t allow that. Hence, the concept of a well-defined function gives us a nice explanation for the unique direction of time without having to invoke entropy or other macro-concepts. 🙂

Now, having said, it’s obvious we could break up that curve, so then we’d have two separate well-behaved curves, so… Yes. Perhaps there is some alternative formulation of the Principle of Least Action. I quickly googled but I only get rather abstruse mathematical excursions on Hamilton’s versus Maupertus’ Principle (the article on the Principle of Least Action on Scholarpedia is a fine example). Hamilton’s Principle is the Principle of Least Action as explained above. Maupertus’ Principle is… Well… I need to have a look at it. 🙂

Lagrangian mechanics

Let us now show how we can link the variational principle to Lagrangian mechanics, as we’re sufficiently armed to do that now. First, we should, perhaps, remind ourselves of why we need such rather complicated approaches to solving problems. The answer: that’s because the problems are complicated. In fact, even seemingly simple problems can be quite complicated. Two examples of such seemingly problems are illustrated below. On the left, we have a bead that is sliding on a frictionless wire, and on the right, we have a mass on a pendulum.

Calculating the position r = (x, y) of the bead, or the mass on that pendulum, in terms of the classical Cartesian coordinates x and y as measured from some chosen origin, can be really tricky because of the constraint: the bead has to move on a wire, and the mass on the pendulum has to follow some circular trajectory. It can be done by the introduction of a constraint force C, as shown above: in the case of the bead on the wire, C will keep the bead on the wire, and in the case of the pendulum, C will ensure moves on the circle, while N is just the gravitational force ensuring the bead, and the mass m, effectively moves. Just try to find x(t) and y(t) as a function of time and the various parameters of the problem (such as L and m). Not easy. That’s where these generalized coordinates, which we will now write as = (q1, q2, … , qN), come in handy: just click the (Wikipedia) link and you’ll see how one single generalized coordinate – the θ angle – can be used to facilitate the calculations for the pendulum problem. Note that we have only one coordinate because we have only degree of freedom in this system (= 1).

So we’re usually looking for solutions for q q(t) = (q1(t), q2(t), … , qN(t)). In my previous post, I showed how these generalized coordinates can be used to track multiple particles. In general, if we have particles, and constraints, then will be equal to = 3·n − k in three-dimensional space and = 2·n − k in two-dimensional space. Now, as a function, our q q(t) will effectively describe some trajectory in… Well… The N-dimensional generalized coordinate space, which is usually referred to as the configuration space. Why? Well… It sort of provides the context for describing the system we’re looking at, right?

Let us now get back to our action integral:action integralThe kinetic energy (KE) depends on the velocities of our particles and, therefore, on the time derivatives of the qi(t) functions. In contrast, the potential energy (PE) depends on position only, so that’s the qi(t) functions themselves. Finally, because we allow the constraints to change over time (think of our wire changing shape, for example), we will also have time itself as an argument in the integrand of this integral, which we denote by = KE − PE (we wrote is as L = T − V in our posts, but it’s the same). The is not some length, obviously: it’s the (in)famous Lagrangian.

You’ll also remember we talked about the variation in S, which is written as δS. At this point, you should also remind yourself of what this actually means. It’s not the same as the d or ∂ we use to denote a (partial) differential: δS is a change in a functional as a result of an infinitesimally small change in a trajectory (think of our qi(t) functions), while ∂would be some change in a function (a dependent variable) because of an infinitesimally small change in (one of) the independent variable(s). But… Well… By now you’re supposed to understand that.

Now, you’re also supposed to understand that we can write δS as a series of terms. These terms give us the corrections of the first, second, third, … etcetera order and you’ll remember we said the first-order term for δhad to be zero if our q q(t) solution is to describe the actual trajectory. We can now re-write our action formula as follows:action formulaAnd, combining it with the δS = 0 requirement (which you should actually read as: the first-order term of δS is equal to zero), we can write the Principle of Least Action as:action conditionSo… Well… The Scholarpedia site says the following: “Using standard calculus of variations techniques, one can carry out the first-order variation of the action, set the result to zero, and thereby derive differential equations for the true trajectory, called the Euler-Lagrange equations.” Now, that sounds simple but, unfortunately, the derivation itself is not so simple. I googled a bit, and I think Wolfram’s MathWorld site offers the best and most concise explanation of how it’s actually done. I copied it below, but I am pretty sure you will not want to get into the nitty-gritty of it. 🙂derivation

So… What about Hamiltonian mechanics?

Hamiltonian mechanics

Ouff ! Do you really want to know? The basics are pretty similar. The Hamiltonian approach is, basically, a re-formulation of the Lagrangian approach to the problems on hand (i.e. the analysis of complicated mechanical systems). But I’ll refer you to the Wikipedia article on it. If you understand all of the above, you may understand some of that article. 🙂 To be frank, I think you will shake your head if I tell you that the Hamiltonian (H) is just a Legendre transformation of the Lagrangian (L). However, the following info may be somewhat useful to know:

Hamiltonian mechanics aims to replace the generalized velocity variables with generalized momentum variables, also known as conjugate momenta. By doing so, it is possible to handle certain systems, such as aspects of quantum mechanics, that would otherwise be even more complicated.

Hmm… So if we really want to get into quantum mechanics, we’ll probably have to understand how this works. Let’s not worry about it now. Let’s wait till we’re at the exercises for Volume III of Feynman’s Lectures. 🙂

Post scriptum: When explaining the Principle of Least Action, Feynman talks a lot about average energies, but that’s kinda tricky, and it’s easy to make mistakes. So let me try a few things here. The situation is the same: we have some object – the usual 5 kg cannon ball, I guess – that goes up in the air, and then comes back down because of… Well… Gravity. Hence, we have a force field and, therefore, some potential which gives our object some potential energy. So, yes, the same situation as depicted (once more) below.

We know the actual trajectory. When everything is said and done, Newton’s Force Law (F = m·a) gives it to us, at each and every point in spacetime. [If you google a bit, you’ll find articles about teleological interpretations of the Principle of Least Action but… Well… Don’t waste your time with them.] So Feynman writes the actual trajectory as x(t) = x(t) + η(t) so as to distinguish it from some other nearby path x(t). We know it will minimize the value of the following integral:action integral

Now, we’ve been wondering what the formula actually means, and wrote that breaking it up in two separate integrals – an integral with the kinetic energy in the integrand minus an integral with the potential energy in the integrand – may help us in our understanding. Also, minimizing the integral is equivalent to maximizing its opposite, so perhaps we should look at something like this:

Maximize S[x(t)] = ∫0t (PE − KE) dt = ∫0t PE dt − ∫0t KE dt

These integrals can, of course, be represented as a surface area under the PE and KE curves, as shown below.


Let us recapitulate what is happening here:

  1. Our object will first go up and reach some maximum height based on its initial kinetic energy, and then it will fall. Hence, it will first maximize its potential energy based on the available kinetic energy, which is equal to 2450 joule in this particular example. [The example involves a 5 kg cannon ball that reaches a height of 50 m, so its initial velocity is around 31.3 m/s. Note that both pieces of information are essentially equivalent: if we know the mass, then we can calculate the height it will reach from the initial velocity, and vice versa.]
  2. To be precise, it will use the available kinetic energy in some 3.2 seconds, at which point it reaches its maximum height. Of course, the (available) kinetic energy diminishes at it is being used. The time rate of change of the kinetic energy can be calculated by re-writing the instantaneous velocity as a function of time:

powerNote that the power that is being delivered here is not constant: it’s a linear function of time. At t = 0, the instantaneous power that is being delivered is well above 1500 watt (J/s), but then it quickly drops. To be precise, it drops to zero in about 3.2 seconds, so that’s when the object stops going up and starts to fall. Of course, when it falls, it will gain kinetic energy at a rapidly increasing rate, as we’d expect it to do, but let’s not focus on that right now. 🙂

Note that the time rate of change of the kinetic energy is proportional to the mass. It has to be, because large and small objects follow the same same trajectory if launched with the same velocity.

OK. So far, so good. Let’s now think about averages. What’s the average kinetic energy as the object goes up? Hmm… What to do? We should, of course, calculate the value of the integral over the first half of its journey (from = 0 to = 3.2 s), and then divide the result by 3.2, i.e. the length of the time interval. Ouff! Sounds complicated. OK. Perhaps there is a quicker way here: if all of the available kinetic energy has been used up in 3.2 s, then the average kinetic energy must be equal to 2450/3.2 ≈ 766 J, right? Well… Maybe not. I think we’ve just calculated some average rate of change of the kinetic energy. We probably did… Because… Well… Unsurprisingly, 766 J is half of the instantaneous power at = 0 (the small difference is due to rounding errors). Let’s postpone the question for a minute. Let’s first look at potential energy. How would we calculate an average?

It’s tricky because we know the potential energy depends on our PE = 0 reference point, but… Well… If we set PE to 0 at t = 0, then the average potential energy should be the same as the average kinetic energy, right?

Hmm… Maybe. Maybe not.

Hey! Wait a minute! It has to be, right? In any case, the initial velocity depends on our reference frame, right? So it’s also quite arbitrary in that sense. So… Yes. I got it. We should be talking changes in kinetic and potential energy over some time interval = t2 − t1, right? So if PE = 0 at t1 = 0, and the change in kinetic energy is equal to the change in potential energy, then the average potential energy over the interval must be the same, right?

Hmm… Maybe. Maybe not.

Let’s check the time rate of change first. You’ll need to express the height (x) as a function of time but you can take that easily by solving the classic = ∫v(t)dt integral. You should the following result:PE changeSo, yes, we get what we should get: −dPE/dt = dKE/dt. At any point in time, kinetic energy gets converted into potential energy, so… Yes. All good. But our reasoning in regard to the averages is obviously wrong. Just look at the shape of the PE and KE curves: one is convex and the other is concave. The corresponding surface areas are, therefore, different. Hence, the average value of PE and KE over that interval must be different. There is no shortcut here: we must calculate those −∫0t PE dt and ∫0t KE dt functions here, and then divide them by t. I’ll leave that to you. The start of the calculations should probably look like this, but you may want to double-check. 🙂primitives

The point is: we will, obviously, get different values for both averages, so… Well… How is that possible? It defies the energy conservation principle, doesn’t it?

Hmm… Maybe. Maybe not.

The cannon ball at = 0 has kinetic energy, but no potential energy. At = 50 m, it has potential energy but no kinetic energy. The two situations are different but, yes, the energy conservation principle must be respected. The only way out is to concede that our reference point for PE = 0 must have been wrong. The graphs below assume the potential energy is minus 2450 J at the t= 0 point. This makes all look good: the change in the (total) kinetic energy matches the change in the (total) potential energy, over the whole time interval as well as instantaneously. Just check it: the surface areas are equal and opposite, and the function value are also equal and opposite. So… Yes. All good. Because we made a better choice of the PE = 0 reference point.new action graph

The two situations are still different – the position of our cannon ball has changed: to be precise, it went up 50 m 🙂 – but they are energetically equivalent now. Note that the sum of the kinetic and the potential energy is zero, over the interval as well as instantaneously. But the difference is not: the difference is twice the kinetic energy. Over the interval, and instantaneously. Weird, isn’t it? So KE − PE = m·v2. Wow ! That’s like E = m·c2, right? It is. And it can’t be a coincidence. 🙂

You should note that the equations don’t change when analyzing objects going against some force (field) or (think of the object falling down again) with some force (field). So what do we get for the action integral here? Well… Let’s do it:


What a monster! Let’s calculate the specific value for this particular case (in case you’re lost: we’re shooting our cannon ball up to a height of 50 m here). Let’s not round too much this time around. First, check the kinetic energy that is needed for our cannon ball to reach an altitude of 50 m. It’s 2451.6625 joule precisely. We know that because it is, effectively, the potential energy that is associated with an extra height of 50 m: 2451.65 = 5·9.80665·50. Hence, the initial velocity must be equal to 31.31557 m/s. Note that we use a more precise value for g now (9.80665 m/s2), although it shouldn’t matter: the Principle of Least Action should be valid for any force field, right? 🙂 Using a spreadsheet for the calculations, we will also get a more precise time for the time interval t: it’s about 3.1933 seconds. Let’s now calculate the value for our action integral by putting all these numbers in the formula above. We get 5219.26187… Well… I guess that’s an amount expressed in N·m·s (newton·meter·second) or J·s (joule·second), right? Let’s do the dimensional analysis: the v02t, v0gt2 and g2t3/3 terms give m2/s, and a kg can be written in terms of N·s2/m, so… Yes. We do get N·m·s, so that’s the action dimension. 🙂 The calculations are given below. Note that the v02t and v0gt2 cancel each other because v02t and v0gt2 = v0t·(v0 − gt) = v0·v = 0 for = 3.1933 s and = 50.calculation

So all we’re left with is this weird cubic function: the total action is equal to mg2t3/3. What is this? What is the meaning of this 5219.26 J·s value? The order of magnitude should not surprise us. If we would move a mass of 5 kg against gravity over a distance of 50 m in 3.1993 seconds, then that would amount to a total action of 5×9.80665×50×3.1933 ≈ 7828.89 J·s. The two amounts (5219.26 and 7828.89) have the same order of magnitude but… Well… They’re different. 😦 To be precise, the difference is 2609.63 J·s. Hey! That number is pretty close to the kinetic and potential energy value , right? Yes. The value for the initial kinetic energy was 2451.6625 joule, to be precise, and so that’s the value of the potential energy at = 50 m.

So… Well… We sort of got that energy for free and then burnt it, so to speak, to get our cannon ball where we wanted it, i.e. at a height of 50 m. So we should take that into account somehow. Should we add or subtract it from our 7828.89 J·s? But wait: 2451.6625 joule is an energy value, not an action value. And the burn rate surely matters, right? We didn’t burn it linearly. In fact, the action we got is given by the area under our KE curve, and we can calculate it as:remainder

So… Well… There we are. For our 2451.6625 joules of energy, we get about 2609.63 joule-seconds as action. We wrote we got the energy for free, so to speak, so… Well… We get this action for free, right? So we should subtract it from the 7828.89 J·s value we calculated:

7828.89 J·s − 2609.63 J·s = 5219.26 J·s.

Bingo! We’re straight on ! 🙂

Now, you may still feel confused and wonder why the numbers for the energy and the action (2451 J and 2609 J·s) are so close. I was, but then I re-did the problem requiring our cannon ball reaches a height of 100 m. You know what? It’s sheer coincidence. For = 100, the numbers are entirely different, but I’ll let you work through that example yourself. Let me just give you the solutions I got (but then I may have done something wrong, of course):

  1. For our cannon ball to reach a height of 100 m, its initial kinetic energy and the initial velocity has to be 4903 J and 44.287 m/s respectively.
  2. The time needed to reach a height of 100 m is equal to 4.516 seconds.
  3. The action integral gives a value of 14762 J·s.
  4. Taking our cannon ball from = 0 to = 100 in the mentioned time amounts to 22143 J·s. The difference between this amount and the action we calculated using our integral is 7381 J·s.
  5. The KE integral will give us the same value: 7381 J·s. In other words, we get 4903 J as initial kinetic energy – for free, so to speak – and, over the trajectory, that’s burnt as 7381 J·s in action.

So… Well… That’s it for the time being ! 🙂


2 thoughts on “II. Conservation of energy (2)

  1. Pingback: Newtonian, Lagrangian and Hamiltonian mechanics | Reading Feynman

  2. Pingback: The Principle of Least Action re-visited | Reading Feynman

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s