?????? ????? <ya.natasha42 at yandex.ru> writes:
> Hello!
>
> Please help with the equation: cos 3x-sin x=sqrt(3)(cos x-sin 3x)
>
> I can not bring it to the form in order to find the real roots in the
> interval [0,2*%pi].
One way to solve this sort of question is to substitute log(y) for %i*x
into its exponential form. For example:
eq: cos(3*x) - sin(x) = sqrt(3)*(cos(x)-sin(3*x));
eq1: exponentialize(eq);
eq2: subst([%i*x = log(y), 3*%i*x = 3*log(y)], eq1);
(the strange form for subst is because subst works by matching
syntactically and %i*x doesn't appear as a subexpression of
3*%i*x. ratsubst deals with this correctly, but jumps straight to eq3,
which makes it less obvious what's going on)
eq2 is then:
3 1 3 1
y + -- 1 %i (y - --) 1
3 %i (y - -) 3 y + -
y y y y
------- + ---------- = sqrt(3) (------------ + -----)
2 2 2 2
This is a sixth order polynomial equation. One way to write it as a
polynomial is to apply rat and then multiply through by the denominator:
eq3: rat(eq2);
eq4: multthru(2*y^3, eq3);
6 4 2 6 4
(%o26) y + %i y - %i y + 1 = sqrt(3) %i y + sqrt(3) y
2
+ sqrt(3) y - sqrt(3) %i
This is promising, since it's a cubic in y^2. So let's tidy up further:
(%i31) eq5: ratsubst(z, y^2, eq4);
3 2 3 2
(%o31) z + %i (z - z) + 1 = sqrt(3) %i (z - 1) + sqrt(3) (z + z)
Now, if u is a root of eq5, then exp(log(sqrt(u))/%i) will be a root of
your original equation. Very promising... But the result of
solve(eq5, z);
is pretty horrible.
Notice that %solve, from the to_poly_solve package, seems to get the
same answer, starting with the original equation. It also takes quite a
long time to run. I'm writing up the stuff above, since it explains
what's going on (and I never believe a long calculation that gives a
horrible answer...)
Incidentally, plotting eq with
plot2d(lhs(eq)-rhs(eq), [x,0,2*%pi]);
convinced me that there are six roots. A relief, since each of the three
roots of eq5 is the square of two roots of eq4. Numerically, you can do:
(%i45) zroots: allroots(eq5), numer;
(%o45) [z = .7071067811865129 %i + .7071067811865259,
z = - .7071067811865503 %i - .7071067811865429,
z = .5000000000000374 %i + .8660254037844556]
(the numer flag is to put in a numerical value for the sqrt(3)).
AHAH! If you recognise the decimal expansion of 1/sqrt(2), this looks
very familiar! Now, there are two things we can do. Firstly, we can
continue with the numerical calculations. I confess that I didn't spot
the magic numbers the first time around, so that's what I did
first. Secondly, you can factor the cubic by eye.
The numerical approach:
First, we want the square roots:
(%i48) yroots: flatten(map(lambda([x], [sqrt(rhs(x)), -sqrt(rhs(x))]), zroots));
(%o48) [.3826834323650779 %i + .9238795325112702,
- .3826834323650779 %i - .9238795325112702,
.3826834323650919 - .9238795325112852 %i,
.9238795325112852 %i - .3826834323650919,
.2588190451025366 %i + .9659258262890813,
- .2588190451025366 %i - .9659258262890813]
And to convert from y to x:
(%i51) almost_x_roots: map(lambda([y], rectform(log(y)/%i)), yroots);
(%o51) [1.983135877736725e-14 %i + .3926990816987195,
1.983135877736725e-14 %i - 2.748893571891074,
6.24500451351651e-16 %i - 1.17809724509617,
6.24500451351651e-16 %i + 1.963495408493623,
.2617993877991614 - 1.66811009449927e-14 %i,
- 1.66811009449927e-14 %i - 2.879793265790632]
Woo! These all have tiny imaginary parts! I haven't got it horribly
wrong! Let's throw away the imaginary parts, which we think are just
From numerical error, to get
(%i53) x_roots: subst(0, %i, almost_x_roots);
(%o53) [.3926990816987195, - 2.748893571891074, - 1.17809724509617,
1.963495408493623, .2617993877991614, - 2.879793265790632]
Oh, and these are sometimes in the wrong 2*%pi-long interval, so let's
fix that:
(%i57) x_roots_in_interval: map(lambda([x], mod(x, float(2*%pi))), x_roots);
(%o57) [.3926990816987195, 3.534291735288512, 5.105088062083416,
1.963495408493623, .2617993877991614, 3.403392041388954]
Incidentally, I made a slight mistake when working that out the first
time, and wrote:
(%i58) map(lambda([x], mod(x, float(%pi))), x_roots);
(%o58) [.3926990816987195, .3926990816987193, 1.963495408493623,
1.963495408493623, .2617993877991614, .2617993877991611]
Given that the pairs of square roots were next to each other in our
list, this shows that the roots are actually %pi-periodic and the
positive and negative square roots pick out the solutions on the odd and
even intervals. Rather neat, considering that the function itself
doesn't have any obvious symmetries (looking at a graph). Anyone know a
nice mathematical explanation for this?
Now let's go back to the bit where we spotted the magic numbers. Notice
that
(%i75) map(lambda([z0], expand(subst(z0, z, lhs(eq5)-rhs(eq5)))),
[(1 + %i)/sqrt(2), -(1 + %i)/sqrt(2), sqrt(3)/2+%i/2]);
(%o75) [0, 0, 0]
So we actually have the solutions. In fact, they have very nice
numerical answers. Taking logarithms, we get the following six answers:
(%i105) y_roots: flatten(map(lambda([x], [sqrt(x), -sqrt(x)]),
[(1+%i)/sqrt(2), -(1+%i)/sqrt(2), sqrt(3)/2+%i/2]))$
(%i106) x_roots: map(lambda([y], rectform(log(y)/%i)), y_roots);
%pi 7 %pi 3 %pi 5 %pi %pi 11 %pi
(%o106) [---, - -----, - -----, -----, ---, - ------]
8 8 8 8 12 12
and we can force them into the expected intervals with
(%i108) x_roots_in_interval: map(lambda([x], mod(x, 2*%pi)), x_roots);
%pi 9 %pi 13 %pi 5 %pi %pi 13 %pi
(%o108) [---, -----, ------, -----, ---, ------]
8 8 8 8 12 12
Incidentally, taking the original numerical answers as num_xrii, you can
do the following:
(%i125) num_xrii / float(%pi);
(%o125) [.1249999999999985, 1.124999999999998, 1.625000000000001,
.6250000000000009, .08333333333333715, 1.083333333333337]
and at least the first four are obviously recognizable. Phew!
Questions:
==========
(1) Natasha, was your original question a homework question? If you
waded through this whole email, I don't feel too guilty for having
answered it. But this probably wasn't the approach the homework
setter expected you to follow. (Spotting that 0.707... is a
numerical solution kind of requires a computer...) If so, was there
some sort of hint?
(2) I'm still mystified by the fact that the two roots in each square
root give the roots over the two length-%pi intervals. Anyone got
any idea why?
(3) Why did algsys give such a horrible answer on the cubic, I wonder?
Anyway, Natasha, I hope this answered your original question. I may have
written slightly more than you were after, but I was enjoying myself :-)
Rupert
PS: Natasha, your email was held in a moderation queue because you're
not subscribed to the mailing list. If you want your emails to
appear more quickly, I recommend subscribing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20130615/a58059ee/attachment.pgp>