khicas documentation.

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 561
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

khicas documentation.

Message par compsystems » ven. oct. 26, 2018 1:42 am

https://www-fourier.ujf-grenoble.fr/~pa ... sioen.html

taylor(sin(x),x=0,5) [ok] It does not print in pretty print.


desolve([y'=2y,y[0]=1],x,y) I think it should be
desolve([y'=2y,y(0)=1],x,y)

with

desolve([y'=2y,y[0]=1],x,y) restart xcas

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: khicas documentation.

Message par parisse » ven. oct. 26, 2018 6:22 am

Fixed, thanks!

compsystems
Messages : 561
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: khicas documentation.

Message par compsystems » ven. oct. 26, 2018 1:57 pm

also do not print in 2D.
P,L,U:=lu(A)
linsolve(P,L,U,v)



(real in [0,1) ) => (real in [0,1])
et => and

compsystems
Messages : 561
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: khicas documentation.

Message par compsystems » ven. oct. 26, 2018 7:40 pm

The file adapted to run on the hp-prime

what is the equivalent command to histogram, interp cmds in the hpprime?

The following code does not operate in XCAS

Code : Tout sélectionner

function square(n)
  repete(4,avance n,tourne_gauche);
ffunction:;
  
efface;
for n from 1 to 10 do
  square(10*n);
od;

Xcas text
/* File: Xcas Text */
/* Abstract: This document explains how to run efficiently CAS on HP Prime calculators.
HP Prime CAS is an adapted version of the Giac/Xcas Computer Algebra System (CAS) for this calculator: */
/* Source: https://www-fourier.ujf-grenoble.fr/~pa ... sioen.html By Bernard Parisse */

/* 3. Common CAS commands */
/* [Tools] [CAS] [1: Algebra] */
/* 3.1 Expand and factor */
/* factor menu: [Tools] [CAS] [1] [4: Factor] */
/* ** factor: factorization. Shortcut cmd =>* (> key menu, then *), for example */
factor(x^4-1)
x^4-1=>*
/* run cfactor to factor over Complex */
cfactor(x^4-1)
/* partfrac menu: [Tools] [CAS] [1] [7:Partial Fraction] */
/* ** partfrac: expands a polynomial or performs partial fraction expansion over a fraction. Shortcut =>+ (> key menu, then + key), for example */
partfrac((x+1)^4)
(x+1)^4=>+
autosimplify(0):;partfrac(1/(x^4-1)) //(1/4)/(x-1) - (1/4)/(x+1) - (1/2)/(x²-1)
autosimplify(0):;1/(x^4-1)=>+
/* simplify menu: [Tools] [CAS] [1] [1: Simplify] */
/* ** simplify: tries to simplify an expression. Shortcut =>/ (> key menu, then /), for example */
simplify(sin(3x)/sin(x))
sin(3x)/sin(x)=>/ // Error syntax hp-prime when entry: textBook (pretty print or 2D)
/* ** ratnormal: rewrite as an irreducible fraction */
ratnormal((x^2-1)/(x^3-1))

/* 3.2 Calculus */
/* [Tools] [CAS] [2: Calculus] */
/* diff menu: [Tools] [CAS] [2] [1: Differentiate ] */
/* ** derivative. Shortcut ' (Shift [9] ') for derivative with respect to x, example */
angle_radian(1):;diff(sin(x),x)
sin(x)'
/* For n th-derivative, add n, for example 3rd derivative */
diff(sin(x^2),x,3)
diff(sin(x²),x,3)
diff(sin(x³),x,3)

/* integrate menu: [Tools] [CAS] [2] [2: Integrate] */
/* ** integrate: antiderivative (1 or 2 arguments) for example */
integrate(sin(x))
integrate(1/(t^4-1),t)
integrate(sin(x)^4,x,0,pi)
/* For an approximate computation, enter one boundary as an approx number, for example */
integrate(sin(x)^4,x,0.0,pi)

/* limit menu: [Tools] [CAS] [2] [3: Limit] */
/* ** limit of an expression. Example */
limit((cos(x)-1)/x^2,x=0)

/* ** tabvar : table of variations of an expression. for example */
tabvar(x^3-7x+5)
ClrIO:; plotfunc(x^3-7x+5,x,-4,4):;
DispG

/* taylor and series menu: [Tools] [CAS] [2] [8: Limits] [2: Taylor] */
/* ** taylor: Taylor expansion or asymptotic serie expansion, for example */
taylor(sin(x),x=0,5)
/* Add polynomial if you do not want to have the remainder term */
taylor(sin(x),x=0,5,polynom)

/* sum menu: [Tools] [CAS] [2] [5: Summation] */
/* ** sum: discrete summation, for example */
sum(k^2,k,1,n)
/* computes the sum and rewrites it factored. */
sum(k^2,k,1,n)=>*

/* 3.3 Solvers */
/* solve menu: [Tools] [CAS] [3: Solve] */
/* ** solve: solve solves an equation exactly. Takes the variable to solve for as second argument, unless it is x, for example */
solve(t^2-1=0,t)
solve(t^2-1=0,t,'=')
/* If exact solving fails, run fsolve for approx solving, either with an iterative method starting with a guess */
fsolve(cos(x)=x,x=0.0)
/* or by dichotomy */
fsolve(cos(x)=x,x=0..1)
/* For complex solutions, run csolve */
csolve(x^4-1=0,x,'=')

/* It is possible to restrict solutions using assumptions on the variable, for example */
assume(m>1) // then
solve(m^2-4=0,m)
purge(m):;
solve(m^2-4=0,m)
/* ** solve can also solve (simple) polynomial systems, enter a list of equations as 1st argument and a list of variables as 2nd argument, for example intersection of a circle and a line: */
solve([x^2+y^2+2y=3,x+y=1],[x,y])
solve([x^2+y^2+2y=3,x+y=1],[x,y],'=')
/* ** Run linsolve to solve linear systems. enter a list of equations as 1st argument and a list of variables as 2nd argument, example: */
linsolve([x+2y=3,x-y=7],[x,y])
/* ** Run desolve to solve exactly a differential equation. for example, to solve y'=2y */
desolve(y'=2y)
/* Another example with an initial condition: */
desolve([y'=2*y,y(0)=1],x,y) // bug desolve([y'=2*y,y[0]=1],x,y)
/* ** Run odesolve for approx solving or plotode for a graphic representation of the approx. solution. */
/* ** rsolve solves some recurrence relations u(n+1)=f(un,..), for example to solve the arithmetico-geometric recurrence */
rsolve(u(n+1)=2*u(n)+3,u(n),u(0)=1)

/* 3.4 Arithmetic */
/* When required, the distinction between integer arithmetic and polynomial arithmetic is done by a prefix i for integer commands. For example ifactor for integer factorization and factor for polynomial factorization */
/* (or cfactor for polynomial factorization over Complex). Some commands work for integers and polynomials, like gcd and lcm */
/* 3.4.1 IInteger */
/* quotient menu: [Tools] [CAS][5: Integer][7: Division][1: Quotient] */
/* ** iquo(a,b), irem(a,b) quotient and remainder of euclidean division of two integers. */
iquo(23,13),irem(23,13)
/* ** isprime(n) checks whether n is prime. This is a probabilisitic test for large values of n */
isprime(2^64+1)
/* ** ifactor(n) factorizes an integer (not too large, since algorithms used are trial division and Pollard-ρ, there is no space left in memory for quadratic sieve), for example */
ifactor(2^64+1)
2^64+1
approx(ifactor(2^64+1))
/* ** gcd(a,b), lcm(a,b) GCD and LCM of two integers or polynomials. */
gcd(25,15),lcm(25,15)
gcd(x^3-1,x^2-1),lcm(x^3-1,x^2-1)
/* ** iegcd(a,b) returns 3 integers u,v,d such that a·u+b·v=d where d is the GCD of a and b, |u| and |v|<|a|. */
u,v,d:=iegcd(23,13); 23u+13v
purge(u,v,d):;
/* ** ichinrem([a,m],[b,n]) returns (if possible) c such that c=a (mod m) and c=b (mod n) (if m are n coprime, c exists). */
c,n:=ichinrem([1,23],[2,13]);irem(c,23); irem(c,13)
purge(c,n):;
/* ** powmod(a,n,m) returns a^n(mod m) computed by the fast modular powering algorithm */
powmod(7,22,23)
/* ** asc converts a string to a list of ASCII code, char converts back a list to a string. These commands may be used to easily write cryptographic algorithms with string messages. */
asc("A"), asc("123+4")

/* 3.4.2 Polynomials */
/* From catalog, select Polynomials. The default variable is x, otherwise you can specify it as last optional argument. For example degree(x²·y) or degree(x²·y,x) return 2, degree(x²·y,y) returns 1. */
/* ** coeff(P,n) coefficient of x^n in P, lcoeff(P) leading coefficient of P, for example */
P_:=x^3+3x; coeff(P_,1); lcoeff(P_)
purge(P_):;
/* ** degre(P) degree of polynomial P */
degree(x^3)
/* ** quo(P,Q), rem(P,Q) quotient and remainder of euclidean division of P by Q */
P_:=x^3+7x-5; Q_:=x^2+x; quo(P_,Q_); rem(P_,Q_)

purge(P_,Q_):;
/* ** proot(P): approx. roots of P (all roots, real and complex) */
proot(x^5+x+1)

/* Graphic representation */
ClrIO; point(proot(x^5+x+1)):;
DispG
/* ** interp(X,Y): for two lists of the same size, returns the interpolating polynomial P such that P(X_i)=Y_i. */
X_,Y_:=[0,1,2,3],[1,-3,-2,0];P_:=interp(X_,Y_)=>+
/* Graphic representation */
ClrIO:; scatterplot(X_,Y_); plotfunc(P_,x,-1,4):;
/* ** resultant(P,Q) : resultant of polynomials P and Q */
purge(X_,Y_):; P_:=x^3+7x-5; Q_:=x^2+x; resultant(P_,Q_)
purge(P_,Q_):;
/* ** hermite(x,n): n-th Hermite polynomial (orthogonal for the density e^(−x²)dx on R) */
hermite(3)
/* ** laguerre(x,n,a): n-th Laguerre polynomial */
laguerre(4)
/* ** legendre(x,n) */
legendre(4)
/* ** tchebyshev1(n) and tchebyshev2(n) */
tchebyshev1(3)
tchebyshev2(3)

/* 3.5 Linear algebra, vectors, matrices */
/* Xcas does not make distinction between vectors and lists. For example, */
v:=[1,2]; w:=[3,4] // defines 2 vectors v and w, then dot will compute the scalar product of v and w
dot(v,w)

/* .A matrix is a list of lists of the same size. You can enter a matrix element by element using the matrix editor (shift-4 or 2D template [c/units] key).
Enter a new variable name to create a new matrix or the name of an existing variable to edit a matrix.
For small matrices, it is also convenient to enter them directly in the commandline, for example to define */
A_:=[[1,2],[3,4]]
/* or */
[[1,2],[3,4]]=>A_
index:=0
/* If a matrix is defined by a formula, then it’s better to use the matrix command, for example: */
matrix(2,2,(j,k)->1/(j+k+1))
/* returns the matrix where coefficient line j and column k is 1/(j+k+1) (beware, indices begin at 0). */
/* Run idn(n) to get the identity matrix of order n and ranm(n,m,law,[parameter]) to get a matrix with random coefficients with dimensions n,m. for example */
/* Line 1
Line 2
Line 3 */
U_:=ranm(4,4,uniformd,0,1)
N_:=ranm(4,4,normald,0,1)
purge(U_,N_):;

/* For basic arithmetic on matrices, use keyboard operators (+ - *, inverse). Otherwise, open catalog and select [Tools] [Math][7: Matrix] */
/* eigenvalues and eigenvectors of matrix A. */
A_:=[[1,2],[3,4]]; eigenvals(A) // [Tools] [Math][7: Matrix][6: Advenced][1: Eigenvalues]
eigenvects(A_) // [Tools] [Math][7: Matrix][6: Advenced][1: Eigenvectors]
/* finds the Jordan normal form of matrix A, returns matrices P and D such that P^−1·A·P=D, with D upper triangular (diagonal if A is diagonalizable) */
P_,D_:=jordan(A_)
purge(P_,D_):;
/* computes matrix A to the k-th power, where k is symbolic. */
Ak:=matpow(A_,k)
/* ** rref: row reduction to echelon form */
rref(A_)
/* ** lu: LU factorization of matrix A, returns a permutation P and two matrices L (lower) and U (upper) such that P·A=L·U. The result of */
P_,L_,U_:=lu(A_)
linsolve(P_,L_,U_,v)

/* to solve a system A·x=b by solving two triangular systems (in O(n²) instead of O(n³)). */
/* ** qr Q·R factorization of matrix A, Q is orthogonal and R upper triangular, A=Q·R */
/* ** svd(A) singular value decomposition of matrix A returns U orthogonal, S vector of singular values, Q orthogonal such that A=U·diag(S)·tran(Q).
The ratio of the largest and the smallest singular value of S is the condition number of A relative to the Euclidean norm */
svd(A_)
purge(A_,P_,L_,U_,v,w):;
/* 4 Probabilities and statistics
4.1 Random numbers */
/* [Tools] [Math][5: Probability][4: Random][1: Number] */
rand() // (real in [0,1])
n:=6:; randint(n)
ranv(10,normald,0,1)
purge(n):;
/* 5 Graphics */
/* [Tools] [CAS][7: Plot][1: Function] */
/* ** plot(f(x),x=a..b) plot expression f(x) for x [a,b]. Discretization option: xstep=, for example */
ClrIO; plotfunc(x^2,x=-4..4,xstep=1):;
DispG
/* Default is 384 evaluations per plot (one per horizontal pixel). */
/* ** plotseq(f(x),x=[u0,a,b]) webplot for a recurrent sequence u_(n+1)=f(u_n) of first term u_0, for example if u(n+1)=√(2+u_n),u_0=6, with a plot on [0,7] */
ClrIO; plotseq(sqrt(2+x),x=[6,0,7]):; // color ?
DispG
/* ** plotparam([x(t),y(t)],t=tm..tM) parametric plot (x(t),y(t)) for t © [tm,tM]. Discretization option: tstep=. Example */
ClrIO; plotparam([sin(2t),cos(3t)],t,0,2*pi):;
DispG

/* plotpolar(r(theta),theta=a..b) polar plot of r(θ) for θ © [a,b], for example */

ClrIO; plotpolar(sin(3*theta),theta,0,2*pi):;
DispG
ClrIO; l:=ranv(500,normald,0,1); histogram(l,-4,0.25):; plotfunc(normald(x),x,-4,4):;

purge(l):;
ClrIO; plotfield(sin(t*y),[t=-3..3,y=-3..3],plotode=[0,1]):;

ClrIO; plotfunc(sin(x),x,display=red):;
ClrIO; plotfunc(cos(x),x,color=green):;
/* 6 Programs */
/* Example : function defined by an algebraic expression nom_fonction(parametres):=expression for example simple confidence interval for a frequency p in a sample of size N */
F1_(P_,N_):=[P_-1/sqrt(N_), P_+1/sqrt(N_)]:;
/* test */
F1_(0.4,30)
/* Second example : more precise confidence interval for a frequency p in a sample of size N: */
f(P_,N_):=[P_-1.96*sqrt(P*(1-P_)/N_),P_+1.96*sqrt(P_*(1-P_)/N_)]:;

function f1(P,N) local D; D:=1.96*sqrt(P*(1-P)/N); return [P-D,P+D]; ffunction;
5**2
function square(n) repete(4,avance n,tourne_gauche); ffunction:;
efface;
for n from 1 to 10 do
square(10*n);
od;
function(a,b) local c;c=a+b;c+gcd(a,b);end;

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: khicas documentation.

Message par parisse » sam. oct. 27, 2018 4:53 am

You must open a logo level to see turtle instructions in Xcas.

compsystems
Messages : 561
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: khicas documentation.

Message par compsystems » sam. oct. 27, 2018 1:23 pm

Hello, BP, how can I execute an worksheet session, exported file as XCAS TEXT?

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: khicas documentation.

Message par parisse » sam. oct. 27, 2018 3:31 pm

Don't export it as text, save it as a worksheet!

compsystems
Messages : 561
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: khicas documentation.

Message par compsystems » lun. oct. 29, 2018 12:55 am

but the format xws, is a non-readable text, that is, to be able to share it quickly on a blog, forum, doc, pdf, etc and that another person reads it directly.

The idea is to share work sessions like the one above, and have the user copy and paste it, then execute it in Xcas quickly, without the need to download files.

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: khicas documentation.

Message par parisse » mer. oct. 31, 2018 4:19 pm

Xcas for Firefox was designed for that. No install, sessions as text links are easy to share.
xws sessions are text files if you remove the context part (// context xxxx giac archive ...)

Répondre