Easy question

09012021, 10:10 AM
Post: #1




Easy question
Hello,
I am new to my HP Prime and I am just starting to use it. I just bumped into this problem and I don't get it: 1^(1/3) = 1 but if I use brackets around the 1 I get: Error (1)^(1/3) Sorry, for the newbie question but this is my first HP calculator and I'm trying to understand how it works. Thanks! 

09012021, 11:54 AM
(This post was last modified: 09012021 11:55 AM by roadrunner.)
Post: #2




RE: Easy question  
09012021, 04:02 PM
Post: #3




RE: Easy question
roadrunner wrote:
Quote:In home settings make sure the "Allow complex output from real input" box is checkedYes, this works. But you get a different answer: (1)^(1/3) has the result 0.50.866025i and 1^(1/3) has the result 1 as boggiani wrote. It seems that the calculator interpretes 1^(1/3) as (1^(1/3)). If there are no brackets it should work from left to right. 

09012021, 04:11 PM
(This post was last modified: 09012021 04:13 PM by toml_12953.)
Post: #4




RE: Easy question
(09012021 04:02 PM)rawi Wrote: roadrunner wrote: Look at your list of priority of operations on page 26 of the User's Guide. ^ comes before unary minus. Only operations that are at the same level are evaluated left to right. Algebraic precedence The HP Prime calculator calculates according to the following order of precedence. Functions at the same level of precedence are evaluated in order from left to right. 1. Expressions within parentheses. Nested parentheses are evaluated from inner to outer. 2. !, √, reciprocal, square 3. nth root 4. Power, 10n 5. Negation, multiplication, division, and modulo 6. Addition and subtraction 7. Relational operators (<, >, ≤, ≥, ==, ≠, =) 8. AND and NOT 9. OR and XOR 10. Left argument of  (where) 11. Assign to variable (:=) Tom L Cui bono? 

09062021, 12:36 AM
Post: #5




RE: Easy question
(09012021 04:11 PM)toml_12953 Wrote: ⋮ One wrinkle with the “left to right” rule the guide lays out is that the power operation is evaluated from right to left. 

09062021, 01:17 AM
Post: #6




RE: Easy question  
09062021, 12:41 PM
Post: #7




RE: Easy question
(09062021 01:17 AM)Albert Chan Wrote:(09012021 04:11 PM)toml_12953 Wrote: 8. AND and NOT It wouldn't be the first inconsistency between HOME and CAS environments! The Xcas documentation doesn't seem to describe the precedence of operators in the Giac/Xcas language, but all the boolean operators are described in the same section, so I guess 'and', 'or', and 'xor' are evaluated at the same precedence in lefttoright order. Changing the compatibility mode doesn't seem to make a difference to the operator precedence. — Ian Abbott 

09062021, 05:39 PM
Post: #8




RE: Easy question
(09062021 01:17 AM)Albert Chan Wrote:(09012021 04:11 PM)toml_12953 Wrote: 8. AND and NOT Good note! I tried three of the other evaluation environments (the interval byte code evaluator of the Advanced Graphing app, the BCD byte code evaluator of the Function app, and the Python terminal). ADV_GR> V1: X^2+Y^2<1 OR X>0 AND Y>0 → AND higher prec. than OR FUNCT> F1(X)= true OR false AND false → 1 (AND higher prec. than OR) PYTH> True or False and False → True (AND higher prec. than OR) Getting a consistent evaluation order also involves internal conversions between formats. Error propagation / shortcircuiting is another consideration with logical operations. (The BCD byte code evaluator is more of a “push” evaluator than a “pull” evaluator, so error propagation matching the PPL evaluator’s didn’t just immediately occur naturally during implementation. That said, converting the BCD evaluator to a “pull” approach is something I have on my list of “desirable changes”.) 

09062021, 10:31 PM
Post: #9




RE: Easy question
(09062021 12:41 PM)ijabbott Wrote: ⋮ Seems like a reasonable guess! When I just mentioned the “T ∨ F ∧ F“ to my daughter, she suggested another possibility: perhaps OR is higher precedence than AND in the CAS. So, as an experiment, I tried flipping the expression around and tried “False AND False OR True” in CAS view. “True” is the result. Not a bad illustration of some of the benefits of precedence rules — that, with associative and commutative operations like AND and OR, one may rearrange arguments to the higher precedence operation or to the lower precedence operation (without changing the final result). Since I mentioned trying the evaluation in Python, I thought I’d also try it using Python syntax in the CAS. There, “True or False and False” evaluates to “False”. 

09072021, 01:09 AM
Post: #10




RE: Easy question
(09062021 10:31 PM)jte Wrote: I tried flipping the expression around and tried “False AND False OR True” in CAS view. “True” is the result. This showed CAS OR does not have higher precedence: 0×(0+1) = 0 But, it does not illustrate precedence rule, result is same as left to right: 0×0+1 = 1 Quote:I thought I’d also try it using Python syntax in the CAS. There, “True or False and False” evaluates to “False”. This showed CAS AND does not have higher precedence: 1+0×0 = 1 CAS only does left to right: (1+0)×0 = 0 see Maths in a minute: Boolean algebra 

09092021, 10:44 AM
Post: #11




RE: Easy question
(09012021 04:11 PM)toml_12953 Wrote: Algebraic precedence Ok, so how I have to write an expression like this? (x+1)^(4/5) Thank you 

09092021, 05:40 PM
Post: #12




RE: Easy question
(09092021 10:44 AM)boggiano Wrote: Ok, so how I have to write an expression like this? Exactly like that, especially if you use Algebraic Entry mode (Home Settings). If you use Textbook Entry mode instead, then you can omit the second pair of parentheses, because the 4/5 will all be in the exponent field: \((x+1)^{\frac{4}{5}}\) <0ɸ0> Joe 

09092021, 05:55 PM
Post: #13




RE: Easy question
(09072021 01:09 AM)Albert Chan Wrote: ⋮ Yes, or to be more explicit: this seems to be true (in the CAS) whether or not Python syntax is being used. The following function, defined using Python syntax, flows into (A / True) when using the Prime’s Python evaluator and into (B / False) when using the CAS with Python syntax. Code: def eval_test(): My first test routine, eval_test2(), shown below, was actually to simply return the result of “True or False and False”, and then print it, but it seems there might be an issue with booleans in Pythonsyntax CAS functions on the Prime as eval_test2() returns “(null)” when run as a Pythonsyntax CAS function. Code: def eval_test2(): “On the Prime” as eval_test2() in Xcas (1.7.029), with “Xcas syntax” selected, returns “false”. (Well, Xcas did crash on me once, but I’m thinking that that could’ve been caused by my playing around with things like print_test() — print_test() reliably crashes both Xcas and the Prime CAS. [It is flagged as a syntax error when tried as Python, either in Xcas or in the Prime’s Python.] I’ll send in a bug report.) Code: def print_test(): 

09092021, 06:05 PM
(This post was last modified: 09092021 06:06 PM by boggiano.)
Post: #14




RE: Easy question
(09092021 05:40 PM)Joe Horn Wrote:(09092021 10:44 AM)boggiano Wrote: Ok, so how I have to write an expression like this? Sorry John, but I don't get it. \((x+1)^{\frac{4}{5}}\) with X=2 I get an irrational number. Instead, if I use the " classic notation" (sqrt function + power) I get the right result: 1. I would like to continue to use this notation (it is faster to insert) 

09092021, 10:10 PM
Post: #15




RE: Easy question
(09092021 06:05 PM)boggiano Wrote:(09092021 05:40 PM)Joe Horn Wrote: Exactly like that, especially if you use Algebraic Entry mode (Home Settings). If you use Textbook Entry mode instead, then you can omit the second pair of parentheses, because the 4/5 will all be in the exponent field: I don't see how you get an irrational number. Here's a screenshot: Tom L Cui bono? 

09092021, 10:32 PM
Post: #16




RE: Easy question
(09092021 10:10 PM)toml_12953 Wrote:(09092021 06:05 PM)boggiano Wrote: Sorry John, but I don't get it. And here the mine: (Sorry, I don't know how to take a screenshot!) 

09092021, 11:59 PM
(This post was last modified: 09102021 12:36 AM by ijabbott.)
Post: #17




RE: Easy question
The result of (1)^(4/5) will depend on whether or not you have the "Allow complex output from real input" option turned on or off in the settings. If turned off, you will get the real result 1. If turned on, you will get the complex result 0.809016994375+0.587785252292*i. Also, I think the CAS mode always approximates to the complex result.
Since 1 is e^(i*π), (1)^(4/5) is (e^(i*π))^(4/5), which is e^(i*π*4/5) in exponential form, or 1∡(π*4/5) in polar form (radians mode), or cos(π*4/5)+sin(π*4/5)*i in rectangular form (radians mode). In CAS mode, pow2exp((1)^(4/5)) produces e^((4/5)*i*π). — Ian Abbott 

09102021, 05:23 PM
Post: #18




RE: Easy question
(09092021 11:59 PM)ijabbott Wrote: The result of (1)^(4/5) will depend on whether or not you have the "Allow complex output from real input" option turned on or off in the settings. If turned off, you will get the real result 1. If turned on, you will get the complex result 0.809016994375+0.587785252292*i. Also, I think the CAS mode always approximates to the complex result. HP Prime emulator, 2.1.14181 (2018_10_16), just after a hard reset. From Symbolic Setup, if I pick Complex: Off, (1)^(4/5) gives 0.809016994375+0.587785252292*i. If I pick Complex: System, or On, (1)^(4/5) give "Error: (X<0)^(∉Z)" I was unable to setup calculator to give real root for (1)^(4/5) = 1.0 

09102021, 06:09 PM
(This post was last modified: 09102021 06:24 PM by ijabbott.)
Post: #19




RE: Easy question
(09102021 05:23 PM)Albert Chan Wrote:(09092021 11:59 PM)ijabbott Wrote: The result of (1)^(4/5) will depend on whether or not you have the "Allow complex output from real input" option turned on or off in the settings. If turned off, you will get the real result 1. If turned on, you will get the complex result 0.809016994375+0.587785252292*i. Also, I think the CAS mode always approximates to the complex result. On my real HP Prime G1 2.1.14588 (2021_05_05), setting Complex: On in Home Symbolic Settings produces a real result = 1, and setting Complex: Off produces the aforementioned complex result. That seems to be opposite of what I expected. It may be a bug? The "Intelligent Math" option in Home Settings needs to be turned off for all of the above. Setting Complex: On and evaluating (1)^.8 produces the domain error that Albert mentions. — Ian Abbott 

09112021, 12:16 AM
Post: #20




RE: Easy question
Just upgrade the Prime OS from 2.0.0.13865 to 2.1.14588
Now with: Home>Settings> "Allow complex output from real input" OFF I get (X+1)^4/5 = 1 In CAS mode still getting the same complex result. 

« Next Oldest  Next Newest »

User(s) browsing this thread: