HP Forums

Full Version: XCAS wins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Although XCAS is an open source free software, it is still very strong in some aspects, such as dealing with the trigonometric simplification problem.

Less nonsense, please see the XCAS code
Code:
simplify(product(sin(k*pi/214),k,1,106))
XCAS got the exact answer
Code:
(sqrt(107))/81129638414606681695789005144064
We are looking at the performance of Maple2018
Code:
simplify(product(sin(k*pi/214),k=1..106),trig)
But given a bloated answer
Code:
   /101   \    /51    \    /103   \    /52    \    /105   \    /
sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|
   \214   /    \107   /    \214   /    \107   /    \214   /    \

  53    \    /67    \    /34    \    /69    \    /35    \    /71    
  --- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi
  107   /    \214   /    \107   /    \214   /    \107   /    \214   

  \    /36    \    /73    \    /37    \    /75    \    /38    \ 
  | sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| 
  /    \107   /    \214   /    \107   /    \214   /    \107   / 

     /77    \    /39    \    /79    \    /40    \    /81    \    /
  sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|
     \214   /    \107   /    \214   /    \107   /    \214   /    \

  41    \    /83    \    /42    \    /85    \    /43    \    /87    
  --- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi
  107   /    \214   /    \107   /    \214   /    \107   /    \214   

  \    /44    \    /89    \    /45    \    /91    \    /46    \ 
  | sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| 
  /    \107   /    \214   /    \107   /    \214   /    \107   / 

     /93    \    /47    \    /95    \    /48    \    /97    \    /
  sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|
     \214   /    \107   /    \214   /    \107   /    \214   /    \

  49    \    /99    \    /50    \    /33    \    /17    \    /35    
  --- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi
  107   /    \214   /    \107   /    \214   /    \107   /    \214   

  \    /18    \    /37    \    /19    \    /39    \    /20    \ 
  | sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| 
  /    \107   /    \214   /    \107   /    \214   /    \107   / 

     /41    \    /21    \    /43    \    /22    \    /45    \    /
  sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|
     \214   /    \107   /    \214   /    \107   /    \214   /    \

  23    \    /47    \    /24    \    /49    \    /25    \    /51    
  --- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi
  107   /    \214   /    \107   /    \214   /    \107   /    \214   

  \    /26    \    /53    \    /27    \    /55    \    /28    \ 
  | sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| 
  /    \107   /    \214   /    \107   /    \214   /    \107   / 

     /57    \    /29    \    /59    \    /30    \    /61    \    /
  sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|
     \214   /    \107   /    \214   /    \107   /    \214   /    \

  31    \    /63    \    /32    \    /65    \    /33    \    / 1    
  --- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi
  107   /    \214   /    \107   /    \214   /    \107   /    \214   

  \    / 1    \    / 3    \    / 2    \    / 5    \    / 3    \ 
  | sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| 
  /    \107   /    \214   /    \107   /    \214   /    \107   / 

     / 7    \    / 4    \    / 9    \    / 5    \    /11    \    /
  sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|
     \214   /    \107   /    \214   /    \107   /    \214   /    \

   6    \    /13    \    / 7    \    /15    \    / 8    \    /17    
  --- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi
  107   /    \214   /    \107   /    \214   /    \107   /    \214   

  \    / 9    \    /19    \    /10    \    /21    \    /11    \ 
  | sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| 
  /    \107   /    \214   /    \107   /    \214   /    \107   / 

     /23    \    /12    \    /25    \    /13    \    /27    \    /
  sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|
     \214   /    \107   /    \214   /    \107   /    \214   /    \

  14    \    /29    \    /15    \    /31    \    /16    \
  --- pi| sin|--- pi| sin|--- pi| sin|--- pi| sin|--- pi|
  107   /    \214   /    \107   /    \214   /    \107   /

Let's take a look at the performance of Wolfram Mathematica 11.3
Code:
FullSimplify@Product[Sin[k*Pi/214], {k, 1, 106}]
For a long time, it is estimated that it has not been calculated.

But still give the answer, but it is very bad
Code:
(Csc[\[Pi]/214]^3 Csc[(3 \[Pi])/214] Csc[(5 \[Pi])/214]^2 Csc[(
    7 \[Pi])/214] Csc[(9 \[Pi])/214]^4 Csc[(11 \[Pi])/214] Csc[(
    13 \[Pi])/214]^2 Csc[(15 \[Pi])/214] Csc[(17 \[Pi])/214]^3 Csc[(
    19 \[Pi])/214] Csc[(21 \[Pi])/214]^2 Csc[(23 \[Pi])/214] Csc[(
    25 \[Pi])/214]^5 Csc[(27 \[Pi])/214] Csc[(29 \[Pi])/214]^2 Csc[(
    31 \[Pi])/214] Csc[(33 \[Pi])/214]^3 Csc[(35 \[Pi])/214] Csc[(
    37 \[Pi])/214]^2 Csc[(39 \[Pi])/214] Csc[(41 \[Pi])/214]^4 Csc[(
    43 \[Pi])/214] Csc[(45 \[Pi])/214]^2 Csc[(47 \[Pi])/214] Csc[(
    49 \[Pi])/214]^3 Csc[(51 \[Pi])/214] Csc[(53 \[Pi])/
    214]^2 Sin[\[Pi]/107]^4 Sin[(2 \[Pi])/107] Sin[(3 \[Pi])/
    107]^2 Sin[(4 \[Pi])/107] Sin[(5 \[Pi])/107]^3 Sin[(6 \[Pi])/
    107] Sin[(7 \[Pi])/107]^2 Sin[(8 \[Pi])/107] Sin[(9 \[Pi])/
    107]^5 Sin[(10 \[Pi])/107] Sin[(11 \[Pi])/107]^2 Sin[(12 \[Pi])/
    107] Sin[(13 \[Pi])/107]^3 Sin[(14 \[Pi])/107] Sin[(15 \[Pi])/
    107]^2 Sin[(16 \[Pi])/107] Sin[(17 \[Pi])/107]^4 Sin[(18 \[Pi])/
    107] Sin[(19 \[Pi])/107]^2 Sin[(20 \[Pi])/107] Sin[(21 \[Pi])/
    107]^3 Sin[(22 \[Pi])/107] Sin[(23 \[Pi])/107]^2 Sin[(24 \[Pi])/
    107] Sin[(25 \[Pi])/107]^6 Sin[(26 \[Pi])/
    107])/40564819207303340847894502572032



So, XCAS wins

Since the HP prime RAM memory is too small, it is restarted.


Looking forward to hp prime's first new firmware update in 2019, expecting CAS update to 1.51-29
It is refreshing to read here something positive about xcas. :-)
Good news!
Thanks!
It seems this always work ... Can anyone prove it ? Huh

p(n) := {local k; product(sin(k/n * pi/2), k, 1, n-1)}

Prove p(n) = √(n) / 2n-1

Example:
p(2) = sin(pi/2) = √(2) / 2¹
p(3) = sin(1/3 pi/2) sin(2/3 pi/2) = (1/2)(√(3)/2) = √(3)/2²
p(4) = sin(1/4 pi/2) sin(2/4 pi/2) sin(3/4 pi/2) = 1/4 = √(4)/2³

And, the one from first post: p(107) = √(107)/2106

Update: got the proof online: https://math.stackexchange.com/questions...ect=1&lq=1
Found a nice proof from the book "An Imaginary Tale, The Story of √ (-1)", by Paul Nahin, p71-72
Note: book proof actually does product of cos, then flip to sin, using \(\cos(\pi/2-x) = \sin(x)\)

Proof: \(\displaystyle\prod _{k=1}^{n-1} \sin \left({k \pi \over 2n}\right) = { \sqrt{n} \over 2^{n-1}}\)

For \(z^{2n} = 1\), we have 2 real roots ±1, and 2(n-1) complex roots, spread out evenly over complex unit circle.
Each complex root, paired with its conjugate, producing quadratic factor: \((z - r)(z - 1/r) = z^2 - (r+1/r)z + 1\)

\(z^{2n} - 1 = (z^2-1) \displaystyle\prod _{k=1}^{n-1}(z^2 - 2\cos\left({k \pi \over n}\right)z + 1)\)

Divide both side by \(z^n\)

\(z^n - 1/z^n = (z-1/z) \displaystyle\prod _{k=1}^{n-1}((z+1/z) - 2\cos\left({k \pi \over n}\right))\)

Let \(z = e^{i θ}\), we have:

\(2i\sin (nθ) = (2i\sin θ) \displaystyle\prod _{k=1}^{n-1}(2\cos θ - 2\cos\left({k \pi \over n}\right))\)

Now, this is the trick to remove θ. Divide both side by \(2i\sin θ\), and take the limit when θ → 0

\(n = 4^{n-1} \displaystyle\prod _{k=1}^{n-1}{1-2\cos\left({k \pi \over n}\right) \over 2}
= 4^{n-1} \displaystyle\prod _{k=1}^{n-1}\sin^2\left({k \pi \over 2n}\right)
\)

Divide both side by 4n-1, and take the square root, the proof is done. Smile
(02-23-2019 06:22 PM)parisse Wrote: [ -> ]Good news!
Thanks!

We need a new HP Prime +
with much more RAM for full Xcas implementation - is 2 GB RAM enough?
Is this possible by Professeur de mathématiques?

by HP?
(02-23-2019 03:05 PM)chromos Wrote: [ -> ]It is refreshing to read here something positive about xcas. :-)

Agree.
(12-16-2019 01:44 PM)CyberAngel Wrote: [ -> ]
(02-23-2019 06:22 PM)parisse Wrote: [ -> ]Good news!
Thanks!

We need a new HP Prime +
with much more RAM for full Xcas implementation - is 2 GB RAM enough?
Is this possible by Professeur de mathématiques?

by HP?

Look how far we've come in the last 50 years. Around the time of the HP 67, 224 bytes with the ability to load cards was revolution. Now we are talking potentially 2 GB RAM on calculators.
There is enough ram for a full Xcas implementation on the Prime. But there are licensing issues for some GPL libraries used by Xcas, and probably also compiling issues (I don't know if it's possible to compile with exceptions for example).
Vosotros (profesores y desarrolladores acreditados y grandes programadores e ingenieros) que tienen el poder, pueden seguir desarrollando en conjunto el motor numérico y simbólico de Xcas, reescribiendo bibliotecas totalmente libres, hardware más poderoso con pantalla más amplia y como sistema embebido dedicado NUM-CAS.

You (accredited professors and developers and great programmers and engineers) who have the power, can continue to jointly develop the Xcas numerical and symbolic engine, rewriting totally free libraries, more powerful hardware with a wider screen and as a dedicated integrated NUM-CAS system.
Compsystem,
You can use an iPad for better hardware (?) and a larger screen.
Install "PocketCAS Pro" App on it. This App is based on GIAC and Xcas.
Then also install the HP-Prime Pro App (then you also have a slightly larger screen).
You also have access to WiFi, the internet and a lot of GB of memory, etc.

IMHO, the HP-Prime is a calculator and not a handheld computer system, it has a lot of memory (the G2) with a nice color touch screen and bugs free (or nearly bugs free).

HP-Prime team (and all forum members),
Happy Christmas and a happy new year!

(No, I do not have shares in PocketCAS and in HP!)
(12-18-2019 01:08 PM)Dirk.nl Wrote: [ -> ]Compsystem,
You can use an iPad for better hardware (?) and a larger screen.
Install "PocketCAS Pro" App on it. This App is based on GIAC and Xcas.
Then also install the HP-Prime Pro App (then you also have a slightly larger screen).
You also have access to WiFi, the internet and a lot of GB of memory, etc.

IMHO, the HP-Prime is a calculator and not a handheld computer system, it has a lot of memory (the G2) with a nice color touch screen and bugs free (or nearly bugs free).

HP-Prime team (and all forum members),
Happy Christmas and a happy new year!

(No, I do not have shares in PocketCAS and in HP!)
You are right. I think that is what the thinking at HP goes as far as calcs are concerned. Why build extra hardware when better exists on pads and phones? I just updated HP Prime Plus on my IPhone and iPad and so far it does works with no crashes, but haw long it will last that way? Who knows. Personally I would like clam shell vertical or horizontal with some rows, one or two, for programmable soft keys. That would be powerful clac with lots of space for powerful hardware and lots of memory. The screen would be bigger as well, so full implementation of XCAS possible. Just dreaming. Oh, I forgot they could also iron out all the bugs etc. etc.
(12-18-2019 10:50 PM)John P Wrote: [ -> ]
(12-18-2019 01:08 PM)Dirk.nl Wrote: [ -> ]Compsystem,
You can use an iPad for better hardware (?) and a larger screen.
Install "PocketCAS Pro" App on it. This App is based on GIAC and Xcas.
Then also install the HP-Prime Pro App (then you also have a slightly larger screen).
You also have access to WiFi, the internet and a lot of GB of memory, etc.

IMHO, the HP-Prime is a calculator and not a handheld computer system, it has a lot of memory (the G2) with a nice color touch screen and bugs free (or nearly bugs free).

HP-Prime team (and all forum members),
Happy Christmas and a happy new year!

(No, I do not have shares in PocketCAS and in HP!)
You are right. I think that is what the thinking at HP goes as far as calcs are concerned. Why build extra hardware when better exists on pads and phones? I just updated HP Prime Plus on my IPhone and iPad and so far it does works with no crashes, but haw long it will last that way? Who knows. Personally I would like clam shell vertical or horizontal with some rows, one or two, for programmable soft keys. That would be powerful clac with lots of space for powerful hardware and lots of memory. The screen would be bigger as well, so full implementation of XCAS possible. Just dreaming. Oh, I forgot they could also iron out all the bugs etc. etc.

Because I need the real keys
Reference URL's