From: Roland S. <sal...@gm...> - 2017-07-18 11:04:55
Attachments:
Simplfication problem.wxmx
|
The following term I don't manage to simplify, neither in trigonometric nor in exponentialized form nor with ntrig: a:(-1-cos(4*%pi/5)+%i*sin(4*%pi/5))/(1-cos(4*%pi/5)+%i*sin(4*%pi/5)); rectform(a); float(%); By exponentialization I get b:exponentialize(a); radcan(b); I'm pretty sure the term is identical with c:sqrt(5-2*sqrt(5))*%i/sqrt(5); float(c); Using load(ntrig); gives from a: a:(-1-cos(4*%pi/5)+%i*sin(4*%pi/5))/(1-cos(4*%pi/5)+%i*sin(4*%pi/5)); rectform(%); radcan(%); -> d:(sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i)/(2*sqrt(5)+10); which again I cannot simplify to c. How can simplification a -> c or b -> c or d -> c be achieved? A wxmx file is annexed. Thanks for any help. Best regards, Roland |
From: Barton W. <wi...@un...> - 2017-07-18 13:04:46
|
Maybe something like: (%i2) load(ntrig)$ (%i3) a:(-1-cos(4*%pi/5)+%i*sin(4*%pi/5))/(1-cos(4*%pi/5)+%i*sin(4*%pi/5))$ (%i4) trigrat(a); (%o4) (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20 --Barton ________________________________ From: Roland Salz <sal...@gm...> Sent: Tuesday, July 18, 2017 6:04:44 AM To: max...@li... Subject: [Maxima-discuss] Simplification of a trigonometric or exponentialized term The following term I don’t manage to simplify, neither in trigonometric nor in exponentialized form nor with ntrig: a:(-1-cos(4*%pi/5)+%i*sin(4*%pi/5))/(1-cos(4*%pi/5)+%i*sin(4*%pi/5)); rectform(a); float(%); By exponentialization I get b:exponentialize(a); radcan(b); I’m pretty sure the term is identical with c:sqrt(5-2*sqrt(5))*%i/sqrt(5); float(c); Using load(ntrig); gives from a: a:(-1-cos(4*%pi/5)+%i*sin(4*%pi/5))/(1-cos(4*%pi/5)+%i*sin(4*%pi/5)); rectform(%); radcan(%); -> d:(sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i)/(2*sqrt(5)+10); which again I cannot simplify to c. How can simplification a -> c or b -> c or d -> c be achieved? A wxmx file is annexed. Thanks for any help. Best regards, Roland |
From: Roland S. <sal...@gm...> - 2017-07-18 15:39:01
|
Thanks, Barton. That's little better than what I had achieved in (%o20). I did not have the idea to use trigrat, because the expression resulting from your (%i3) does not have any trigonometric functions left, only square roots. But your result is still far away from the simple expression c. I assume Maxima does not have any guideline regarding to which is the simplest version of this expression of nested square roots. And in order to verify identity of your (%o4) with my c, I would have to do it manually. Maxima does not simplfy, if I build the difference of the two, and I don't see any way how to simplify this difference to zero. But the floats indicate clearly that the terms should be identical. Roland From: Barton Willis [mailto:wi...@un...] Sent: Tuesday, July 18, 2017 3:05 PM To: Roland Salz; max...@li... Subject: Re: [Maxima-discuss] Simplification of a trigonometric or exponentialized term Maybe something like: (%i2) load(ntrig)$ (%i3) a:(-1-cos(4*%pi/5)+%i*sin(4*%pi/5))/(1-cos(4*%pi/5)+%i*sin(4*%pi/5))$ (%i4) trigrat(a); (%o4) (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20 --Barton |
From: Raymond T. <toy...@gm...> - 2017-07-18 19:21:23
|
>>>>> "Roland" == Roland Salz <sal...@gm...> writes: Roland> Thanks, Barton. That’s little better than what I had Roland> achieved in (%o20). I did not have the idea to use Roland> trigrat, because the expression resulting from your (%i3) Roland> does not have any trigonometric functions left, only Roland> square roots. Roland> Roland> But your result is still far away from the simple Roland> expression c. I assume Maxima does not have any guideline Roland> regarding to which is the simplest version of this Roland> expression of nested square roots. And in order to verify Roland> identity of your (%o4) with my c, I would have to do it Roland> manually. Maxima does not simplfy, if I build the Roland> difference of the two, and I don’t see any way how to Roland> simplify this difference to zero. But the floats indicate Roland> clearly that the terms should be identical. Here is one way. Take Barton's result: c: (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20 c^2; ratsimp(sqrt(expand(%))),algebraic; => sqrt(5-2*sqrt(5))*%i/sqrt(5) The c^2 and expand is a hack to get maxima to multiply the contents of the sqrt together. This really only works because the imagpart is positive. Otherwise, we probably would have gotten the wrong sign. -- Ray |
From: Roland S. <sal...@gm...> - 2017-07-19 22:11:05
|
> -----Original Message----- > From: Raymond Toy [mailto:toy...@gm...] > Sent: Tuesday, July 18, 2017 9:21 PM > > Here is one way. Take Barton's result: > > c: (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20 > c^2; > ratsimp(sqrt(expand(%))),algebraic; > > => sqrt(5-2*sqrt(5))*%i/sqrt(5) > > The c^2 and expand is a hack to get maxima to multiply the contents of the sqrt together. This really only works > because the imagpart is positive. Otherwise, we probably would have gotten the wrong sign. > True. Unfortunately, my problem consists of 4 such expressions, and two of them are negative imaginary numbers. Take for example the expression -c. The sign is lost. Is there another hack to simplify the general case? Or would I have to write my own routine that memorizes the sign and adjusts it at the end accordingly? PS: Stavros' general algorithm I did not dare to ask about this new situation yet ... Best regards, Roland |
From: Roland S. <sal...@gm...> - 2017-07-18 19:55:18
|
> -----Original Message----- > From: Raymond Toy [mailto:toy...@gm...] > > Here is one way. Take Barton's result: > > c: (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20 > c^2; > ratsimp(sqrt(expand(%))),algebraic; > > => sqrt(5-2*sqrt(5))*%i/sqrt(5) > > The c^2 and expand is a hack to get maxima to multiply the contents of the sqrt together. This really only works > because the imagpart is positive. Otherwise, we probably would have gotten the wrong sign. > Great! There seems to be a magic word for everything in Maxima. Thanks a lot to both of you! Roland |
From: Richard F. <fa...@be...> - 2017-07-18 20:52:31
|
in general those nested roots are ambiguous because there are 2 sqrts. The fact that float() gets the "right" result is partly concidence. On the other hand, it is a useful (if theoretically dubious) technique to evaluate expressions to floating-point numbers to see if they are the same, just as originally posted. RJF On 7/18/2017 12:55 PM, Roland Salz wrote: >> -----Original Message----- >> From: Raymond Toy [mailto:toy...@gm...] >> >> Here is one way. Take Barton's result: >> >> c: (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20 >> c^2; >> ratsimp(sqrt(expand(%))),algebraic; >> >> => sqrt(5-2*sqrt(5))*%i/sqrt(5) >> >> The c^2 and expand is a hack to get maxima to multiply the contents of the sqrt together. This really only works >> because the imagpart is positive. Otherwise, we probably would have gotten the wrong sign. >> > Great! There seems to be a magic word for everything in Maxima. Thanks a lot to both of you! > > Roland > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss |
From: Stavros M. (Σ. Μ. <mac...@al...> - 2017-07-18 23:18:01
|
It's easy enough to try *all* sequences of simplification you want to explore: multif_fixedpoint(new,funs) := block([done:new], while new#{} do ( new: setdifference(setify(create_list(apply(func,[i]),func,funs,i,listify(new))), done), done: union(new,done), if length(new)>30 or length(done)>50 /* catch over-expansion */ then (global_new: new, global_done: done, error("overflow")) /* assign to global_x for debugging */ ), done); ratsimp_alg(ex) := block([algebraic:true],ratsimp(ex))$ squaresimp(ex) := ratsimp_alg(sqrt(expand(ex^2)))$ squaresimpf(ex) := ratsimp_alg(sqrt(factor(ex^2)))$ partfracx(ex) := partfrac(ex,'x)$ load(ntrig)$ testx : expand( (-1-cos(4*%pi/5)+%i*sin(4*%pi/5))/(1-cos(4*%pi/5)+%i*sin(4*%pi/5)), 0 , 0)$ test1() := multif_fixedpoint( { testx }, '[ratsimp,ratsimp_alg,squaresimp,squaresimpf,partfracx,radcan,rectform])$ ... you might want to add, say, factor or factorsum or any other value-preserving transformation ... Now tt: test1() => { (sqrt(5-2*sqrt(5))*%i)/sqrt(5), (sqrt(5-2*sqrt(5))*%i)/sqrt(5), (sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i)/(2*sqrt(5)+10), (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20, ((((1-((-sqrt(5))-1)/4)*(sqrt(5)-1)*sqrt(sqrt(5)+5))/2^(5/2)-(((-((-sqrt(5))-1)/4)-1)*(sqrt(5)-1)*sqrt(sqrt(5)+5))/2^(5/2))*%i)/(((sqrt(5)-1)^2*(sqrt(5)+5))/32+(1-((-sqrt(5))-1)/4)^2)+(((sqrt(5)-1)^2*(sqrt(5)+5))/32+((-((-sqrt(5))-1)/4)-1)*(1-((-sqrt(5))-1)/4))/(((sqrt(5)-1)^2*(sqrt(5)+5))/32+(1-((-sqrt(5))-1)/4)^2), ((sqrt(sqrt(5)+5)*(2*sqrt(5)+10)*(sqrt(2)*sqrt(5)-sqrt(2))-sqrt(sqrt(5)+5)*(2*sqrt(5)-6)*(sqrt(2)*sqrt(5)-sqrt(2)))*%i)/((sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))^2+(2*sqrt(5)+10)^2)+((sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))^2+(2*sqrt(5)-6)*(2*sqrt(5)+10))/((sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))^2+(2*sqrt(5)+10)^2), (sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i+2*sqrt(5)-6)/(sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i+2*sqrt(5)+10), (((sqrt(5)-1)*sqrt(sqrt(5)+5)*%i)/2^(5/2)-((-sqrt(5))-1)/4-1)/(((sqrt(5)-1)*sqrt(sqrt(5)+5)*%i)/2^(5/2)-((-sqrt(5))-1)/4+1) } Let's sort those by length (as a proxy for simplicity): sort(listify(tt),lambda([a,b],slength(string(a))<slength(string(b)))) => [ (sqrt(5-2*sqrt(5))*%i)/sqrt(5), (sqrt(5-2*sqrt(5))*%i)/sqrt(5), <<< see below (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20, (sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i)/(2*sqrt(5)+10), (sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i+2*sqrt(5)-6)/(sqrt(sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))*%i+2*sqrt(5)+10), (((sqrt(5)-1)*sqrt(sqrt(5)+5)*%i)/2^(5/2)-((-sqrt(5))-1)/4-1)/(((sqrt(5)-1)*sqrt(sqrt(5)+5)*%i)/2^(5/2)-((-sqrt(5))-1)/4+1), ((sqrt(sqrt(5)+5)*(2*sqrt(5)+10)*(sqrt(2)*sqrt(5)-sqrt(2))-sqrt(sqrt(5)+5)*(2*sqrt(5)-6)*(sqrt(2)*sqrt(5)-sqrt(2)))*%i)/((sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))^2+(2*sqrt(5)+10)^2)+((sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))^2+(2*sqrt(5)-6)*(2*sqrt(5)+10))/((sqrt(5)+5)*(sqrt(2)*sqrt(5)-sqrt(2))^2+(2*sqrt(5)+10)^2), ((((1-((-sqrt(5))-1)/4)*(sqrt(5)-1)*sqrt(sqrt(5)+5))/2^(5/2)-(((-((-sqrt(5))-1)/4)-1)*(sqrt(5)-1)*sqrt(sqrt(5)+5))/2^(5/2))*%i)/(((sqrt(5)-1)^2*(sqrt(5)+5))/32+(1-((-sqrt(5))-1)/4)^2)+(((sqrt(5)-1)^2*(sqrt(5)+5))/32+((-((-sqrt(5))-1)/4)-1)*(1-((-sqrt(5))-1)/4))/(((sqrt(5)-1)^2*(sqrt(5)+5))/32+(1-((-sqrt(5))-1)/4)^2) ] Let's evaluate numerically to check that they are equivalent: map(lambda([ex],rectform(float(ex))),tt) => {0.3249196962329062*%i+3.068580969878509e-17,0.3249196962329063*%i+3.068580969878509e-17,0.3249196962329063*%i-2.775557561562891e-17,0.3249196962329063*%i+6.938893903907228e-17,0.3249196962329063*%i,0.3249196962329063*%i,0.3249196962329066*%i} which looks good, I guess, especially if you look at the cabs: map(cabs,%o148); => {0.3249196962329062,0.3249196962329063,0.3249196962329063,0.3249196962329066} You might have noticed something funny about the first two expressions in tt, though: they print identically, but they are not equal, because they are not the same internally. This is a bug. In fact, there are multiple ways of getting the wrong version of that expression (wrong means that resimplifying with expand(ex,0,0) doesn't give the same result as ex). My guess is that they are all being generated by ratdisrep, but I'm not going to investigate right now.... The procedure can also go wrong if you add a function to the list which makes bigger and bigger expressions. An example? rootscontract.... Have fun, -s On Tue, Jul 18, 2017 at 4:52 PM, Richard Fateman <fa...@be...> wrote: > in general those nested roots are ambiguous > because there are 2 sqrts. The fact that float() > gets the "right" result is partly concidence. > > On the other hand, it is a useful (if theoretically > dubious) technique to evaluate expressions to > floating-point numbers to see if they are the same, > just as originally posted. > > RJF > > On 7/18/2017 12:55 PM, Roland Salz wrote: > >> -----Original Message----- >>> From: Raymond Toy [mailto:toy...@gm...] >>> >>> Here is one way. Take Barton's result: >>> >>> c: (sqrt(sqrt(5)+5)*(3*sqrt(2)*sqrt(5)-5*sqrt(2))*%i)/20 >>> c^2; >>> ratsimp(sqrt(expand(%))),algebraic; >>> >>> => sqrt(5-2*sqrt(5))*%i/sqrt(5) >>> >>> The c^2 and expand is a hack to get maxima to multiply the contents of >>> the sqrt together. This really only works >>> because the imagpart is positive. Otherwise, we probably would have >>> gotten the wrong sign. >>> >>> Great! There seems to be a magic word for everything in Maxima. Thanks a >> lot to both of you! >> >> Roland >> >> >> >> ------------------------------------------------------------ >> ------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> Maxima-discuss mailing list >> Max...@li... >> https://lists.sourceforge.net/lists/listinfo/maxima-discuss >> > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |