Strange Cube Root on the DM42 and a Work-around

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024
  • The DM42 was giving me complex answers to cube roots that should have been simple negative integers. I wrote a program to give me a more useful answer.

ความคิดเห็น • 126

  • @JaapVersteegh
    @JaapVersteegh 3 ปีที่แล้ว +23

    My HP28S and HP48GX both return the complex result, so not that "strange". It's just that x^0.3333 isn't the same as the cube root. The HP48 also has an XROOT function that does return -2, but the DM42, like the HP42S and HP28S, does not have this.. You solved that issue ;). Would have been nice if you'd called it XROOT and supported the X parameter: -8 3 XROOT -> -2

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +6

      Well said. I'd never run into this situation on my other calculators. Agree that making it generic (any odd or even root as dictated as you've shown above) and calling it XROOT would have been better. At the time I just needed the real cube root for use in finding the roots of a cubic function. Thanks for taking the time to leave a comment, Jaap.

    • @jellybeans6533
      @jellybeans6533 ปีที่แล้ว +1

      Indeed, it's not exactly the same. But a real cube root function should return all values (the pricipal real value and it's imaginary conjugates), not just one. Of course, the HP 42s doesn't have a root function.
      Back in the day, when complex numbers mattered to me, I was taught to order roots in order of the magnitude of the real part if it's "obvious". It was the polite thing to do at the time, a time when people would save up to buy a calculator (still using slide rules). But this calculator doesn't follow that convention. Rather it follows the convention of presenting the the roots in order of the polar angle. Which is also quite valid.
      What particularly irks me is that my HP48GX, just like in the video, gives the expected result---the real value, but the emulator on my phone (Droid 48) gives a complex result. So, someone has made a conscious decision to deviate from canon. I don't have a HP 42s or the DM 42, but after seeing this, I am not inclined to ever get one. But I get the feeling that there are some pedants out there, probably the authors of Free42, and these pedants have made unconventional choices.

    • @johan0234523
      @johan0234523 11 หลายเดือนก่อน +2

      @@jellybeans6533 I can tell you that the HP-42S and HP-15C also give the complex result only.

    • @MattMcIrvin
      @MattMcIrvin 10 หลายเดือนก่อน

      @@jellybeans6533 I just tried it with Droid48 and Emu48 (which I think is running the actual ROM): in both cases, -8 3 XROOT gives me -2, but -8 3 INV ^ gives me the complex result. And I'd argue this makes sense.
      Emu42 gives the same answer as the DM42, calculating it the same way as in the video.

  • @boxerdoc5592
    @boxerdoc5592 2 ปีที่แล้ว +7

    I may be a bit late to the show.
    It might be worth throwing in my few cents here as this still seems to be an unsolved riddle...
    The complex result can be reproduced on the HP50G and on the HP48GX.
    The reason is the setting of the system flags.
    On the HP50G you can select the CAS settings ->Numeric ON
    which corresponds to Flag 03 (Function ->numeric)
    whilst also having complex mode on
    Then you will get the numeric result if you use :
    -8
    3
    x V(''''') y
    Please note that the HP50's CAS is much more advanced as it allows for an Exact Mode which uses integer quotients wherever possible and remains in symbolic mode..
    It has two different numeric types:
    - integers
    and reals
    which allows for he quotients , helping to avoid precision loss.
    Similar process for the HP48GX:
    Flag 03 is also present.
    The result is a bit different though:
    -8
    3
    x (V''''') y
    or XROOT(3,-8)
    yields a numeric result: -2
    whereas
    -8
    3
    1/x
    (Y^x)
    yields a complex : (1 , 1.173205080757)
    with Flag 03 set to clear: Function -> symb
    If you care to look at the Hewlett Packard HP42 User Manual (available on Swiss Micros website)
    page 282 (Appendix C: Flags)
    Flag 74 Real Result only - is cleared at memory clear,
    which is the default state of the delivered product.
    Thus you get the complex result.
    My best guess is that setting Flag 74 to '1' will yield the numeric result you expect.
    Give it a try.
    As the HP Team in Corvallis used a lot of their architectural knowledege for subsequent calculators
    it is no surprise that the HP calculators like the HP42S , HP48 and HP50 have many similarities.
    One item of interest are the many flags you can use to fine tune your calculator settings to match your application.
    HP assume(d) that the users of their calculators know what they are doing as the HP calcs are mathematical beasts.
    Nothing comes close - even today.

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว +1

      Good info to have here regarding the hp 48 and 50, Boxerdoc. It's never to late to chime in! I did not realize the hp 50 was more advanced -- I naïvely thought it was just a different look and updated chip, etc. rather than a more-advanced CAS system.
      Regarding the hp 42S (and DM42), the manual says that 74 is a system flag and is not able to be set by the user. About the flag, it says: "If flag 74 is set, the calculator returns an error for functions that would turn a real-number input into a complex-number result (such as calculating the square root of a negative real number)." Thus, it sounds to me that even if this was user-settable, it would not apply to this particular situation.

    • @antbest
      @antbest 2 ปีที่แล้ว +1

      @@scottcollins7513 RRES/CRES (in MODE menu) sets/clears flag 74. Setting RRES results in the error "Invalid Data"

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      @@antbest Thank you for clarifying that, Anthony. The 42S has its fair share of quirks!

  • @MattMcIrvin
    @MattMcIrvin 10 หลายเดือนก่อน +2

    The DM42 seems to be behaving just like actual HP calculators in this case--it's just that the 42S had no XROOT function, just the general exponential, so neither does the DM42.
    And when you take the reciprocal of 3, you now have a floating-point number that (because of rounding error) isn't exactly 1/3, so it's not even clear that the calculator *should* go to a special case of principal-root choice that is only more desirable for the exact integer root case. Trying to do that could have unpredictable results in itself.
    Better to do something consistent and easy to describe for the general case of a number raised to a fractional power, which in this case is probably to give you the root with the lowest polar angle or argument.
    If it did have an XROOT then it could be unambiguous about picking the special case for an integer root, just as you did, and as the HP48 does.

    • @scottcollins7513
      @scottcollins7513  10 หลายเดือนก่อน +1

      Great treatment of the topic at hand in terms of presentation and explanation. You are right - without a separate function there is no "safe" way to accomplish what I want (or think I want).

  • @outofahat9363
    @outofahat9363 3 ปีที่แล้ว +3

    if you dont want to do any coding just set the calculator to show complex numbers in polar notation instead of rectangular notation: shift>modes>pol. Now complex numbers will be shown as module < angle. the module is the solution just remember it should be negative if you are taking an odd root of a negative number.
    of course if you have to use the result directly and often, a program like yours might be the best option

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      This is a great idea. You now have me wondering if I couldn't make a much simpler program to accomplish the same goal of my original program -- I plan to try it out. THANKS.

    • @outofahat9363
      @outofahat9363 3 ปีที่แล้ว +1

      @@scottcollins7513 I dont know about using it in a program, i dont like the idea of a program changing the calculator settings. tbh i would just do a pretty basic two options program like this:
      LBL "CUBERT"
      X>=0? (checks if the radicans is negative or not)
      GTO 01
      GTO 02
      LBL 01 (case when its positive)
      3
      1/X
      Y^X
      RTN
      LBL 02 (case when its negative)
      3
      1/X
      Y^X
      ABS (finds the module/absolute value)
      +/-
      Or alternatively you could something more fancy and concise using flags:
      LBL "CUBERT"
      X

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      I found an issue w this approach. If the input number is complex to begin with, the program does not work or will only give the magnitude of the complex number. In other words the program only works with real number inputs. This means it may not work in some applications.

    • @outofahat9363
      @outofahat9363 3 ปีที่แล้ว +1

      @@scottcollins7513 how about this:
      LBL "CR"
      REAL? (checks if it's real, if it is sets flag 5; it's in catalog)
      SF 05
      3
      1/X
      Y^X
      FC?C 05 (if flag is clear it means it complex so you can just return otherwise we go to the real cases)
      RTN
      REAL? (I'm asking again in the case the input was a negative real number resulting in an unwanted complex output. But if it is real you can just return here)
      RTN
      ABS
      +/-
      tl;dr Complex in complex out. Real in, real out even when negative. Unless there is some other flaw ofc ;)
      EDIT: I put the RTN command after FC?C to correct the typo it should work now

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      @@outofahat9363 There’s one correction to the code above - line 8 should be “FS?C 05” - with this change it works as you intended. Handles real and complex and saves 2 lines of code. Downside is that it is tougher to understand which is why it took me a while to figure out why it was not working as intended (didn’t help that I was not too familiar with using flags). Thanks for the education/help!

  • @scramjet4610
    @scramjet4610 10 หลายเดือนก่อน

    This is a brilliant video, don't apologize for this being nerdy. I've not seen this addressed elsewhere, and have completely missed this myself. An awareness of this may be very valuable in certain situations.

    • @scottcollins7513
      @scottcollins7513  10 หลายเดือนก่อน

      Thank you for the kind words!

  • @cret859
    @cret859 3 ปีที่แล้ว +2

    We get the same 'first quadrant' cubic root on HP-28S and HP-15C (in complex mode since on HP-15C such as on the HP-41C no fractional exponent can be applied to any negative number).
    On the HP-15C, as you, I have used a small program to get the cubic root of 'real value' :
    f LBL C ENTER g ABS ÷ g LSTx 3 1/x y^x × g RTN
    This code may be used in HP15C real only mode (CF 8) or in 'complex' mode as well (SF 8).
    I have used the same 'trick' on HP-28S (which may be compatible with HP-48/50 as well):
    « DUP ABS 3 INV ^ SWAP SIGN * » 'CROOT' STO

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      Good information. HP 28S got me through college -- must not have been taking many cube roots back then b/c I never ran into this issue.

  • @MatteoCampinoti94
    @MatteoCampinoti94 2 ปีที่แล้ว +2

    Edit: this program will only output correct results for odd root exponents
    Thanks for the video! I use a 48G and never noticed what happened with fractional square roots. I strongly suspect that the algorithm takes the complex solution with the smallest theta angle, which will be Pi/n for roots of negative integers. In the case of -8^1/3 that is Pi/3 while the real solution doesn't appear until theta is equal to Pi, -32^1/5 returns 2 theta Pi/5, and so on.
    I made this short program that should work on the original 42S and the DM42, though I could only test it with Free42.
    00 { 32-Byte Prgm }
    01 LBL "XROOT"
    02 XY
    03 CPX?
    04 GTO 01
    05 X

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      I appreciate you leaving such a detailed/useful comment and improved program for finding odd roots. Glad you liked the video. I always took the nth root for granted, but now I see the subtle but important difference between having an nth root function versus taking a number to the 1/n power. Cool how little twists like this can expand one's understanding of math. Take care, Matteo.

    • @diversionmary
      @diversionmary ปีที่แล้ว

      Works on an actual HP 42S -8 3, -2

    • @diversionmary
      @diversionmary ปีที่แล้ว

      Actually getting multiple answers like the dm42. How weird.

    • @MatteoCampinoti94
      @MatteoCampinoti94 ปีที่แล้ว +1

      @@diversionmary My suspicion is that it looks for solutions anticlockwise starting from x>0 y=0, so it is impossible for it to display the integer solution directly.

  • @detronbrian
    @detronbrian 3 ปีที่แล้ว +8

    we come here for nerdy

  • @Matt-qq8dh
    @Matt-qq8dh 3 ปีที่แล้ว

    I know there had not been a reply in one month but I came across this. Thank you very much for this information, hard work on the program writing and bringing this to everyone's attention. 👍✔😃

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      Glad you found it helpful -- it was cool to hear from others like you -- more discussion than I expected. Thanks for leaving a comment!

  • @Matt-qq8dh
    @Matt-qq8dh 3 ปีที่แล้ว +3

    I thought that calculators had the y root of x on them but apparently not all do. It would have been the reverse function of the x to the y key. That is what I get for thinking wrongly. Any way I just converted the complex number ( I guess that it is in complex form) answer of the cube root of -8 to Polar form and got a -2 with an angle on the answer. I do not know if this works with all types of cube roots or not. My 1 cent worth. Thank you.

  • @TreeDancingCloud
    @TreeDancingCloud 2 ปีที่แล้ว +2

    I love my HP-42S. I keep one on my desk, and another in an unopened original box. Yes, really.
    The HP Prime, the TI-89, and the TI-Nspire can do this. Each behaves as you wish for. They can also do roots and powers of negative numbers where the roots are not integers roots. Example: You can take the π root of -8. The value of π is near 3, so the π root of -8 is -1.94, which is not far away from -2.

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      First, very cool that you have not only 1, but 2, hp 42S calculators. Well played!
      Second, I like the idea of taking the Pi root of -8 and appreciated you pointing out why the answer should be close to -2. It seems the Prime, TI-89, and Nspire are "smarter", but I still like the DM42 (or hp 42S for the lucky ones out there) better. Once you include the hp 48GX and hp 28S, it is much more difficult for me to pick a favorite.
      Thanks for leaving a thoughtful and interesting comment, Bill.

    • @TreeDancingCloud
      @TreeDancingCloud 2 ปีที่แล้ว +2

      Scott,
      Thanks. You are too kind, if there is any such thing.
      When I am lucky enough to find one, I always wish for a calculator to be capable of accepting imaginary numbers as inputs for all of its functions, including hyperbolic trig. Many do not.
      My 15C can do it, and technically it is smaller than a 42S, but a user must know how to magically set flag 8 before, and unset that flag after when doing sinh(1+2i), for example. The 42S is a treasure, because it can do the math, it is ultra-portable, and (usually) we can figure out what to do with it by reading the key labels, and display.
      The 42S has moments of mystery, though. When entering program steps that operate directly on the Y, Z or T registers, a user must magically know to press the little . button when entering a program step. Calculators should not have "secret handshakes" in the user interface.
      By the way, the oldest machine I have that can do the imaginary hyperbolic thing is my physically perfect mint condition Log Log Duplex Vector slide rule, made in 1947 by K&E. The famous HP-41CX calculator could never do this, so when those were new items, and I had a fresh one, I actually had to put it down, and use my slide rule to solve problems on too many occasions.
      Four digits are plenty, when they are the right four digits.
      Bill

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      @@TreeDancingCloud You clearly are doing higher-level mathematics than I am. But, it is cool to hear what the different machines are capable of. AND, quite cool that you knew how to use a slide rule at all, let alone, in such a powerful way. Finally, I like the quote "four digits are plenty, when they are the right four digits". Spoken like an engineer or scientist!
      Well, one more thing, I 100% agree with the sentiment that there should not be cryptic handshakes. The fact that you GTO .. to start a new program is not intuitive -- it's simple-enough once you know about it, but there is nothing intuitive about it. But, that's a minor gripe with such a fantastic little calculator.
      Take care, Bill.

    • @EdouardTavinor
      @EdouardTavinor ปีที่แล้ว

      Unless I'm mistaken, the pi-th root of -8 is not a real number :/ its modulus is about 1.94, but none of the three possible values for its argument is 180°

    • @TreeDancingCloud
      @TreeDancingCloud ปีที่แล้ว +1

      @@EdouardTavinor Correct, and good point. Often, calculators that can return complex results have configuration setting options. Depending on the settings, machines can attempt to return the real and the imaginary parts separately, or in some cases simply return the modulus.
      My favorite machines for this kind of work are the TI-89/92+. They return both the real and the imaginary parts, but symbolically. So, if we enter the pi root of (-8) instead of two decimal numbers we get back 8^(1/pi)*cos(1 radian) for the real part, and 8^(1/pi)*sin(1 radian) for the imaginary part.

  • @JonDisnard
    @JonDisnard 2 ปีที่แล้ว

    This was a fun video, thanks. I'm new to the dm42, and have been curious how to write small programs like this. I have a particular desire for a proper `logb` log base, so for RPN maybe `logYX`. On all my RPN calculators I've got to remember to divide the natural log of X by natural log of Y.
    So for example, log 12 in base 3.
    So like... `X³ = 12 `
    Simply run `logₓy` or in this case `log₃(12)`
    On my RPN calculators be like... `ln 12 / ln 3`
    Or
    12 [ln]
    3 [ln]
    / [Enter]
    Use love to turn that into a beginner level function. So your video was educational for me, thanks.

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      Glad you found it helpful, Jon. Good idea for a simple little program -- once in a while I have had to use the "ln 12 / ln 3" identity myself. DM42 is a very cool, though pricey, device. Have fun with it!

    • @EdouardTavinor
      @EdouardTavinor ปีที่แล้ว

      My first attempt:
      Start a new program by entering GTO and then pressing "." twice.
      Enter the following:
      LBL "LNB"
      ln
      XY
      ln
      XY
      ÷
      Press exit to leave the programming mode.
      Enter
      4
      2
      Press XEQ and select "LNB"
      I hope it works!

  • @marklgarcia
    @marklgarcia 9 หลายเดือนก่อน

    Interesting video. I tried -8 raised to the 1/3 power on my HP-41CV and I get DATA ERROR on the LCD display.

    • @scottcollins7513
      @scottcollins7513  9 หลายเดือนก่อน +1

      Strange that was not covered. hp may have figured that users would take the cube root of the positive number and then reverse the sign of the answer. Not sure.

  • @jimfondren393
    @jimfondren393 3 ปีที่แล้ว

    Also need to check for non-integer negative input as that, to the 1/3 power, will be complex

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      I just tried --3.375 (-27/8) and the cuberoot program correctly gives -1.5 (-3/2) and not a complex answer. Let me know if I am missing something. Regardless, thanks for taking the time to leave a comment.

  • @davannaleah
    @davannaleah ปีที่แล้ว

    If it is always taking the cube root of a negative number (not complex), just use the ABS function on the cube root complex result, then change sign to make the result negative

    • @scottcollins7513
      @scottcollins7513  ปีที่แล้ว

      Good tip, David. Thanks for leaving a comment.

  • @detronbrian
    @detronbrian 3 ปีที่แล้ว +3

    thanks for sharing this. (also, glad you got yourself a DM42)

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      Thanks, Detron. I've enjoyed the DM42. It's not perfect, but it is very good. Love the size, build quality, screen quality, general-simplicity, and programmability.

  • @alikaperdue
    @alikaperdue ปีที่แล้ว

    On the HP48sx, I type in "(-8,0)", "3", "x√y" and get an error "XROOT Error".
    But I type in "(-8,0)", "3", "1/x", "y^x" and it shows (1,1.732...)
    The HP48 dev team should fix their "x√y" button code.
    * I prefer the 48xs display with a short real part when it has a bunch of trailing zeros but the imaginary does not.

  • @KipIngram
    @KipIngram ปีที่แล้ว

    If you have your DM-42 set to display complex numbers in magnitude/angle form, then that result will just be 2 angle 60. We know 180 is 3*60, so it's easy to just know that -2 is also a root.

    • @scottcollins7513
      @scottcollins7513  ปีที่แล้ว

      Good tip about using magnitude/angle format -- had not thought of that approach. And, we would know that if the magnitude is an integer and we are finding the cube root of a negative, we would know that it has to be a negative value. Thanks for pointing this out, Kip.

    • @KipIngram
      @KipIngram ปีที่แล้ว

      @@scottcollins7513 There's a function that lets you force y and x to be interpreted as mag/angle - I think it's called PCOMPLX or something close to that. So even if you have your calculator in rectangular mode "in general" you can still force in a mag/angle complex if you assign that function somewhere handy.
      I don't want to "make excuses" for the device - I actually think this should be handled more gracefully. Maybe some settings would be required - I haven't thought it through well enough. But some way to say "prefer real branches" would be useful here. I'm also a little concerned that the necessity on the DM-42 of doing the cube root as the 1/3 power may be a shortcoming, since 1/3 can't be represented perfectly. Having a separate nth root function would alleviate that.

    • @scottcollins7513
      @scottcollins7513  ปีที่แล้ว

      Well said!@@KipIngram

  • @guerom00
    @guerom00 2 ปีที่แล้ว

    As for the square root, what is returned is the principal branch of the cube root function whose argument theta is 0≤theta

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      I think that you are correct in suspecting that it always provides the principal root. Calculator algorithms are far beyond me! I'm really amazed how quickly they can find approximate answers to complicated problems so quickly -- a whole lot of accumulated mathematical cleverness is housed inside these things!

  • @N269
    @N269 3 ปีที่แล้ว

    Lbl "RCuRt"
    CF 00
    X

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      It's a minor issue, but I don't think this would work if the original number is complex.

  • @johan0234523
    @johan0234523 11 หลายเดือนก่อน

    If you look at the source code of Free42, then you see that the power of a negative number to a non-integer exponent is always supposed to be a complex number. Since Thomas Okken faithfully implemented the HP-42S functionality, I have no doubt that the 42S behaved in the same way.
    Edit: when you put the HP-15C in complex mode (the classic, but the CE will do the same, I assume), the behavior is the same. Undoubtedly a choice of the HP engineers to always use the y^x = e^(x*ln(y)) function. Which fails when the calculator is in the real domain, and delivers the complex root when the calculator is in complex mode.

    • @scottcollins7513
      @scottcollins7513  11 หลายเดือนก่อน

      I have always assumed that the hp 42S had the same “issue”/design. I should have thought to mention in the video. You make a good point - thanks for leaving a comment.

  • @AntonioCavicchioni
    @AntonioCavicchioni 3 ปีที่แล้ว +2

    Maybe a system flag for complex calcs?

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      I'd love to know. You might be onto something here. But, when I did some research no one brought that up -- they just acted like it was the same with the HP 42S and the DM42 is just carrying on the legacy.

    • @petermikus2363
      @petermikus2363 3 ปีที่แล้ว +1

      @@scottcollins7513 yeah the free 42 app also has the same thing

  • @johnyu-eh4id
    @johnyu-eh4id 3 ปีที่แล้ว +1

    This might also work
    Nth root of X
    =
    (-1)^N * exp(1/N * ln(abs(X))

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      Interesting! I tried it out on Free42 and it worked for the cube root of -8, but it does not work for +8 (it gives -2 rather than +2), meaning it would need to be part of a program which treated negative values differently than positive values (i.e. had branching). Regardless, it is a clever work-around and I appreciate you sharing it, John Doe (if that is your real name :) ).

    • @grahamhepwor8860
      @grahamhepwor8860 3 ปีที่แล้ว

      @@scottcollins7513 Multiplying the entire thing by the -sign of x works. This version will do cube root of -8 and +8, but I haven't tested much else:
      LBL "xroot"
      FUNC 21 (not necessary, I just like my stack to stay consistent before and after the program, and not mess up the stack if this is called programmatically. Basically says it uses 2 args and makes 1 result)
      LSTO "N" (can also use STO 00 or a global store)
      DROP (can also use CLX and RDOWN)
      ENTER
      ABS
      LN
      RCL/ "N" (recall divide)
      EXP
      XY
      SIGN
      +/-
      * (times)
      -1
      RCL "N"
      Y^X
      *
      END

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      @@grahamhepwor8860 Thanks for leaving this code. I'll give it a try. Curious how it compares in size to my existing, functional-but-not-glamorous approach.

  • @reneejones6330
    @reneejones6330 ปีที่แล้ว

    There are three cube roots of -8 and it returns a perfectly valid one. It returns the root with the smallest argument.

  • @pisotones2348
    @pisotones2348 3 ปีที่แล้ว

    I found the same problem some time ago. I guessed that using "modes" RRES should solve the problem but it didn't, giving an "Invalid Data" answer instead.
    It would be nice to do a program simillar to yours for the nth root of any number, positive or negative.

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      I may make the program more generic and allow it to find nth root -- good suggestion, thank you.

    • @pisotones2348
      @pisotones2348 3 ปีที่แล้ว

      @@scottcollins7513 A *VERY* quick and dirty approximation:
      01▸LBL "nRoot"
      02 "Degree? (+ R/S)"
      03 PROMPT
      04 STO 00
      05 "Number? (+ R/S)"
      06 PROMPT
      07 1
      08 XY
      09 CPX?
      10 GTO 01
      11 ×
      12 SIGN
      13 LASTX
      14 ABS
      15▸LBL 01
      16 RCL 00
      17 1/X
      18 Y^X
      19 ×
      20 END
      It works but there is a problem that must be addressed: It completely mangles the current stack so it cannot be used as a function in a calculation or program. It also has a problem with even grade roots of a negative number... as I said it is *VERY* quick and dirty :)

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      @@pisotones2348 Thanks for posting this.

  • @seanhunter111
    @seanhunter111 ปีที่แล้ว

    Firstly, to take the nth root of x, can't you just do e^(ln x /3)? This will I think give slightly better precision than just raising the number to a fractional power. When you take the ln of a negative number you get a complex answer, which I think under the hood gives you a clue as to how the calculator is implementing your fractional exponent.
    Having said that, I noticed that if you take the -1 * the norm of that complex solution you were shown you get the expected answer. So if you expressed the number as a + bi then - sqrt(a^2 + b^2) gives you what you expect.

    • @seanhunter111
      @seanhunter111 ปีที่แล้ว

      Looking at the free42 emulator, you can take this norrm by just using the ABS function. That said, if you're aking the sign of the number anyway to get the negative sign at the end you're better off doing sign(x) * e^(ln (abs(x)/y))) which will do what you want and not introduce these complex roots.

    • @scottcollins7513
      @scottcollins7513  ปีที่แล้ว

      I think what you are meaning is e^((ln(x))/3). Taking the natural log of a negative number will result in an imaginary result (I tried on Wolfram Alpha), so we are back where we started.
      Your second point about finding the norm is a good approach. Someone else suggested this, too. Good thinking.
      Thanks for weighing in and for leaving a comment, Sean.

  • @Chrls5
    @Chrls5 3 ปีที่แล้ว

    well if you do on the hp48, (-8)^0.33333, you´ll also get the same answer as the Swiss, maybe type the exponent in exact mode so (-8)^(1/3).

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +2

      I tried typing it in on the HP 48GX as you suggested -- (-8)^(1/3) -- and used both NUM and EVAL. In both cases it gave a complex answer (i.e. not -2). However, the 48GX has a specific "xth root of y" function which can be used to get the expected/desired -2. Good thought to try this though; I had not considered this approach.

    • @Chrls5
      @Chrls5 3 ปีที่แล้ว

      @@scottcollins7513 True, it gives those results you mentioned, my bad, i actually tried it on an HP50g, i was a bit surprised to find that the HP48 doesn't include the Command 'XQ' which if executed on the number (0.33333) will convert it to (1/3), thanks for sharing!! so maybe, if you add more digits say (0.3333333333333333) , you will get (2,60°) ,, very interesting!

  • @tallswede80
    @tallswede80 2 ปีที่แล้ว +1

    does it do the same thing on the original 42?

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      My understanding is that it does. But, I don’t have an original hp to use to verify.

    • @TreeDancingCloud
      @TreeDancingCloud 2 ปีที่แล้ว +1

      It works the same on the original HP-42S.

  • @azcue
    @azcue 3 ปีที่แล้ว

    👍👍👍... Thank you...

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      Thank you for the thumbs up -- definitely encouraging.

  • @petermikus2363
    @petermikus2363 3 ปีที่แล้ว

    Kind of a shame it doesnt have nroot function i hvae been thinking of getting a dm42 and still am however i have also been cnsidering the hp48cx but maybe ill just get the dm42 as my main calc and then buy a cheap one for stuff such as this

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      It depends what sort of calculations you need -- if you mostly just need a powerful scientific calculator, I'd go with the DM42 (the display and the form factor are great). If it's missing a few things you need (e.g. nth root), you could create a program and save it in the custom menu for easy access.

    • @petermikus2363
      @petermikus2363 3 ปีที่แล้ว

      @@scottcollins7513 yeah i agree i have been wanting to get one but ill have to wait and yeah i also have to search for some programs to inspire from

  • @alasdairniven6578
    @alasdairniven6578 3 ปีที่แล้ว

    Surprised to see you have your prime set on algebraic notation. Do you prefer it?

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      I only occasionally use the Prime, and have minimal experience using it in RPN mode.
      I did see someone mention having the calculator in RPN in the "home" mode and using Algebraic for the "CAS" mode. I may need to give that a try.
      In my limited experience, RPN on the Prime did not feel fully integrated/developed (as compared with the HP 48GX or DM42), but perhaps they have improved that in the past couple years.

    • @alasdairniven6578
      @alasdairniven6578 3 ปีที่แล้ว

      @@scottcollins7513 thanks, I have been thinking of getting one for the rpn and now I'll look into it more closely.

  • @DANNY40379
    @DANNY40379 3 ปีที่แล้ว

    I considered getting the DM42 but then just got the Prime (realizing it was better at certain things and worse at others).

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +2

      I think it just comes down to how you plan to use the calculator. The Prime is in a different plane in terms of capability and power -- I think HP did a good job on it. But, the DM42 is a really cool device that works well for me.

    • @rasittutgun
      @rasittutgun 2 ปีที่แล้ว +1

      Same crossroad for me and my friend. We ended up buying DM42 for me and Prime for him. Both satisfied with the results.

  • @lancelink88
    @lancelink88 ปีที่แล้ว

    Cant swissmicros do a firmware update to fix this?

    • @scottcollins7513
      @scottcollins7513  ปีที่แล้ว +2

      I think the issue is that the 42 does not have an "nth root" function, period. I do not think the function of the calculator is wrong (it is a valid answer); it is simply an implementation of the same way the hp 42S would have handled the same problem. In my view, the fix would be for the calculator emmulator to add an "nth root" function so you did not have to use the 1/x and y^x functions in combination.

    • @billhennessy5118
      @billhennessy5118 7 หลายเดือนก่อน

      I would guess they could add a nroot function to the custom menu.

  • @petermikus2363
    @petermikus2363 3 ปีที่แล้ว

    Another interesting thing this issue also occurs only with negative numbers i have tried the same calculation with positive number is in it gives to right answers
    For
    8 2
    27 3
    And so on assumingly because it can get a more precise answer that way not aure tho

    • @petermikus2363
      @petermikus2363 3 ปีที่แล้ว

      So really this program is usefull only for negative square roots

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      Correct. It actually is giving the correct answer For positive and negative odd roots, it is just not the answer that we actually want when taking the root of a negative. But the answer is correct when you consider that in both cases it produces the complex answer that in polar coordinates lies in the first quadrant as someone else pointed out in the comments somewhere along the line.

  • @leeprimeroessler3277
    @leeprimeroessler3277 3 ปีที่แล้ว +2

    I get the same in the hp-50g. It gives me the same complex solution .

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว +1

      OH. I did not think to try -8^(1/3) on the HP 48GX. You are right. I guess I never thought to do that since it has an nth-root function. Thanks for the comment - it shed some additional light.

    • @leeprimeroessler3277
      @leeprimeroessler3277 3 ปีที่แล้ว +1

      @@scottcollins7513 When I set it on «approx mode», it gave me -2. I think it is a bit strange behaviour.

    • @scottcollins7513
      @scottcollins7513  3 ปีที่แล้ว

      @@leeprimeroessler3277 Good info and agree that it is strange that approx mode changes the outcome. Thanks for sharing.

    • @BobDarlington
      @BobDarlington 3 ปีที่แล้ว +1

      The Prime G2 gives me -2. Just a data point (even in CAS mode).

    • @kmorar
      @kmorar 3 ปีที่แล้ว

      @@BobDarlington On HP Prime -8^(1/3) gives -2, but (-8)^(1/3) results in 1+1,73205080757*i

  • @philsturges5578
    @philsturges5578 3 ปีที่แล้ว +6

    Rotate your answer by 120 degrees to get the answer with no complex part:
    LBL "CUBR"
    3
    1/X
    Y^X
    REAL?
    GTO 00
    ->POL
    0
    120
    COMPLEX
    +
    ->REC
    COMPLEX
    XY
    LBL 00
    .END.

    • @philsturges5578
      @philsturges5578 3 ปีที่แล้ว +2

      I like @Erik P's solution. This is a slightly different implementation:
      LBL "CUBR"
      CF 00
      REAL?
      X>0?
      SF 00
      FC? 00
      +/-
      3
      1/X
      Y^X
      FC? 00
      +/-
      .END.

    • @giubin
      @giubin 3 ปีที่แล้ว

      @@philsturges5578 clearing the flag 00 on exit. It's good.

  • @georgeberl7947
    @georgeberl7947 2 ปีที่แล้ว

    Although this is a calculator for engineers, I think that swiss micros, beeing a european company, holds up with the traditional idea that a negative number is not defined under any root unless it is a complex number. This is a result of pure mathematics rather than applied mathmatics. You'd have to type "negative cube root of 8" to get the answer "negative 2".

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      I like the way you phrased it as an issue of "pure mathematics rather than applied mathematics". It is no big deal, too, b/c any engineer would be able to either take the negative of the cube root of the positive number *or* just take the magnitude of the complex result and make it negative. Appreciate the thoughtful comment, George!

  • @baconsledge
    @baconsledge 2 ปีที่แล้ว

    in for a penny, in for a pound.

    • @scottcollins7513
      @scottcollins7513  2 ปีที่แล้ว

      You taught me a new phrase, Bob. Thanks!

  • @jellybeans6533
    @jellybeans6533 ปีที่แล้ว +1

    Imagine paying so much for a calculator and running into some pedantic bullsh!t like this. If you had set the "disable complex" mode enabled you would think that it would provide the real root, if it exists. But no. Thankfully, it's a programmable calculator.

    • @jellybeans6533
      @jellybeans6533 ปีที่แล้ว

      Absolutely. If you disable the complex result, it should return real values (assuming they exist). Instead, it gives an invalid result for all negative numbers, even if a real root exists. Boo!

  • @alikaperdue
    @alikaperdue ปีที่แล้ว

    I said some things before listening to what you said.
    I think your solution is real reasonable.
    I like some features on the free GNU calculator on debian. It has a "true" base 2, 8, 10, 16 option, where all floating point numbers can be manipulated and displayed using almost all the calculator functions. Not just "binary" which only deals with integers. I can do 1₂/11₂ and get 0.0101010101010101₂. But my HP 48 can not. Or can it?
    What I want is to plug my old HP calculator into the PC and then use the calculator buttons to control the PC calculator. I want good buttons and smart layout.

    • @scottcollins7513
      @scottcollins7513  ปีที่แล้ว

      I have never delved into performing operations (other than addition) with different base numbers -- your example is interesting and something I have not thought about before. Thanks for mentioning it.
      About the "calculator buttons to control the PC calculator" -- I have had the same thought when using desmos with students. I thought a good amount about how I might create a dedicated keyboard that would operate the desmos functions, which is the same goal that you are describing.

    • @alikaperdue
      @alikaperdue ปีที่แล้ว

      @@scottcollins7513
      I use often fooplot. Similar, but desmos looks better. Thanks.
      I wonder if it would be "easy" to wire together the inside of an old USB keyboard to insides of a shell of an old HP calculator. Just to make a mock test that could be used to try it.
      I'm dreaming of a calculator that is about the size of a 48GX with great buttons, but hollow. I shove my iphone into this hollow calculator and only the top of my display is visible. I know have the phone inside the calculator and the phone auto switches to calculator mode. I use it just like an HP. I can also send and receive numbers and equations direct from it to wifi connected computers. So I can highlight numbers from the internet and left click to send to my calculator to work with it. And then swipe the number back to the computer when after I manipulated it. And also the buttons might be clear and the mobile phone might display the numbers which glow and can change and be configured. This might also operate as an input device for other things then number calculating. Since the buttons could change symbols on the fly. That's my calculator dream when I hold my old HP 48SX. I still love holding it, but it's slow, dull and lonely.

  • @christophbodner6518
    @christophbodner6518 ปีที่แล้ว

    LBL "CUBIC" ; avoiding complex numbers
    ENTER
    SIGN
    STO 01
    xy
    ABS
    3
    1/x
    y^x
    RCLx 01
    RTN
    ; tested with Free42/Android

    • @scottcollins7513
      @scottcollins7513  ปีที่แล้ว +2

      Clean/simple approach, but is limited to real numbers (which, admittedly, is nearly always the case). Thanks for sharing, Christoph.

    • @MrNoahTall
      @MrNoahTall 10 หลายเดือนก่อน

      @@scottcollins7513 Indeed. I'd just label the same program "RCUBIC" and be at peace with it.