HP Forums

Full Version: How to plot a summation?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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
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?
Change your program to this:

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

and I believe it should work.

-road
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?
(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...
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.
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).
Reference URL's