pagan

5147 Reputation

23 Badges

17 years, 122 days

 

 

"A map that tried to pin down a sheep trail was just credible,

 but it was an optimistic map that tried to fix a the path made by the wind,

 or a path made across the grass by the shadow of flying birds."

                                                                 - _A Walk through H_, Peter Greenaway

 

MaplePrimes Activity


These are replies submitted by pagan

@simoncfr That's just a consequence of how Arrays get printed. Try using a Vector[row] instead of a 1D Array, to get printing that is more like that of a list. Vectors can also be grown.

> A:=Vector[row]([11,12,13,14,15]);

                          A := [11, 12, 13, 14, 15]

> A[2..-1];

                              [12, 13, 14, 15]

> A[3..-2];

                                  [13, 14]

> op(1,A); # size

                                      5

> A(7):=99;

                      A := [11, 12, 13, 14, 15, 0, 99]

> op(1,A);

                                      7

Note that by default the Standard GUI will only explicitly print the entries for Vectors and Matrices whose sizes are at most 10. Above that size, only a summary is printed. Use the command interface(rtablesize=N) to change the maximal size which will printed in full.

> restart:

> V:=Vector[row](25,6);

                             [ 1 .. 25 Vector[row]  ]
                             [ Data Type: anything  ]
                        V := [ Storage: rectangular ]
                             [ Order: Fortran_order ]

> interface(rtablesize=30):

> V;

 [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]

@simoncfr That's just a consequence of how Arrays get printed. Try using a Vector[row] instead of a 1D Array, to get printing that is more like that of a list. Vectors can also be grown.

> A:=Vector[row]([11,12,13,14,15]);

                          A := [11, 12, 13, 14, 15]

> A[2..-1];

                              [12, 13, 14, 15]

> A[3..-2];

                                  [13, 14]

> op(1,A); # size

                                      5

> A(7):=99;

                      A := [11, 12, 13, 14, 15, 0, 99]

> op(1,A);

                                      7

Note that by default the Standard GUI will only explicitly print the entries for Vectors and Matrices whose sizes are at most 10. Above that size, only a summary is printed. Use the command interface(rtablesize=N) to change the maximal size which will printed in full.

> restart:

> V:=Vector[row](25,6);

                             [ 1 .. 25 Vector[row]  ]
                             [ Data Type: anything  ]
                        V := [ Storage: rectangular ]
                             [ Order: Fortran_order ]

> interface(rtablesize=30):

> V;

 [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]

@hirnyk The `allvalues` command does not succeed below, in the presence of the function application of sin@@3, but it does succeed if this is converted to sin(sin(sin(...))). One way to do such a conversion is by using `expand`. I wasn't sure whether I wanted to also expand nested subexpressions inside the RootOfs of the form sin(A+B) into something huge. So instead I used subsindets directly to replace function calls of sin@@3 by sin(sin(sin(...))).

It seems that the application of arcsin (thrice) to both sides of the equation was not a necessary step. I omit this below. I converted to exact rational because experience tells me that solving/simplifying mixed float & exact expressions can lead to a mess (and potential loss of information, at whatever working precision).

> RootOf((sin@@3)(_Z)-(sin@@3)(883/171669+RootOf(-(sin@@3)(_Z)+x)));

           /              
     RootOf|@@(sin, 3)(_Z)
           \              

                    / 883                                \\
        - @@(sin, 3)|------ + RootOf(-@@(sin, 3)(_Z) + x)||
                    \171669                              //

> allvalues(%); # weakness in allvalues

           /              
     RootOf|@@(sin, 3)(_Z)
           \              

                    / 883                                \\
        - @@(sin, 3)|------ + RootOf(-@@(sin, 3)(_Z) + x)||
                    \171669                              //

> subsindets(%,
>            specfunc(anything,sin@@3),t->sin(sin(sin(op(t)))));

        /                 
  RootOf|sin(sin(sin(_Z)))
        \                 

          /   /   / 883                                   \\\\
     - sin|sin|sin|------ + RootOf(-sin(sin(sin(_Z))) + x)||||
          \   \   \171669                                 ////

> allvalues(%):

> length(%); # now it succeeded
                              4760

So I can use the above approach for the problem at hand.

> restart:

> eq:=y=(sin@@3)(0.5143600172e-2
>                +1.000000039*arcsin(arcsin(sin(sin(-0.1543083839e-1
>                   +.9999999610*RootOf((sin@@3)(_Z)-(sin@@3)(0.5143619410e-2
>                      +1.000000000*RootOf(-(sin@@3)(_Z)+x)))))))):

> neweq:=convert(eq,rational,exact):

> solve(neweq,x); # returns NULL

Warning, solutions may have been lost

> solve([allvalues(neweq)],x); # returns NULL

Warning, solutions may have been lost

> NEWEQ:=subsindets(neweq,
>                 specfunc(anything,sin@@3),t->sin(sin(sin(op(t))))):

> solve([allvalues(NEWEQ)],x): # succeeds

> subsindets(%,`local`,t->0); # quick way to subs for all assumed _B and _Z parameters

   /       /   /   /   514361941           /      /   /    /
  { x = sin|sin|sin|- ------------ + arcsin|arcsin|sin|-sin|
   \       \   \   \  100000000000         \      \   \    \
    1028723881980269721 
  - --------------------
    99999999999999847900

       1000000000000000000                          \\\\\\\\ 
     - ------------------- arcsin(arcsin(arcsin(y)))||||||| }
       999999999999998479                           //////// 

I notice another failing on sin@@3

> restart:

> P:=(arcsin@@3)((sin@@3)(x));

                  @@(arcsin, 3)(@@(sin, 3)(x))

> eval(P,x=0.7);

                          0.7000000000

> simplify(P,symbolic); # weakness in simplify

                  @@(arcsin, 3)(@@(sin, 3)(x))

> expand(P);

            arcsin(arcsin(arcsin(sin(sin(sin(x))))))

> simplify(expand(P),symbolic);

                               x

@hirnyk The `allvalues` command does not succeed below, in the presence of the function application of sin@@3, but it does succeed if this is converted to sin(sin(sin(...))). One way to do such a conversion is by using `expand`. I wasn't sure whether I wanted to also expand nested subexpressions inside the RootOfs of the form sin(A+B) into something huge. So instead I used subsindets directly to replace function calls of sin@@3 by sin(sin(sin(...))).

It seems that the application of arcsin (thrice) to both sides of the equation was not a necessary step. I omit this below. I converted to exact rational because experience tells me that solving/simplifying mixed float & exact expressions can lead to a mess (and potential loss of information, at whatever working precision).

> RootOf((sin@@3)(_Z)-(sin@@3)(883/171669+RootOf(-(sin@@3)(_Z)+x)));

           /              
     RootOf|@@(sin, 3)(_Z)
           \              

                    / 883                                \\
        - @@(sin, 3)|------ + RootOf(-@@(sin, 3)(_Z) + x)||
                    \171669                              //

> allvalues(%); # weakness in allvalues

           /              
     RootOf|@@(sin, 3)(_Z)
           \              

                    / 883                                \\
        - @@(sin, 3)|------ + RootOf(-@@(sin, 3)(_Z) + x)||
                    \171669                              //

> subsindets(%,
>            specfunc(anything,sin@@3),t->sin(sin(sin(op(t)))));

        /                 
  RootOf|sin(sin(sin(_Z)))
        \                 

          /   /   / 883                                   \\\\
     - sin|sin|sin|------ + RootOf(-sin(sin(sin(_Z))) + x)||||
          \   \   \171669                                 ////

> allvalues(%):

> length(%); # now it succeeded
                              4760

So I can use the above approach for the problem at hand.

> restart:

> eq:=y=(sin@@3)(0.5143600172e-2
>                +1.000000039*arcsin(arcsin(sin(sin(-0.1543083839e-1
>                   +.9999999610*RootOf((sin@@3)(_Z)-(sin@@3)(0.5143619410e-2
>                      +1.000000000*RootOf(-(sin@@3)(_Z)+x)))))))):

> neweq:=convert(eq,rational,exact):

> solve(neweq,x); # returns NULL

Warning, solutions may have been lost

> solve([allvalues(neweq)],x); # returns NULL

Warning, solutions may have been lost

> NEWEQ:=subsindets(neweq,
>                 specfunc(anything,sin@@3),t->sin(sin(sin(op(t))))):

> solve([allvalues(NEWEQ)],x): # succeeds

> subsindets(%,`local`,t->0); # quick way to subs for all assumed _B and _Z parameters

   /       /   /   /   514361941           /      /   /    /
  { x = sin|sin|sin|- ------------ + arcsin|arcsin|sin|-sin|
   \       \   \   \  100000000000         \      \   \    \
    1028723881980269721 
  - --------------------
    99999999999999847900

       1000000000000000000                          \\\\\\\\ 
     - ------------------- arcsin(arcsin(arcsin(y)))||||||| }
       999999999999998479                           //////// 

I notice another failing on sin@@3

> restart:

> P:=(arcsin@@3)((sin@@3)(x));

                  @@(arcsin, 3)(@@(sin, 3)(x))

> eval(P,x=0.7);

                          0.7000000000

> simplify(P,symbolic); # weakness in simplify

                  @@(arcsin, 3)(@@(sin, 3)(x))

> expand(P);

            arcsin(arcsin(arcsin(sin(sin(sin(x))))))

> simplify(expand(P),symbolic);

                               x

In that case how about just that double-seq way?

  [seq(seq(`if`(M[i,j]=1,[i,j],NULL),j=1..n),i=1..m)]:

It's pretty quick. There, m and n are the dimensions of M, like from op(1,M).

In that case how about just that double-seq way?

  [seq(seq(`if`(M[i,j]=1,[i,j],NULL),j=1..n),i=1..m)]:

It's pretty quick. There, m and n are the dimensions of M, like from op(1,M).

@hirnyk The acrobatics relate to getting a grip on the inverse, ie. a function of y. And it could be shortened. But anyone can plot the original expression in x easily (and indeed I'd already done that too), so your point is unclear.

@hirnyk The acrobatics relate to getting a grip on the inverse, ie. a function of y. And it could be shortened. But anyone can plot the original expression in x easily (and indeed I'd already done that too), so your point is unclear.

I think that grandiose is a fitting description of the idea.

@Axel Vogt I was just using Euler's formula as relating to trig. In Maple..

> convert(cos(Pi/13),exp);

                1    /1      \   1    / 1      \
                - exp|-- I Pi| + - exp|--- I Pi|
                2    \13     /   2    \ 13     /

> expand(%); # which converts exp(I*Pi) -> -1

                  1     (1/13)   1     (12/13)
                  - (-1)       - - (-1)       
                  2              2            

@Axel Vogt I was just using Euler's formula as relating to trig. In Maple..

> convert(cos(Pi/13),exp);

                1    /1      \   1    / 1      \
                - exp|-- I Pi| + - exp|--- I Pi|
                2    \13     /   2    \ 13     /

> expand(%); # which converts exp(I*Pi) -> -1

                  1     (1/13)   1     (12/13)
                  - (-1)       - - (-1)       
                  2              2            

@Axel Vogt I see some old usenet posts like this, in which convert/radical is used following `convert/RootOf` or `convert/RootOf/sincos`, for handling sin(Pi/27). But maybe it ought to be mentioned that the resulting explicit, unsimplified, purely real-valued, expressions do still contain `I` in them. And evalc goes to town on that.

The exact expression cos(Pi/13) can be written down as 1/2*((-1)^(1/13)+(-1)^(-1/13)) or (1/2)*((-1)^(1/13)-(-1)^(12/13)) easily enough. But it's not directly helpful.

Considering some of that older usenet material then, maybe it's worthwhile to point out that what'd be "nicest" would be explicit radical representation without any imaginary subterms?

Are you referring to this, by the way (as part of the much longer parent thread here)? The code posted there by Carl Devore is like this:

> restart:

> `expand/Cos`:= proc(n::nonnegint, x::name)
>  option remember;
>  expand(`if`(n<100,cos(n*x),
>              (p-> `if`(p=n,2*Cos(n-1,x)*cos(x) - Cos(n-2,x),
>                        subs(cos(x)= Cos(n/p,x),expand(Cos(p,x)))
>         ))(ifactors(n)[2,1,1])))
> end proc:

> MinPolyCos:=
> (C::specfunc(satisfies(x-> type(x/Pi, rational)), cos), x::name)->
> select(p-> (d-> fnormal(evalf[d](combine(eval(p, x= C))), d))
> (max(14, length(norm(p,1))))= 0,subs(cos(x)= x,map(q-> q[1]
> ,factors(expand(Cos(2*denom(op(C)), x)) - 1)[2])))[]:

Applied to your cos(Pi/13) example:

> MinPolyCos(cos(Pi/13),x);

            6       5       4       3       2          
        64 x  - 32 x  - 80 x  + 32 x  + 24 x  - 6 x - 1

> convert(cos(Pi/13),RootOf);

      /                 2        3        4        5        6  
RootOf\-1 - 6 _Z + 24 _Z  + 32 _Z  - 80 _Z  - 32 _Z  + 64 _Z , 

              \
  0.9709418174/

At least one person has mentioned Chebychev polynomial T_n, see A&S 22.3.15, for producing a polynomial P(x) such that P(cos(m*Pi/n)) is zero.

Dave Rusin has made some informative posts (elsewhere) on quintics and radicals, if I remember.

@Axel Vogt I see some old usenet posts like this, in which convert/radical is used following `convert/RootOf` or `convert/RootOf/sincos`, for handling sin(Pi/27). But maybe it ought to be mentioned that the resulting explicit, unsimplified, purely real-valued, expressions do still contain `I` in them. And evalc goes to town on that.

The exact expression cos(Pi/13) can be written down as 1/2*((-1)^(1/13)+(-1)^(-1/13)) or (1/2)*((-1)^(1/13)-(-1)^(12/13)) easily enough. But it's not directly helpful.

Considering some of that older usenet material then, maybe it's worthwhile to point out that what'd be "nicest" would be explicit radical representation without any imaginary subterms?

Are you referring to this, by the way (as part of the much longer parent thread here)? The code posted there by Carl Devore is like this:

> restart:

> `expand/Cos`:= proc(n::nonnegint, x::name)
>  option remember;
>  expand(`if`(n<100,cos(n*x),
>              (p-> `if`(p=n,2*Cos(n-1,x)*cos(x) - Cos(n-2,x),
>                        subs(cos(x)= Cos(n/p,x),expand(Cos(p,x)))
>         ))(ifactors(n)[2,1,1])))
> end proc:

> MinPolyCos:=
> (C::specfunc(satisfies(x-> type(x/Pi, rational)), cos), x::name)->
> select(p-> (d-> fnormal(evalf[d](combine(eval(p, x= C))), d))
> (max(14, length(norm(p,1))))= 0,subs(cos(x)= x,map(q-> q[1]
> ,factors(expand(Cos(2*denom(op(C)), x)) - 1)[2])))[]:

Applied to your cos(Pi/13) example:

> MinPolyCos(cos(Pi/13),x);

            6       5       4       3       2          
        64 x  - 32 x  - 80 x  + 32 x  + 24 x  - 6 x - 1

> convert(cos(Pi/13),RootOf);

      /                 2        3        4        5        6  
RootOf\-1 - 6 _Z + 24 _Z  + 32 _Z  - 80 _Z  - 32 _Z  + 64 _Z , 

              \
  0.9709418174/

At least one person has mentioned Chebychev polynomial T_n, see A&S 22.3.15, for producing a polynomial P(x) such that P(cos(m*Pi/n)) is zero.

Dave Rusin has made some informative posts (elsewhere) on quintics and radicals, if I remember.

@Axel Vogt With Maple 12,

solve(32*c^5-16*c^4-32*c^3+12*c^2+6*c-1, c, Explicit);

@Axel Vogt With Maple 12,

solve(32*c^5-16*c^4-32*c^3+12*c^2+6*c-1, c, Explicit);

First 27 28 29 30 31 32 33 Last Page 29 of 81