Programming with CAS commands (e.g., arcLen)



#2

arcLen() works fine in CAS view, but in home view there are problems.

For example, arcLen(x^3,0,2) in CAS gives the correct answer approx. 8.63...

In home view, arcLen(X^3,0,2) returns 2 ???

Other CAS commands work correctly in home view, e.g., diff(X^2,X) returns 2*X.

This also presents a challenge for programming.

This simple program

EXPORT TPP()
BEGIN
LOCAL QQ,RR,SS;
INPUT({QQ,RR,SS});
arcLen(QQ,RR,SS);
END;

gives the wrong answer if entering X^3 into QQ.

But I can't enter lower case x^3 into QQ. Why? Syntax error. I tried quotes around the symbolic expression, but to no avail. Any ideas?


#3

The home parser requires all objects exist on parse time. Mixing CAS stuff with HOME stuff is not a great thing to do at this moment as there are just so many cases that will misbehave.

TW


#4

OK, so how do I, on the Prime, write a program where the user can enter a function, start and end values, and run something like arcLen? (This is just an example).

Sorry for the bad formatting in the post before; hopefully, this reads better.

EXPORT TPP() 
BEGIN
LOCAL QQ,RR,SS;
INPUT({QQ,RR,SS});
arcLen(QQ,RR,SS);
END;

Is it not possible to do this at all? Not even workarounds?

#5

Quote:
arcLen() works fine in CAS view, but in home view there are problems.

For example, arcLen(x^3,0,2) in CAS gives the correct answer approx. 8.63...

In home view, arcLen(X^3,0,2) returns 2 ???

Other CAS commands work correctly in home view, e.g., diff(X^2,X) returns 2*X.

This also presents a challenge for programming.

This simple program

EXPORT TPP()
BEGIN
LOCAL QQ,RR,SS;
INPUT({QQ,RR,SS});
arcLen(QQ,RR,SS);
END;
gives the wrong answer if entering X^3 into QQ.

But I can't enter lower case x^3 into QQ. Why? Syntax error. I tried quotes around the symbolic expression, but to no avail. Any ideas?


When you enter X^3, are you entering that as just X^3, 'X^3', or "X^3" as all three are handled differently. X^3 converts into a number first, so the arclength is just SS-RR. I am still trying to figure out when the second and third cases are treated the same and when they are not... :-(


#6

I tried everything I could think of.

Ideally you should be able to enter lower case "X", i.e., x^3, into the variable on the INPUT screen, but at runtime the parser doesn't let you.


#7

Quote:
I tried everything I could think of.

Ideally you should be able to enter lower case "X", i.e., x^3, into the variable on the INPUT screen, but at runtime the parser doesn't let you.


I have found that pretty much anytime I need to do anything with symbolic expressions, I end up have to use expr(" blah "); And even this can break the calculator. For example,

F0:=expr("'X-F1(X)/(" + diff(F1(X),X) + "')");

works fine within a program. However,

BEGIN EXAMPLE()
LOCAL QQ, RR, SS;
QQ:=""; // this will enable you to enter a string, now
INPUT({QQ,RR,SS});

CAS.arcLen(EXPR("'"+QQ+"'"),RR,SS); // warmstarts even without RR,SS at end

END;

causes a warmstart on my actual calculator. I can type: X^2-5 for QQ and it shows up properly during the input screen. But it seems to fail once inputs are entered. In sum, working with built-in variables _usually_ works. Most of the time, anything with CAS seems broken. Then again, I have yet to consult the manual regarding CAS operations (assuming I can find it in there).


Edited: 1 Oct 2013, 2:47 p.m.


#8

Thanks so much for looking at this problem as well!

All this (storing and evaluating symbolic expressions with the CAS) works fine on the 50G, so when I tried this out on my Prime, I first thought I was going crazy!

As for a Prime CAS reference, maybe this XCAS manual will be of help:

http://www-fourier.ujf-grenoble.fr/~parisse/giac/cascmd_en.pdf

Covers the HP Prime CAS commands (and then some). I don't know if there is a newer edition.

I guess for now we'll just have to be content using the CAS commands and functions in CAS view, and in interactive mode only.


#9

EXPORT AL()
BEGIN
LOCAL RR,SS;
INPUT({F1,RR,SS}); // changing F1 to CAS.F1 causes warmstart.
CAS.arcLen(CAS.F1,RR,SS);
END;

Allows you to enter in a function, and at least does not crash. Heading out a.t.m. so didn't test if it correctly returns the result we want.

Edited: 1 Oct 2013, 3:53 p.m.


#10

For arcLen(x^3,0,2), that returns 2*sqrt(2), so it is not correct (sigh).

Running CAS.arcLen(F1, RR, SS) gives an error message "expecting an expression, not a function."


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime: CAS taylor Alberto Candel 5 700 12-13-2013, 09:45 PM
Last Post: Alberto Candel
  HP Prime CAS curiosity bluesun08 11 1,103 12-10-2013, 01:03 PM
Last Post: Han
  [HP-Prime CAS] "Warning, ^ (Command) Is ambiguous on non square matrices"?? CompSystems 1 462 12-07-2013, 07:15 PM
Last Post: CompSystems
  HP Prime: complex numbers in CAS. Alberto Candel 1 396 12-06-2013, 02:36 PM
Last Post: parisse
  [HP Prime] plotfunc() bug in CAS Chris Pem10 2 460 12-04-2013, 02:46 PM
Last Post: Chris Pem10
  HP Prime: Home/CAS? Alasdair McAndrew 11 1,000 11-26-2013, 02:48 PM
Last Post: Alberto Candel
  HP Prime numerical precision in CAS and HOME Javier Goizueta 5 581 11-16-2013, 03:51 AM
Last Post: Paul Dale
  Need CAS help Michael de Estrada 6 608 11-13-2013, 01:29 AM
Last Post: cyrille de Brébisson
  HP Prime - CAS functions in Spreadsheet App CR Haeger 6 662 11-11-2013, 12:37 AM
Last Post: Michael de Estrada
  Another HP Prime CAS question Michael de Estrada 3 432 11-09-2013, 10:56 AM
Last Post: Michael de Estrada

Forum Jump: