Post Reply 
Hp50g emu : graph abs(x)^3 gives negative y-values
12-11-2020, 09:07 PM
Post: #1
Hp50g emu : graph abs(x)^3 gives negative y-values
On my EMU48, I want to graph the function
y=abs(x)^3.

But for negative x-values it gives
negative y-values on the graph and also for F6-Table.

Strange, because executing on the stack
'abs(x)' ENTER
-5 ENTER
'x' STO
EVALUATE
gives the right answer 125 (and not -125).

On my real HP 48 Gx calculator, the graph is correct for negative x,
when writing y=abs(x)^3.

What should I check to get positive / symmetric graph for y,
like a U-shape, and not a wrong S-shape?

Thanks for your help.

Gil
Find all posts by this user
Quote this message in a reply
12-11-2020, 10:17 PM
Post: #2
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
Simplification of ABS(X) to X? Looks like a \<< -119. CF \>> situation to me...
Find all posts by this user
Quote this message in a reply
12-11-2020, 10:20 PM
Post: #3
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
The same strange behavior in graphing or F6-Table occurs when writing the function
as y=x^3 × sign(x).
Find all posts by this user
Quote this message in a reply
12-11-2020, 10:23 PM
Post: #4
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
You found the solution.

I could not believe that a HP could present a such a "bug".

Many thanks.

Regards,
Gil
Find all posts by this user
Quote this message in a reply
12-12-2020, 02:33 PM
Post: #5
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
Can it be classified as a bug when it's there for all to see in the documentation?

Quote:-119 Rigorous mode
Clear: Rigorous mode on: |X| is not simplified to X
Set: Rigorous mode off: |X| is simplified to X

Page C-8 of the AUR.

Why one would want to simplify \(abs(x)\) to \(x\) in the first place is another matter. It does simplify things if you know that \(x\) is always going to have the same sign in the domain you're looking at, but if that is the case then why consider \(abs(x)\) in the first place...

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
12-12-2020, 02:48 PM
Post: #6
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
You are right regarding my possible, wrong labelling or questioning, but the thing is that my first reflex was to partake my indue surprise.

Regards and thanks for your quick insight.

Regards,
Gil
Find all posts by this user
Quote this message in a reply
12-12-2020, 02:57 PM
Post: #7
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
(12-12-2020 02:48 PM)Gil Wrote:  You are right regarding my possible, wrong labelling or questioning

Don't worry, it's not your sanity that I was questioning. I was wondering why HP would want to add that specific feature!

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
12-12-2020, 11:09 PM
Post: #8
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
Anyway, for my instinctive, poor knowledge, it's not clear
why when - 119 flag is set to "rigorous off"

y=ABS(X) gives, in the stack, "correctly" +5 when X is equal to -5,
whereas it is drawn like X = -5, or

y=ABS(X)^3 gives, in the stack, "correctly" +125 when X is equal to -5,
whereas it is drawn for a y-value = X^3 = -125.

I do not see the point of having that flag
with two different behaviours according to the context :

- stack, programs —> absolute value taken into account ;
- graphics —> absolute not taken into account.

I wish I could use the existing flag in a concrete, useful case.

Gil
Find all posts by this user
Quote this message in a reply
12-14-2020, 08:51 AM
Post: #9
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
it's the same if you just draw or calculate abs(x) ...

Hardware: Hp48S - Hp50g (5x black + 1 blue) - HP39gII - Hp27s - Casio fx-CG50
Find all posts by this user
Quote this message in a reply
12-14-2020, 09:17 AM
Post: #10
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
No, at least not in my EMU48 Android application :
two different behaviours, as mentioned, when
Rigorous mode is OFF ( -119 flag is set to 1).

Again, in other words :
-119 SF ENTER
-5 'X' STO

then
a) Graph will show point
(-5,-5) [a negative part of y=f(x)],
and not (-5,+5), but

b) ABS(X) ENTER EVALUATE
will give a positive number (+5).

Well, when -119 is set, I
would expect the same result in both cases a) and b).

Or did I miss something?
Find all posts by this user
Quote this message in a reply
12-14-2020, 10:20 AM
Post: #11
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
perhaps I was too concise in my contribution. I meant that the behavior is the same with ABS (x), you don't need the "^ 3".
The problem is: why is the graph drawn wrong with the "rigorous" off mode?
(besides the -119 flag the "rigorous" mode can also be changed from the CAS menu)

Hardware: Hp48S - Hp50g (5x black + 1 blue) - HP39gII - Hp27s - Casio fx-CG50
Find all posts by this user
Quote this message in a reply
12-14-2020, 10:38 AM
Post: #12
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
As a previous contributors on this forum made me understand,
the graph behavior is consistent with the state flag.

The question is why two DIFFERENT behaviours
when -119 flag is set, I. e. "not rigorous" mode is on for

a) stack/programme calculation
b) drawing graphs.

a) For stack/programme calculation :
absolute value taken into account, indepently of - 119 flag status.

b) And for drawing :
absolute value not taken into account
when - 119 is set.

I don't argue the individual issue of the result,
but I wish somebody could explain to me
the difference of treatment between a) and b).

Regards,
Gil
Find all posts by this user
Quote this message in a reply
12-14-2020, 02:07 PM
Post: #13
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
(12-14-2020 10:38 AM)Gil Wrote:  The question is why two DIFFERENT behaviours
when -119 flag is set, I. e. "not rigorous" mode is on for

a) stack/programme calculation
b) drawing graphs.

Flag -119 controls symbolic operations with the CAS. I find it interesting when doing symbolic simplifications on the stack or in a program and using parameters with a physical meaning.

For example, the voltage across the terminals of an R-L series circuit can be written as: w·L·Ip·sin(w·t)+R·Ip·cos(w·t)
Let’s consider that all the symbols in this expression are always positive (or zero) in practical applications. In fact, Ip is the amplitude of the current across the circuit. We want to rewrite that expression into something more compact like cos(w·t + phase).
Let’s have the HP 50g in Real & Exact mode on (-103 CF -105 CF):
  • Apply TCOLLECT with rigorous mode on (-119 CF). The result is: √(w²·L²+R²)·|Ip|·cos(w·t+...)
  • Apply TCOLLECT with rigorous mode off (-119 SF). The result is: √(w²·L²+R²)·Ip·cos(w·t+...)
This second result (non-rigorous) discards the module of Ip. Hence, if by chance we require to divide this expression by Ip, further simplifications can be done. However, with the first result, it won’t be possible for the machine to further simplify |Ip|/Ip to 1.

Ramón
Valladolid, Spain
TI-50, Casio fx-180P, HP48GX, HP50g, HP Prime G2
Visit this user's website Find all posts by this user
Quote this message in a reply
12-14-2020, 03:46 PM
Post: #14
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
Nice explanation and example.

Remains the unexplained different behaviour
— with non-rigorous option —
when a) drawing graphs or when
b) using the abs function directly
on the stack/within programs.

Regards,
Gil
Find all posts by this user
Quote this message in a reply
12-14-2020, 09:57 PM
Post: #15
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
I guess the graphing code tries to simplify the equation you throw at it. I haven't actually checked the code, but it wouldn't surprise me ... after all, the equation needs to be evaluated numerically over and over, for different values of X, so simplifying it might give it a nice performance boost if the equation is needlessly complex. Then the flag -119 thing would be nothing more than a side effect of re-using the existing simplification routines in CAS.
Find all posts by this user
Quote this message in a reply
12-14-2020, 10:08 PM
Post: #16
RE: Hp50g emu : graph abs(x)^3 gives negative y-values
A "pitfall" that makes sense.

Thank you.
Find all posts by this user
Quote this message in a reply
Post Reply 




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