Post Reply 
How to plot a summation?
09-25-2015, 12:46 PM
Post: #1
How to plot a summation?
Hi everyone! I'm trying to plot a summation on my HP Prime, but I can't do it. Even something as simple as Σ(N,N,0,X) produces no output (it should produce the summation of 0 to X). How should it be done? Thanks!
Find all posts by this user
Quote this message in a reply
09-25-2015, 05:25 PM
Post: #2
RE: How to plot a summation?
That's because the sum function is a cas function and plotting is an operation using home. One way to do it is to make a cas function like:

#cas
sumcas(x):=
BEGIN
return sum(n,n,0,x);
END;
#end

That should work in home and cas; then plot F1(X):=sumcas(X).

-road
Find all posts by this user
Quote this message in a reply
09-25-2015, 07:14 PM
Post: #3
RE: How to plot a summation?
Sorry, I'm really new to HP Prime (and graphic calculators in general). How do I make a CAS function like you said? I have tried creating a program like this:

EXPORT sumplot(X)
BEGIN
return CAS.sum(N,N,0,X);
END;

When running it directly, it works fine, however when I try plotting it the calculator crashes and reboots. What I'm I doing wrong?
Find all posts by this user
Quote this message in a reply
09-25-2015, 07:29 PM
Post: #4
RE: How to plot a summation?
Change your program to this:

EXPORT sumplot(X)
BEGIN
return CAS.sum("N","N",0,X);
END;

and I believe it should work.

-road
Find all posts by this user
Quote this message in a reply
09-25-2015, 07:48 PM
Post: #5
RE: How to plot a summation?
No, didn't fix it. I tried modifying the code a bit, as to make it return the summation only when X>0 and X<10. Now it doesn't crash, but in the interval from 0 to 10, nothing is plotted, like the program didn't return anything. Here is the code:

EXPORT sumplot(X)
BEGIN
IF X < 1 THEN
return 0;
END;
IF X > 10 THEN
return 0;
END;
return CAS.sum("N","N",0,X);
END;

Maybe CAS is returning something the plotting does not understand?
Find all posts by this user
Quote this message in a reply
09-25-2015, 09:25 PM (This post was last modified: 09-25-2015 09:26 PM by Tim Wessman.)
Post: #6
RE: How to plot a summation?
(09-25-2015 12:46 PM)RodrigoPontes Wrote:  Hi everyone! I'm trying to plot a summation on my HP Prime, but I can't do it. Even something as simple as Σ(N,N,0,X) produces no output (it should produce the summation of 0 to X). How should it be done? Thanks!

You actually DID make a plot. If you look in your plot screen, you will see that as you trace to an integer value it has correctly calculated your value. However, since all the values in between are not defined you get. Try typing 10 to jump to x=10 and you'll see your value traced at the bottom.

The points aren't connected though as you've seen. Probably need to improve stuff with respect to sums...

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
09-25-2015, 10:06 PM
Post: #7
RE: How to plot a summation?
Wow, you're right, I feel really dumb now. One thing, why does the calculator crash when I try returning the value like I did on the sumplot program? Is there no way to get a nice continue curve? When I use summation under CAS I have no problems with decimals.
Find all posts by this user
Quote this message in a reply
09-26-2015, 03:27 AM
Post: #8
RE: How to plot a summation?
First rule when dealing with CAS functions: avoid using upper case single letter variables such as N or X for undefined variables, use lower case variables such as n or x instead to avoid unwanted side effects. On the Prime upper-case single letter variables are predefined as reals with a default value of 0.

You don't need a program, you can do in the function app F1(X):=CAS.sum(n,n,0,X)
and you will plot steps between each integer value of X *.

If you want a nice continuous curve you can do in CAS: f:=sum(n,n,0 x)
and in the function app: F1(X)=f(X)

Do you see the difference in what you're plotting ?

*an interesting mix of lower case undefined CAS variable (n) and upper case app variable (X).
Find all posts by this user
Quote this message in a reply
Post Reply 




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