HP Forums

Full Version: How to graph Taylor series on the Prime
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I graph Taylor series on the Prime?
What type of graph do you expect ?

This type :

??
These commands will recreate that plot:

STARTAPP("Function");
F1:=CAS("taylor(sin('X'),('X') = 0,1,polynom)");
F2:=CAS("taylor(sin('X'),('X') = 0,3,polynom)");
F3:=CAS("taylor(sin('X'),('X') = 0,5,polynom)");
F4:=CAS("taylor(sin('X'),('X') = 0,7,polynom)");
F5:=CAS("taylor(sin('X'),('X') = 0,9,polynom)");
F6:=CAS("taylor(sin('X'),('X') = 0,11,polynom)");
F7:=CAS("taylor(sin('X'),('X') = 0,13,polynom)");
F8:=CAS("sin('X')");
Xmax:=10;
Ymax:=10;
Xmin:=−10;
Ymin:=-10;
CHECK({1,2,3,4,5,6,7,8});
UNCHECK({9,0});
STARTVIEW(1);

I tried that. The cursor follows the plot correctly but all that is show on the screen is a line with a slope of 0 and at y=wherever the cursor's position was last time the plot was drawn. Is this supposed to happen?
You should get something like this:

[attachment=9637]

(07-11-2021 01:06 PM)roadrunner Wrote: [ -> ]These commands will recreate that plot:

Thank you for your input ! I was in trouble finding any explaination in the Reference User Manual and was planning using the ptayl function like in this code:

EXPORT PLTYR(Fct,x0,a,b,s)
// Plot F(X) in slot F0 and taylor polynomials
// from order a to b by step of s
//
// Don't forget to enter function
// as single or double quoted expression
// 'SIN(X)' or SIN('X') or "SIN(X)"
BEGIN
// --- Start FUNCTION application ---
STARTAPP("Function");
LOCAL sFct:=REPLACE(STRING(Fct),"X","'X'");
LOCAL k,f;

F0:=EXPR(sFct); CHECK(0); UNCHECK({1,2,3,4,5,6,7,8,9});
FOR k FROM a TO b STEP s DO
f:=1+(k-a)/s;
IF 1≤f AND f≤9 THEN
EVAL(EXPR("F"+f+":=ptayl("+sFct+","+x0+","+k+")"));
CHECK(f)
END;
END;
// --- center plot & square zoom ---
LOCAL h:=Xmax-Ymin, y0:=F0(x0);
// center plot on (x0,y0) coordinates
Xmin:=x0-2*h/3; Xmax:=x0+2*h/3;
Ymin:=y0-h/2; Ymax:=y0+h/2;

STARTVIEW(1);
END;

// --- Alternative Forms Table ---
// 1 argument : PLTYR('F(X)')
EXPORT PLTYR(Fct)
BEGIN PLTYR(Fct, 0,1,9,1) END;
// 2 arguments: PLTYR('F(X)','x0')
EXPORT PLTYR(Fct,x0)
BEGIN PLTYR(Fct,x0,1,9,1) END;
// 3 arguments: PLTYR('F(X)','x0',u) plot only F(X) and one taylor term of order u
EXPORT PLTYR(Fct,x0,m)
BEGIN PLTYR(Fct,x0,m,m,1) END;
// 4 arguments: PLTYR('F(X)','x0',a,b) plot F(X) and a set taylor curve from order a to b inclusive
EXPORT PLTYR(Fct,x0,a,b)
BEGIN PLTYR(Fct,x0,a,b,1) END;

I am just curious about where did you find the documentation about the 'polynom' option of the TAYLOR function ?
Also, is there a way to program the color of the curves for any slot F1 to F0 ?
(07-13-2021 02:44 PM)C.Ret Wrote: [ -> ]I am just curious about where did you find the documentation about the 'polynom' option of the TAYLOR function ?

It is not well documented, only an example in "taylor" help.

CAS> taylor(sin(x),x=0, 5, polynom)

Help for "series" or "convert" does not even mention it.

CAS> convert(taylor(sin(x),x = 0, 5), polynom)

