cancel
Showing results for 
Search instead for 
Did you mean: 
Layzer
Level 2
14 9 1 0
Message 1 of 7
1,264
Flag Post

Solved!

Infinite symbol

HP Recommended
HP Prime
Other

Hi and I hope someone can help!

 

I'm writing a program that stores, manages and uses (solves) formulas and I'm stuck at some point where the program must do specific actions when a result is infinite, say the user wants to use the formula P=V*I and for the value V he tells the program to use the formula I=V/R since only the R is known. If, for example, he enters value for V=1_(V) and R=0_(Ohm) for the second formula, then the result will be +§_(A) [im using the § symbol here to symbolize infinite coz my android phone doesn't have the "horizontal 8" infinite symbol, sorry for that].

 

So my problem is that if the intermediate result of the formula I=V/R is infinite the result doesn't have the infinite symbol but instead it sais +Inf_(A), an expression that cannot be used for further calculations. So after the program stores that +Inf_(A) in the list where it stores all its results and tries to use it again afterwards to solve the P=V*I formula, it generates an error.

 

For that reason, I'm trying to tell it to transform the +Inf_(A) result into a string, then use the REPLACE command to replace the Inf back into an infinite symbol (which works fine) but the problem arises when the final result must be un-stringed again and stored into the list. Then, no matter what I've tried, in the best case it will replace my infinite symbol again in an Inf and store it, or produce different errors, according to how I try to syntax the command.

 

Given that CNT5 contains the final result "+§_(A)" which I want into a string and CNT1 just some FOR-DO counter, when writing only:

 

ANSLIST(CNT1,3):=CAS(expr(CNT5));
...it stores the string "syntax error" into the list.

 

If I write:
ANSLIST(CNT1,3):=CAS("CNT5");
...it stores EXPR(+Inf_A) in the list.

 

if I write:
ANSLIST(CNT1,3):=EXPR(CNT5);
...it produces a syntax error pop-up when the specific command is executed.

 

I found the interesting command QUOTE online, which is supposed to leave the expression unchanged when storing it into a variable, and tried to implement it somehow in the syntax to solve my problem but I didn't had any luck.

Can somebody help me out who knows better about this issue?

I wonder why they even have the calculator change the infinite symbol with that Inf thing in the results and not use the infinite symbol itself which would be not only just fine, but also mathematically correct. And, it would allow my program to run without problems it the situation I described above.


Thanx,

Andreas

0 Kudos
6 REPLIES 6
Jan_D
Level 6
305 297 32 76
Message 2 of 7
Flag Post
HP Recommended

Hello Andreas,

 

Have you tried this string: “ ’∞’ ”?

You can also use “ ’-∞’ ” but strangely enough not “ ’+∞’ ”

 

So you have to use both double quotes, which are used for creating strings, and single quotes, which are used for creating algebraic expressions.

 

The single quote you can get with shift - N.

You will get 2 of them and have to delete one.

 

0 Kudos
Maké
Level 9
3,551 3,490 180 541
Message 3 of 7
Flag Post
HP Recommended

Hi!, @Layzer:

 

If you needed use the Ohm Law, in HP PRIME, you can use, the Equation's Libraries and other's, of Eddie Shore, from ... http://edspi31415.blogspot.com.ar/2015/04/hp-prime-equation-library.html

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
0 Kudos
Layzer
Author
Level 2
14 9 1 0
Message 4 of 7
Flag Post
HP Recommended
Hi Jan_D and thank you for your reply!

Yes I tried the string you mentioned too. However, What I found out soon later after I posted my question is that it is actually not a problem at all to store the symbol ∞ into a list either as a string or not, but where the problem begins is when trying to store it with a unit (like ∞_(Ohm)) like I was trying to do. Then, no matter what I tried, I did not manage to have an expression like, say, ∞_(Ohm) NOT AS STRING stored into a list but during the execution of the command the expression changes to +Inf_(Ohm). Finally I had to change my program algorithm for the case of a ∞ result and have the program store the ∞ and the units separately in this situation.


Anyway thanx again for your suggestion,

Andreas
0 Kudos
Jan_D
Level 6
305 297 32 76
Message 5 of 7
Flag Post
HP Recommended

With firmware version 8151 this is what I see happening in Home view:

 

I store ‘∞’_Ohm into a list, and have no problems.

 

Next I create a string containing this expression, subsequently unstring it with EXPR, and store it into the list.

Again I have no problems.

 

But I can not store it into a matrix.

I can not even store 1_Ohm into a matrix!

2016-12-14 19.37.49.jpg

 

 

In CAS view it is different

 

I can not even store 1_Ohm into list L1 without problems.

But when I create a list in CAS as follows: l1:={}, I have no problems.

I can also store ‘∞’_Ohm into it.

 

Also expr(“ ‘∞’_Ohm”)

But not EXPR(“ ‘∞’_Ohm”).

 

In CAS view I can also store everything into a matrix, which has been created in CAS.

 

Note that in CAS view EXPR is shown in uppercase, but this is a wrong displayal, I entered lowercase, and when I turn off Textbook Display in second page of Home settings I see it displayed in lowercase. 

2016-12-14 20.20.24.jpg        

0 Kudos
Layzer
Author
Level 2
14 9 1 0
Message 6 of 7
Flag Post
HP Recommended
Hello Jan_D and sorry for the late answer,

after studying your answer and the pictures you've posted carefully I noticed that the trick was to put the quotes only on the value and to not also include the units of the expression. You suggested, for example, to write it as '∞'_Ohm while I was trying '∞_Ohm' which did not work.

Thank you for your precious time and the useful help, which indeed made me solve my problem!


Andreas
0 Kudos
Jan_D
Level 6
305 297 32 76
Message 7 of 7
Flag Post
HP Recommended

It is not a waste of time for me to think about your problems.

It is an exercise for me, and I learn from it too!

0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation