2
$\begingroup$

I am trying to solve the following set of equations to get a1, a2, a3. The code shown below produces too many solutions, my solution lies in it...how do i select it... in the attached picture, i am showing the code and the long list of solutions...i have highlighted the solution that i require in the blue colored box....how to i get this result only???

ClearAll;
Vdc1 = 1;
v1 = 0.15;
eqn = {(4 Vdc1)/π (Cos[a1 Degree] - Cos[a2 Degree] + Cos[a3 Degree]) - v1 == 0,
       (4 Vdc1)/(3π) (Cos[3 a1 Degree] - Cos[3 a2 Degree] + Cos[3 a3 Degree]) == 0,
       (4 Vdc1)/(5π) (Cos[5 a1 Degree] - Cos[5 a2 Degree] + Cos[5 a3 Degree]) == 0
      };
Solve[eqn, {a1, a2, a3}]  (* find so that 0<a1<a2<a3<π/2 *)

enter image description here

Need to extract the highlighted.

$\endgroup$
  • 1
    $\begingroup$ Why dont you give those restrictions to the Solve command??? $\endgroup$ – Mauricio Fernández May 15 '17 at 14:49
  • 2
    $\begingroup$ Select[sols, Quiet[ineq /. #] &], with or without Quiet? (Inequalities complain about complex numbers. $\endgroup$ – Michael E2 May 15 '17 at 15:06
  • 2
    $\begingroup$ Since {a1, a2, a3}` are degrees, the constraint should presumably be 0 < a1 < a2 < a3 < 90 $\endgroup$ – Bob Hanlon May 15 '17 at 15:12
  • $\begingroup$ how do u give restrictions to the solve command ? $\endgroup$ – UTs May 15 '17 at 15:22
2
$\begingroup$
Vdc1 = 1;
v1 = 15/100;

I had no luck adding constraints to Solve

Solve[{
  (4 Vdc1)/(\[Pi]) (Cos[a1 Degree] - Cos[a2 Degree] + 
       Cos[a3 Degree]) - v1 == 0,
  (4 Vdc1)/(3 \[Pi]) (Cos[3 a1 Degree] - Cos[3 a2 Degree] + 
      Cos[3 a3 Degree]) == 
   0, (4 Vdc1)/(5 \[Pi]) (Cos[5 a1 Degree] - Cos[5 a2 Degree] + 
      Cos[5 a3 Degree]) == 0,
  0 < a1,
  a1 < a2,
  a2 < a3,
  a3 < 90
  },
 {a1, a2, a3}
 ]

Mathematica graphics

One can use the same format for Reduce. It appeared to take a long time and I did not wait for it to finish to see if it produced an answer.

Instead I tried FindMinimum. It expects a function so I summed up the square of the inputs which is more or less equivalent to equating them to zero.

FindMinimum[
 {
  ((4 Vdc1)/\[Pi] (Cos[a1 Degree] - Cos[a2 Degree] + Cos[a3 Degree]) -
       v1 )^2 +
   (4 Vdc1)/(3 \[Pi]) (Cos[3 a1 Degree] - Cos[3 a2 Degree] + 
       Cos[3 a3 Degree])^2 +
   (4 Vdc1)/(5 \[Pi]) (Cos[5 a1 Degree] - Cos[5 a2 Degree] + 
       Cos[5 a3 Degree])^2,
  0 < a1 && a1 < a2 && a2 < a3 && a3 < 90
  },
 {
  a1,
  a2,
  a3
  }
 ]

The answer was produced quickly

{3.65723*10^-12, {a1 -> 42.5831, a2 -> 47.3491, a3 -> 86.6151}}
$\endgroup$
  • $\begingroup$ This is the answer is am getting {0.680728, {a1 -> 0.692134, a2 -> 13.5875, a3 -> 49.8621}} $\endgroup$ – UTs May 15 '17 at 15:47
  • $\begingroup$ In your original question you had some typos (i.e., using square brackets rather than curly brackets, etc...). I tried to correct those in the answer. If I start with a fresh Mathematica session and paste in the the top two lines and the FindMinimum line I duplicate the result in the answer. I am using Mathematica 11.1.1.0 $\endgroup$ – Jack LaVigne May 15 '17 at 15:51
  • $\begingroup$ Although taking about five minutes, Reduce does offer the advantage of finding all answers satisfying the equations. In this case there is only one, {a1 -> 42.5833, a2 -> 47.3492, a3 -> 86.6151} $\endgroup$ – bbgodfrey May 15 '17 at 16:58
0
$\begingroup$

As I have kept mentioning many times before, such problems are best handled through the Weierstrass substitution. The substitution is especially convenient here, since the angle restrictions are also very easily imposed:

With[{Vdc1 = 1, v1 = 15/100}, 
     NSolve[Join[TrigExpand[{(4 Vdc1)/(π) (Cos[a1] - Cos[a2] + Cos[a3]) - v1 == 0,
                             (4 Vdc1)/(3 π) (Cos[3 a1] - Cos[3 a2] + Cos[3 a3]) == 0,
                             (4 Vdc1)/(5 π) (Cos[5 a1] - Cos[5 a2] + Cos[5 a3]) == 0} /.
                            Thread[{a1, a2, a3} -> 2 ArcTan[{u1, u2, u3}]]],
                 {0 < u1 < 1, 0 < u2 < 1, 0 < u3 < 1}], {u1, u2, u3}]]
   {{u1 -> 0.942601, u2 -> 0.43844, u3 -> 0.389715},
    {u1 -> 0.389715, u2 -> 0.43844, u3 -> 0.942601}}

2 ArcTan[{u1, u2, u3}]/° /. %
   {{86.6151, 47.3492, 42.5833}, {42.5833, 47.3492, 86.6151}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.