You are better off with XCAS documentation.
polynom help Wrote:Option of the convert or convertir command and of the taylor and series commands.
(07-13-2021 02:44 PM)C.Ret Wrote: [ -> ]Also, is there a way to program the color of the curves for any slot F1 to F0 ?

Yes, see "Tip: Change a color of a graph" on this page.
(07-13-2021 03:27 PM)Albert Chan Wrote: [ -> ][CAS> taylor(sin(x),x=0, 5, polynom)

Thank you Chan, now I better see what's up there ! It its like this particular option is a flag to remove the tail order size indicator \( o(x^6) \).

[attachment=9639]

(07-13-2021 03:55 PM)Didier Lachieze Wrote: [ -> ]Yes, see "Tip: Change a color of a graph" on this page.

Thank you Didier for the link, "l'astuce" given on Eddie's Blog is full efficient to colorize the plots and to make the increase of orders clearer :

[attachment=9640][attachment=9641]

Have a good La Bastille's Day !
This may be a bug with taylor

CAS> series(sin(x),x,0,5,polynom)

x-1/6*x^3+1/120*x^5

CAS> taylor(sin(x),x,0,5,polynom)

sin(5)+cos(5)*(x-5)-sin(5)/2*(x-5)^2-cos(5)/6*(x-5)^3+sin(5)/24*(x-5)^4+cos(5)/120*(x-5)^5
series and taylor are not synonyms, because taylor has some compatibility with the TI92 taylor command.
Hi parrise,

Off topic, but a question...I got your CAS on my CASIO fx-CG 50. When integrating roots of X such as x^(1/3), do I have to use surd, or is there a direct way to conjure up an NRoot option?
For definite integrals, it may be useful to use surd. For indefinite integrals, no.
Please note that KhiCAS for the CG50 is not as complete as other ports on calculators because there is no flash available (2M limit for addins). I can also not fix bugs easily for 2 reasons: no support for debugging (with tools like gdb) and there is no room left for bug workarounds.
Thanks. One more question...is Khicasen more complete on other handhelds? Is the PRIME version the most complete version? I’m amazed at what it is capable of (I was still in the slide rule age during college...never dreamed that symbolic math would be available on a hand held!).
The most complete port of Giac/Xcas on a calculator is the GPL port of KhiCAS available on the TI Nspire CX and CX II, with multi-precision float, arithmetic interval, all giac commands, and also MicroPython and the QuickJS Javascript engine. The CX version has an exam mode compatible with KhiCAS.
Then you will find the Numworks GPL port for unlocked Numworks N0110 calculators with OS version <=15.5 : it does not have quickJS support and most importantly the RAM capabilities are very limited (a little less than 128K of RAM). It is compatible with exam mode.
Then the HP Prime port of Xcas : this commercial port has some commands disabled and lacks some LGPL libraries (incompatible licenses). On the other hand, it is fully integrated with the system, exam mode (in countries allowing CAS) and has the best hardware ressources available on a calc.
And then you have the Casio ports for the Casio Prizm family (CG10, 20, 50) and for the B&W Fx-9750GIII, Fx-9860GIII. They are limited by the addin limit size (2M: I had to remove some commands and online help to fit) + RAM limitations (around 128K of RAM on the Prizm, less on the B&W Casio).
Another question...concerning the TI CX 2, can one use templates for math entry, or is the entry method similar to on the CASIO’s ?
Both methods are available (there are two user interface available, one with template for maths only, the second one w/o template like the Casio).
Quote:F1:=CAS("taylor(sin('X'),('X') = 0,1,polynom)");

First thanks for this forum. Without the information given here I would be lost and the prime would be (almost) useless for me because I have no instructor nor too much time to get used to the device. :-)

Using the above command works in that I enter the command in home view and the resulting series is inserted into the function app. However I wonder why can't I use the exact same command directly as input from within the app?

The single quotes are necessary to have prime identify 'X' as a symbolic variable and no numeric. Am i right? Why would 'x' instead of 'X' not work?
these little quirks are giving me a hard time.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :