These equations have an answer - how to get solve to find it?

1 view (last 30 days)
I'm not sure where to ask this question. I solved some equations by hand, and I know the answer is right. I can't get `solve` to give me the same answer, and I'm wondering why.
It's a physics problem with two objects and conservation of momentum. Their final velocities are v_1f and v_2f. The question is "what is u when the two velocities are equal".
Why doesn't `solve` give me that value for `u`?
syms m m_1 m_2 v_1 v_2 v_1f v_2f u;
expression1 = (v_1*m_1 + v_1*m + u*m) / (m+m_1); % for final velocity 1
expression2 = (v_2*m_2 + m*(v_1f-u)) / (m_2 + m); % for final velocity 2
eq1 = v_1f == expression1
eq2 = v_2f == expression2
eq3 = v_1f == v_2f
solve([eq1 eq2 eq3], u) % fails
answerByHand = -(m_2*(m + m_1)*(v_1 - v_2))/(m*(m + m_1 + m_2)) % this is u, found manually
X = simplify(subs(expression1,u,answerByHand))
Y = simplify(subs(subs(expression2,v_1f,expression1),u,answerByHand))
isequaln(Y,X) % true
Update:
It might be useful or interesting to know more about the physics problem...
It's about 2 astronauts in zero-gravity throwing a mass between them.
Everything is 1-dimensional. v_1 and v_2 are the initial velocities of the two astronauts. They are both moving to the right. #2 is initially faster. #1 throws a mass (m) to #2, at relative speed u. v_1f and v_2f are their final velocities. So the question is: how fast must #1 through the mass m so that the two astronauts have the same speed after astronaut #2 catches it.
The equations come from the conservation of momentum (m*v).

Answers (2)

John D'Errico
John D'Errico on 29 Nov 2017
Edited: John D'Errico on 29 Nov 2017
Anyway, lets check the solution that you have posed. I'll write it a bit more simply.
v_1f = (v_1*m_1 + v_1*m + u*m) / (m+m_1);
E2 = v_2f == (v_2*m_2 + m*(v_1f-u)) / (m_2 + m);
But, you also have v1_f == v_2f. So we can eliminate v_2f completely, which has the nice feature that it also eliminates v_1f.
E3 = subs(E2,v_2f,v_1f)
E3 =
(m*u + m*v_1 + m_1*v_1)/(m + m_1) == (m_2*v_2 - m*(u - (m*u + m*v_1 + m_1*v_1)/(m + m_1)))/(m + m_2)
We can solve that for u.
u = solve(E3,u)
u =
-(m*m_2*v_1 - m*m_2*v_2 + m_1*m_2*v_1 - m_1*m_2*v_2)/(m*m_1 + m*m_2 + m^2)
u0 here is the solution that you posed.
u0 = -(m_2*(m + m_1)*(v_1 - v_2))/(m*(m + m_1 + m_2));
simplify(u-u0)
ans =
0
So in fact, the two solutions are the same.
  5 Comments
John D'Errico
John D'Errico on 29 Nov 2017
Edited: John D'Errico on 29 Nov 2017
I think what happens is solve sees those two extra variables and does not see how they can be eliminated. It got confused. Probably it ends up doing some work that led to a complicated mess. Sometimes it is easier for the eye to disentangle things, looking down from above. Computers don't always know how to look for something that makes a problem simpler.
For example, in one of Cleve's recent posts, I recall he took a problem that arrives at no direct solution symbolically, yet by an intelligent set of transformations, has a very pretty solution.

Sign in to comment.


Stefan Wehmeier
Stefan Wehmeier on 30 Nov 2017
Why not just solve(expression1 == expression2, u) ?
What you did is to confuse assignemnts/assumptions with equations. You want to assume that v1_f and v2_f are given by certain expressions, and ask for a value of u that makes the two equal. What you typed is the question whether there exists u such that any two numbers v1_f and v2_f automatically become equal to the given expressions, and equal to each other.
  1 Comment
RobNik
RobNik on 7 Dec 2017
I guess I don't understand `solve`. Can you restate your answer using the following simpler example? If I were told to "solve these two equations for y":
  • x = y
  • x = 1
I'd use basic algebra and say that the answer is "y = 1". But this has no answer:
solve([x == y, x == 1], y) % Empty sym: 0-by-1
This one however, does what I was thinking:
solve([x == y, x == 1], [x,y])
and says "x=1, y=1".
What is the first one really saying/asking for?

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!