Existing CAS commands > Prime discussion

06262017, 06:40 PM
(This post was last modified: 06262017 07:23 PM by Tim Wessman.)
Post: #1




Existing CAS commands > Prime discussion
First, let me explain that this is not a promise to add everything, nor a promise to add ANYTHING. It is simply a place for those interested in potentially getting commands that already exist in the CAS added to Prime, and discuss the merits and reasons behind adding a command. Having rational and reasoned discussion about commands will be the best way to encourage them to be added.
Quantity will not win out here. Quality and reason will. A 20 page post with pictures is not the way to explain best in any case I can possibly imagine. Please, respond to my questions and educate my poor math skills as to why certain things need inclusion. I am listening and hoping to be wrong. I am especially weak when it comes to linear algebra/matrix type stuff as I stopped at the introduction level courses for my degree in university. Thanks! Note, these are the rules and thought I personally tend to use when I look at adding a command:
These thoughts are all things that go through my head when I look at adding or supporting something. It is a balancing act. Remember that EACH bit of text or documentation is multiplied by <number_of_languages> and thus even "small items" can result in large amount of additional translations. Small changes an ripple into large ones and impact much more then just a few minutes of my time. Developer time, testing time, documentation time, trade offs between things that we might *otherwise* be doing.... all have to be considered. Without further ado, and starting from the items in the other thread, here is my thoughts/response to Joe's list. Note that I do have the full xcas english documentation and consult it regularly. It is quite out of date in some areas though by this point. :/ Items I immediately see an issue with: Quote: Items I can see without much trouble might be useful: Quote:adjoint_matrix  yes Commands in permutations/cycles stuff. These were deliberately left out of the CAS at first due to focus on more core thigns. I can probably see an argument to add them now: (any missing from this list?) Quote:cycle2perm  Items already turned on, or have the capability already: Quote:fdistrib  Already in there, expand is a synonym Items turned on in source, means would be in next, if any, release comes in the future most likely: Quote:chisquaret Here are items I have questions about or don't understand the purpose: Quote:as_function_of  doesn't seem to function in my xcas install. as_function_of(b,a) returns an error Other commands mentioned: Quote:nop  this doesn't do anything, what would I document with resepct to "using" it? Finally, items that fail to pass the "only Joe is interested in it" test: :P Quote:dfc < :( Joe really likes him some continued fractions. Yessireee that man do like them. Feel free to suggest any further items or commands you think should be added. TW Although I work for the HP calculator group, the views and opinions I post here are my own. 

06262017, 09:53 PM
Post: #2




RE: Existing CAS commands > Prime discussion
(06262017 06:40 PM)Tim Wessman Wrote: Note, these are the rules and thought I personally tend to use when I look at adding a command: Quote:...Finally, items that fail to pass the "only Joe is interested in it" test: :P Oh, phooey. Quote:Joe really likes him some continued fractions. Yessireee that man do like them. Yes, and I learned the bittersweet reason for that during a crosscountry motorcycle trip with my dad in 1990: Me: "Dad, some of these guys seem to live on their bikes. Why do some people like riding motorcycles so much?" Dad: "Because everybody loves forever whatever they were thinking about at the pinnacle of their intellectual development." <0ɸ0> Joe 

06272017, 02:30 AM
Post: #3




RE: Existing CAS commands > Prime discussion
I'm traveling so I cannot give a complete view but just immediately from the lists you have questions on.
simplex_reduce is key in classic optimization / Linear Programming. I would say any Optimization class will cover this at the 101 level. would be great to have this by default instead of programming it our selves (been there). Also great if it can perform the calculations staying in the rational (Z) domain if all coefficients are in Z (I think it can stay in Z in Xcas). Of course if has to work in the real domain (R) but that is a give. is_pseudoprime is important in crypto. A network/internet/crypto security class could cover some of this. So useful in computer science/engineering. You are right in that "zeros" and "czeros" covers rationalroot, crationalroot. realroot, i.e. rationalroot, crationalroot. realroot do not give us anything new. Is Z/pZ and Z/pZ[x] implemented as in Xcas? Not sure (for vectors etc). Have not tested all. dfc and dfc2f are helpful educationally in analytic theory, real and complex analysis so why not implement it? Understand the licensing issue with Airy_Ai and Airy_Bi. Is there another way to get them? Really happy to see that below are potential candidates  great additions to probability: chisquaret kolmogorovd kolmogorovt multinomial randvector wilcoxonp wilcoxons wilcoxont Great that also that these are considered: adjoint_matrix bernoulli blockmatrix changebase colspace genpoly makevector isom rowspace tcoeff Thanks! 

06272017, 05:04 AM
Post: #4




RE: Existing CAS commands > Prime discussion
Some comments:
as_function_of is more an internal function than something else, it is used by locus to build a function from a construction. For example in an Xcas session enter a:=1; b:=a*x+1; as_function_of(b,a) is_prime is the same as is_pseudoprime on the Prime, it links to PARI in Xcas. c1oc2 and c1op2 are there in Xcas, it's a 1 not a l, read this as compose permutation as a cycle 1 with permutation as a cycle 2 or as a permutation 2. Same for p1oc2 and p1op2 conique_reduite and quadrique_reduite have been translated to reduced_conic and reduced_quadric, the French keywords work only if you have selected French. realroot is not the same functionnality as zeros or proot. zeros is an exact algorithm to find exact roots, proot is an approx algorithm to find approx roots, while realroot is an exact algorithm to find isolation interval for roots, it means you have a proof that there is 1 and exactly 1 root in the returned intervals. makevector is not really useful, just put bracket on the sequence. Z/pZ is available on the Prime, but you must enter %% instead of % in Xcas. I don't want to make change to the parser that could have side effects, therefore I don't want to enable user_operator . combine: it was added for maple compat. SortA and SortD: added for TI compat. count_eq, count_inf and count_sup were added at the request of teachers using Xcas, because they don't want to explain how to use count : count is indeed more elaborate since you must pass a function to a command 

06272017, 02:24 PM
Post: #5




RE: Existing CAS commands > Prime discussion
(06262017 06:40 PM)Tim Wessman Wrote: ord  "Returns the ASCII code of a character or of the first character of a string." Why? Only use I can possibly think is for sorting purposes? I use it to compare nonprintable characters. Code: LOCAL X; Tom L Cui bono? 

06272017, 06:59 PM
Post: #6




RE: Existing CAS commands > Prime discussion
(06272017 01:25 PM)compsystems Wrote:It will not work inside a program, it's designed for locus in the Xcas geometry screen, it is using an internal history mechanism. If you want to build a function from an expression, the right function is unapply.(06272017 05:04 AM)parisse Wrote: as_function_of is more an internal function than something else, it is used by locus to build a function from a construction. For example in an Xcas session enterVery useful for defining functions within a program 

06272017, 09:00 PM
(This post was last modified: 06272017 09:03 PM by Anders.)
Post: #7




RE: Existing CAS commands > Prime discussion
(06272017 05:04 AM)parisse Wrote: Some comments: Sorry if I miss understand you above: isprime on HP Prime return one value either true/false (if it is prime or not = 1/0 =) is_pseudoprime in Xcas returns to values 2/1/0. 2 if it is true prime, 1 if it is a pseudo prime number otherwise it return 0. So not sure what you mean....? For very large numbers I still think is_pseudoprime is very valuable, or do you always calculate if every number is prime fully in isprime on HP Prime regardless on how large the number is? I can see the value of realroot, complexroot and rationalroot for use with polynomial functions. I understand the distinction in how you arrive at the solution (algorithms). I can also see how this is useful in calculus (sign analysis of the function). But then again, if I read you correctly and based on my own experience, zeros() always give you all roots exactly regardless. so... if you have all the roots exactly in Z if possible and also as expression of radicals if possible, if not then a decimal number within +/ epsilon error. So what does realroot give us that zeros() does not. Same applies to complexroot() vs czeros(). Great that Z/pZ works 1:1 :) also with vectors and matrices 

06282017, 08:40 AM
Post: #8




RE: Existing CAS commands > Prime discussion
isprime on the Prime returns 1 if the number is pseudoprime, it is not a proof of primality (except for "small" numbers) and there is nothing on the Prime to return a certificate of primality.
About roots: most of the time, proot will return accurate roots, but it may fail for very specific polynomials that have two roots almost identical (and zeros will almost never be able to return exact roots). Classical example is Mignotte polynomial mig(n,t):=x^n((2^(t/2)1)*x1)^2 For example mig(257,14)==x^257(127*x1)^2 has two roots near 1/127. realroot finds these roots with precision 1e15 in about 0.03s on my computer, proot requires more than 6s (of course it also computes complex roots). 

07012017, 07:27 PM
Post: #9




RE: Existing CAS commands > Prime discussion
Here's a useful CAS "command" (syntax, really) that’s already implemented, but not documented or sensibly presented in CAS history:
m1:=hilbert(99):; where the emphasized bit suppresses the value returned by the assignment statement, and instead displays nodisp(m1:=hilbert(99)) "Done" in place of the special syntax. Trouble is, nodisp is not defined, so clickcopying and evaluating the history entry nodisp(m1:=hilbert(99)) yields nodisp(m1:=hilbert(99)) ⎛⎡ 1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 1/10 ⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯ nodisp⎜ ⎢1/50 1/51 1/52 1/53 1/54 1/55 1/56 1/57 1/58 1/59 ⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯ ⎝⎣1/99 1/100 1/101 1/102 1/103 1/104 1/105 1/106 1/107 1/108 except with nicer formatting, ninetysix additional rows in place of the ellipses, and preceded by a twentysecond or so delay while the 9,801element matrix of fractions is formatted for display. While defining nodisp(x) := when(type(x) == 0, "Done", "Done") apparently fixes the reevaluation problem, I don’t know enough about either Xcas or the Prime to be certain that this works in the general case*, and it's probably not a reasonable candidate for the “one, and preferably only one” way to do such a simple, fundamental thing as suppressing output of a function called only for its side effects. Including the original ":;" syntax in both history and copy/paste seems like a reasonable solution (assuming, of course, that I haven’t overlooked an existing nonhack alternative!). P.S.: The when expression in my definition shows up in textbookformat history (more or less) as written, but algebraically displays and clickcopies as an (undocumented) Cstyle “p?q:r” conditional operator. P.P.S.: How difficult would it be to provide, at least as an option, an actual history of verbatim, unevaluated input in the history, instead of a prettyprinted representation of the syntax tree after it has been accepted by the evaluator? Because the latter, current behavior has serious downsides that wouldn’t go away if it worked “correctly” in every case. Most important example of why: valid input may nevertheless be mistaken, and it’s much harder to correct mistakes once original “nearly correct” input has been discarded in favor of considerably different “input”, whether or not the latter happens to be semantically equivalent to the original mistaken input. It’s as if a psychotic teacher, instead of marking a student’s incorrect homework and returning it, redid all the work for the wrong answers from scratch in an entirely different way, shredded the original homework, then justified this behavior on the grounds that the “reimagined” errors were logically equivalent to the student’s original mistakes… Less important example: if I’m using the CAS or Home screen to interactively prototype things that will ultimately be pasted into code, the current behavior forces me to either adopt to the history window’s (not necessarily stable between releases, and potentially subject to the whims of very machinelike implementation details) “coding style”, or else waste time either reformatting history or diligently copying everything I may want to save for reuse into the clipboard before evaluating it “just in case”, largely defeating the purpose input history exists to serve. * In particular, I'm assuming without proof that the type function
** While my nodisp definition seems to work as well without the equality test as with, I can’t find any documentation (HP or Xcas) suggesting that the automatic Boolean conversion of what appears to be any (exact or inexact, real or complex, rational or irrational) number is anything more than an implementation detail, so I include the equality test. 

07022017, 05:10 AM
Post: #10




RE: Existing CAS commands > Prime discussion
I understand your PPS, this is the reason why you don't have 2d input by default in Xcas (you must select new expression). It's probably not available on the Prime because it's useful for advanced commandlines.


07102017, 08:46 AM
Post: #11




RE: Existing CAS commands > Prime discussion
(06282017 08:40 AM)parisse Wrote: isprime on the Prime returns 1 if the number is pseudoprime, it is not a proof of primality (except for "small" numbers) and there is nothing on the Prime to return a certificate of primality. ok got it. That means we would need both the isPrime and isPseudoprime functionality from Giac/Xcas to ensure we can make a distinction between true prime functionality and pseudo prime. This would also mean you need to allow the user to press stop to halt the calculator if isPrime take too long time to finish the true prime test. could be done as one function isPrime with a parameter to specific if you are looking for turn prime or pseudo prime (1/0). Understand the distinction between the algoritms used for roots better now. So we need to cover zeros, proot and realroot (including their complex root counterparts) to ensure we can cover all root corner cases, BUT we need to have really great documentation to explain when to use what algorithm to cover all cases. 

08022017, 01:57 PM
(This post was last modified: 08022017 01:58 PM by Eddie W. Shore.)
Post: #12




RE: Existing CAS commands > Prime discussion
Would the Fresnel functions S(x) and C(x) be a problem to implement? What about the elliptical integrals?
The function bernoulli and multinomial get my support. I am going to look up kolmogorovd, kolmogorovt, wilcoxonp, wlicoxons, and wilcoxnt because I don't know what they are. 

08022017, 05:35 PM
Post: #13




RE: Existing CAS commands > Prime discussion
(08022017 01:57 PM)Eddie W. Shore Wrote: Would the Fresnel functions S(x) and C(x) be a problem to implement? What about the elliptical integrals? Fresnel functions S(x) and C(x) was suggested before, but at the time parisse view was that the application was to small to warrant a full implementation in XCAS. However, as S(x)=int(sin(x^2),x,0,x) and C(x)=int(cos(x^2),x,0,x) can be expressed as a function of the erf(x), which is implemented, you can actually do S(x) and C(x) today with some work of your own. See thread here: http://www.hpmuseum.org/forum/thread588...52555.html. I think in the end, parisse went ahead and implemented int(sin(x^2),x,0,x) and int(cos(x^2),x,0,x) in XCAS in terms of erf(x) for finite boundaries in definite integration case. So if you need S(x) you can use the method described in the thread and get it to work today. Of course it would be nice to have it natively implemented as S(x) and C(x) in PRIME hiding all the underlying transformations and so you do not have to do all this yourself. All the others you mentioned get my vote too. 

08052017, 06:40 AM
Post: #14




RE: Existing CAS commands > Prime discussion
Well, I think the study of conics is very important in Geometry, and the HP Prime has no commands just as there are in the competition as the Classpad or Tinspire to analyze graphs of conics, in a parabola for example find The focus the vertex, point of symmetry; In an ellipse the focal distance, or the foci of the parabola or also the eccentricity, which is almost always denoted by the letter "e". And in the same way with other geometric curves.


08072017, 08:28 PM
Post: #15




RE: Existing CAS commands > Prime discussion
(06262017 06:40 PM)Tim Wessman Wrote: Finally, items that fail to pass the "only Joe is interested in it" test: :P Me too! I would love to have this available on a calculator if for nothing else than have students experiment with it. I would certainly use it more than a lot of other commands. (What do the letters dfc stand for anyway?) [I feel like Lot arguing with God: "What if there are only 10 righteous people who want this command?" "For the sake of 10 I will not destroy the command." ] Just a few days ago, a former student sent me a problem that involves a continued fraction of sorts and I haven't been able to figure it out. 

08072017, 08:58 PM
Post: #16




RE: Existing CAS commands > Prime discussion
(08072017 08:28 PM)Wes Loewer Wrote: [I feel like Lot arguing with God: "What if there are only 10 righteous people who want this command?" "For the sake of 10 I will not destroy the command." ] Well, 8 more to go if we use that example... TW Although I work for the HP calculator group, the views and opinions I post here are my own. 

08272017, 04:24 PM
(This post was last modified: 08272017 04:25 PM by Anders.)
Post: #17




RE: Existing CAS commands > Prime discussion
In CAS mode:
How about enable ∡ so it does polar arithmetic algebraically. e.g. 2∡(π/6) * 3∡(π/6) = 6∡(π/3), (2∡(π/6))^2 = 4∡(π/3) etc for at least +,,*, / ^ . Also, how about enable the ∡ button to shift what's in "Ans" between polar and rectangular/Cartesian form algebraically when pressed on it's own (like it does in Home view but in decimal form). e.g. with 4∡(π/3) in Ans pressing ∡ would show 2+2*√3*i pressing ∡ again would return to 4∡(π/3). These functions are used a lot and this would cut out a lot of time wasted in typing the function names and converting between the two forms etc. 

09072017, 02:11 PM
(This post was last modified: 09072017 04:05 PM by Helge Gabert.)
Post: #18




RE: Existing CAS commands > Prime discussion
Tim,
You stated in your first post that syst2mat() seems a little esoteric, but a recent thread suggests that it could be useful http://www.hpmuseum.org/forum/thread8949.html (see last comment by Bernard). Thanks for your consideration. And I could really use, in my daily work for small data sets, the Kolmogorov commands to assess normality. . . 

09082017, 09:57 AM
Post: #19




RE: Existing CAS commands > Prime discussion
I can't see if this has already been mentioned, but is there any chance of higherprecision arithmetic? I know that Xcas can do this but maybe there are licensing issues with the code...
Nigel (UK) 

09082017, 02:53 PM
Post: #20




RE: Existing CAS commands > Prime discussion
The code used for that is in xcas is LGPL based. Since the OS doesn't support linked library loading and we have no mechanism to handle replacement with a different version from the end user...
TW Although I work for the HP calculator group, the views and opinions I post here are my own. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)