4 different wrong eduations instead of one right after using solve

>> syms g h q sx sy v;
>> sy = (-g/2) * ( sx/(cos(q)*v) )^2 + v * sin(q) * ( sx/(cos(q)*v) )^2 + h;
>> sx=solve(sy,sx)
sx =
(2^(1/2)*v*cos(q)*(g*h - 2*h*v*sin(q))^(1/2))/(g - 2*v*sin(q))
-(2^(1/2)*v*cos(q)*(g*h - 2*h*v*sin(q))^(1/2))/(g - 2*v*sin(q))
>> sx = ( 2^(1/2) * v * cos(q) * (g * h - 2*h*v*sin(q) )^(1/2) ) / (g - 2*v*sin(q));
>> sx = diff(sx,q);
>> q=solve(sx,q);
>> q
q = asin((g + (g^2 - 4*v^2)^(1/2))/(2*v))
pi - asin((g - (g^2 - 4*v^2)^(1/2))/(2*v))
asin((g - (g^2 - 4*v^2)^(1/2))/(2*v))
pi - asin((g + (g^2 - 4*v^2)^(1/2))/(2*v))
The right equation is:
q = arcsin (v/(2*v^2+2*h*g))
Is there a way in matlab to get this equation?

4 Kommentare

Please format your equations: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question.
I hope that looks better. May you have now some idea, what's wrong with my calculation?:)
Your answer is not dimensionally correct. The argument to arcsin must be dimensionless, but it has units (1/velocity).
Maple solves to
arctan((g + (g^2 - 4*v^2)^(1/2))/(2*v), (8*v^2-2*g^2-2*g*(g^2-4*v^2)^(1/2))^(1/2)/v)
instead of
arcsin((g + (g^2 - 4*v^2)^(1/2))/(2*v))
and the arcsin() equivalent to Maple's solution is notably different.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

The web page is not clear, but this seems to be a simple projectile problem where you're trying to maximize the horizontal distance. Suppose the projectile is ejected at an angle q with respect to the vertical at a speed v and from a height h above the ground. The height at time t is z = h + v*t*sin(q) - 0.5*g*t^2. The time t0 at which this height is zero is the positive root of the RHS: t0 = (v*sin(q) + sqrt(v^2*sin(q)^2-2*g*h))/g.
The object is to maximize the horizontal distance x = v*t*cos(theta). This is the solution of dx/dt = 0, but the solutions also include minima and other local maxima that are not the global maximum.
t0 = (v*sin(q) + sqrt(v^2*sin(q)^2-2*g*h))/g;
x = t0*cos(q)
x =
2 2 1/2
cos(q) (sin(q) v + (sin(q) v - 2 g h) )
-------------------------------------------
g
Note that since we are trying to maximize this distance, we can normalize by the positive factor v/g, leaving x0 = cos(q)*(sin(q) + sqrt(sin(q)^2 - 2*B^2)), where B^2 = g*h/v^2. Try plotting this function of angle for a given B:
B = 1;
f = @(q) cos(q).*(sin(q) + sqrt(sin(q).^2 - 2*B^2));
x = (0:.01:1)*2*pi; y = f(x); plot(x,y)
As you can see, there are two maxima and two minima.
Now try the symbolic solution.
syms B
x = cos(q).*(sin(q) + sqrt(sin(q).^2 - 2*B^2));
dddq = diff(x,q);
qsols = solve(dddq,q)
You can play around with different values of B to see which solution is the one you want:
double(subs(qsols,B,0.5))
ans =
-2.1863
-0.9553
2.1863
0.9553
Note that only the fourth solution is between 0 and pi/2. The symbolic solution is
disp(qsols(4))
1/2 2 2 1/2
1 2 ((B - 1) (2 B - 1))
atan(--------------, - 1/2 -----------------------------)
2 1/2 2
(-2 B + 2) B - 1
This atan is the two-argument arctangent atan(y,x).

Weitere Antworten (2)

I'm going to weed out some irrelevant material from your question and format it using the methods in How to format your question:
syms g h q sx v;
sx = ( 2^(1/2) * v * cos(q) * (g * h - 2*h*v*sin(q) )^(1/2) ) / (g - 2*v*sin(q));
dsx = diff(sx,q);
qsol=solve(dsx,q);
I get an answer, but it is much more complicated than arcsin (v/(2*v^2+2*h*g)). Moreover, if I try
simple(subs(dsx,q,asin (v/(2*v^2+2*h*g))))
which should be zero if your solution is correct, I do not get zero. Are you sure that your answer is correct?

3 Kommentare

In Maple I get answers in terms of arctan() not arcsin(), and converting to arcsin() gives very long expressions that are not at all the same as v/(2*v^2+2*h*g) .
I do not find any significant simplification. I do find a rewrite in terms of ln of a complex number, but that is really just hiding the arctan:
-I*ln((1/2)*((8*v^2-2*g^2-2*g*(g^2-4*v^2)^(1/2))^(1/2)+I*g+I*(g^2-4*v^2)^(1/2))/v)
where "I" represents sqrt(-1)
thanks for your answer, I don't know, but I think the equation is korrect.
If you want you can read hier whats my question about.
I found a german page, but may the google translator works good enogth, that you can understand it. http://translate.google.de/translate?sl=de&tl=en&js=n&prev=_t&hl=de&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fwww.chemieonline.de%2Fforum%2Fshowthread.php%3Ft%3D145564&act=url
When I looked through that, I saw someone proposed using arcsin() the correction was to use arctan()

Melden Sie sich an, um zu kommentieren.

Sascha
Sascha am 28 Dez. 2011

0 Stimmen

I worked hours and hours on this exerciese and I can't find a solution.
I tryed it without Matlab on paper with Pythagorean trigonometric and trigonometric addition theorems, but I can't get it..
I hope you have any idea. I let be sayn q is not 45° if h != 0 Tomorrow I will try it again.. good night

1 Kommentar

please do not delete your other questions, they contain information not in this question that might help find a solution

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by