# Need help to reformulate Projectile Motion to a convex problem

(Kelvin Pagels) #1

I will try to formulate my question precise as possible. I am aware of there’s a introduction to cvx pdf and a thread about what not to do in CVX. I tried to look in them and see if I could find the answer there before making this new topic.

My question is as follows:

I am trying to solve a simple problem just to try the CVX toolbox. The problem is about “Projectile motion” and the formulas can be seen on this wikipedia page: https://en.wikipedia.org/wiki/Projectile_motion

My idea is that I want to maximize the distance the ball can fly (xmax = vx * vy * 2/ g) and put one constraint so the ball does not go above some fixed height (ymax = vy^2/2*g).

``````g = 9.82;
cvx_begin
variables vx vy
maximize vx * vy * 2/ g
subject to
vy^2/2*g <= 5;
cvx_end
``````

The problem with this expression is that I am not allowed to multiply two variables with each other since they are not always convex. I found others having the same problem but I haven’t found the solution in theirs topic. I also tried to add constraints for vx > 0 and vy > 0 but that did not help. When I change vx to a fixed value the following problem can be solved… But why?

``````g = 9.82; vx = 10;
cvx_begin
variables vy
maximize vx * vy * 2/ g
subject to
vy^2/2*g <= 5;
cvx_end
``````

I would really like to get some tips about how to fix it so it can work with CVX.

Thanks in regards.

(Mark L. Stone) #2

I have no idea what your formula
`vx * vy * 2/ g`
i s supposed to be. What is that the maximum distance of? I certainly don’t see such a formula anywhere in the Wikipedia article you linked.

`vx * vy * 2/ g` is neither a convex nor concave function of `vx` and `vy`. If `vx` is fixed at a particular value, such as 10, rather than being a CVX variable, then `vx * vy * 2/ g` is an affine function of `vy.` As such, CVX will allow you to use it in an objective function to be maximized or minimized, or on the Left Hand Side or Right Hand Side of an equality or inequality constraint.

(Kelvin Pagels) #3

Theres a formula in the section The initial velocity for vx = cos(a)v0 and vy = sin(a)v0. If they are inserted in vxvy2 /g you get the following: cos(a)*v0 * sin(a)*v0 * 2 / g = cos(a) * sin(a)*v0^2 * 2 / g (where cos(a)sin(a) = 1/2 sin(2a) ) = 2 1/2 * sin(2a) * v0^2 = sin(2a) * v0^2. This formula correspond to the formula in the following section Maximum distance of projectile. So thats where that formula comes from.

(Mark L. Stone) #4

As I wrote in my first post, I don’t see such a formula there. The product term `vx*vy` doesn’t make any sense in this application. You can get a term proportional to the square of the initial speed; that is a function of one variable, not the product of two variables.

I suggest you seek assistance at https://math.stackexchange.com/ in order to get a valid mathematical problem formulation. You can look at http://calculus7.com/sitebuildercontent/sitebuilderfiles/projrangenotes.pdf , but notice that the problem of maximizing the projectile range which is shown there is non-convex, and is solved analytically without using CVX; and CVX would not accept that problem, because it is not convex.

After you have a valid mathematical problem formulation, you may come back to this forum if the resulting optimization problem is convex and you need help entering it into CVX.