### Xcas Expression Simplification and Expansion Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel002 Illustrates automatic simplification and manual expression manipulation in Xcas. The `expand` command distributes multiplication across addition and expands powers. ```xcas a := 3 b := 4 a*b*x + 4*b^2 ``` ```xcas expand((x+1)^3) ``` ```xcas factor(x^2 + 3*x + 2) ``` -------------------------------- ### Xcas Calculator Operations Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel002 Demonstrates basic arithmetic operations and order of operations in Xcas. Xcas provides exact results for integer inputs and can handle fractions. It also supports decimal approximations. ```xcas 34+45*12 ``` ```xcas 2/3 + 98/7 ``` ```xcas 2/3 + 3/2 ``` ```xcas evalf(2/3 + 3/2) ``` ```xcas sin(pi/4) ``` -------------------------------- ### Xcas Plotting Functions Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel002 Demonstrates how to create basic plots in Xcas using the `plot` function. The function takes an expression and a variable, and can optionally specify the plotting interval. ```xcas plot(sin(x),x) ``` ```xcas plot(sin(x),x=-pi..pi) ``` -------------------------------- ### Xcas Variable and Function Assignment Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel002 Shows how to assign values to variables and define custom functions in Xcas. Variables can be used in subsequent expressions, and defined functions can be applied to various inputs. ```xcas x^2 + x + 2*x + 2 ``` ```xcas myvar := 5 ``` ```xcas myvar*x + myvar^2 ``` ```xcas sqr(x) := x^2 ``` ```xcas sqr(7) ``` ```xcas sqr(x+1) ``` -------------------------------- ### Xcas Prime Factorization Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Demonstrates the `ifactor` function in Xcas for obtaining the prime factorization of an integer. The output format shows the prime base and its exponent. ```xcas ifactor(250) # Returns 2*5^3 ``` -------------------------------- ### Approximate Solution of Equations with Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel005 The `fsolve` function in Xcas provides approximate solutions for equations or systems of equations. It can take an optional starting point to guide the approximation. This is useful when exact solutions are difficult or impossible to find. ```xcas fsolve(x^3 -3*x + 1,x) fsolve(x^3 -3*x + 1,x,1) ``` -------------------------------- ### Xcas Integer Division Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Demonstrates the usage of the `iquorem` function in Xcas to find both the integer quotient and remainder of a division. The function returns a list containing the quotient and the remainder. ```xcas iquorem(30, 7) # Returns [4, 2] ``` -------------------------------- ### Xcas Divisors List Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Illustrates the `idivis` function in Xcas, which returns a list of all positive divisors of a given integer, including 1 and the number itself. ```xcas idivis(250) # Returns [1, 2, 5, 10, 25, 50, 125, 250] ``` -------------------------------- ### Xcas Next Prime Number Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Demonstrates the `nextprime` function in Xcas, which finds the smallest prime number strictly greater than the given integer. ```xcas nextprime(37) # Returns 41 ``` -------------------------------- ### Xcas Prime Factors with Multiplicity Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Explains the usage of the `ifactors` function in Xcas, which returns a list of prime factors along with their multiplicities. The format is a list where each prime factor is followed by its exponent. ```xcas ifactors(250) # Returns [2, 1, 5, 3] (2^1 * 5^3) ``` -------------------------------- ### Xcas Euclidean Division Function Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel008 An example Xcas program that implements the Euclidean division algorithm to find the quotient and remainder of two integers. It handles the case where the divisor is zero. ```Xcas idiv2(a,b) := { local q,r; if (b != 0) { q := iquo(a,b); r := irem(a,b); } else { q := 0; r := a; } return [q,r]; } ``` -------------------------------- ### Xcas Extended Euclidean Algorithm Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Shows how to use the `iegcd` function in Xcas, which implements the Extended Euclidean Algorithm. It returns a list containing the greatest common divisor `d` of two integers `a` and `b`, along with the coefficients `u` and `v` such that `a*u + b*v = d`. ```xcas iegcd(72, 120) # Returns [2, -1, 24] because 72*2 + 120*(-1) = 24 ``` -------------------------------- ### Xcas Approximate Number Input Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Demonstrates how to input approximate numbers in Xcas using decimal points or scientific notation. All examples shown represent the same approximate value. ```xcas 2000.0 2e3 2.0e3 ``` -------------------------------- ### Xcas Base Input (Octal and Hexadecimal) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Shows how Xcas interprets integers starting with '0' as octal (base 8) and integers starting with '0x' as hexadecimal (base 16). ```xcas > 011 9 > 0x11 17 ``` -------------------------------- ### Matrix Creation from Function Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Matrices can be created using the 'makemat' or 'matrix' commands, which require a real-valued function of two variables, the number of rows, and the number of columns. The function defines the value of each element based on its row and column index (starting from 0). ```xcas makemat((j,k)->j+k,3,2) matrix(3,2,(j,k)->j+k) ``` -------------------------------- ### Xcas Modular Exponentiation Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Shows the usage of the `powmod` function in Xcas for efficiently calculating powers modulo a number. This is useful for large exponents where direct calculation would be computationally expensive or infeasible. ```xcas powmod(a, n, p) # Calculates (a^n) mod p ``` -------------------------------- ### Xcas Previous Prime Number Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Illustrates the `previousprime` function in Xcas, which finds the largest prime number strictly less than the given integer. ```xcas previousprime(37) # Returns 31 ``` -------------------------------- ### Xcas Modulo Arithmetic Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Explains how to perform calculations with integers modulo p in Xcas. By appending `% p` to an integer, subsequent operations are performed within the ring of integers modulo p (ℤ/pℤ). ```xcas a := 3 % 5 a * 2 # Returns 1 % 5 (since 3*2 = 6 ≡ 1 mod 5) 1 / a # Returns 2 % 5 (since 1/3 ≡ 2 mod 5) ``` -------------------------------- ### Convert Expressions to Different Formats in Xcas (sincos, partfrac) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 The 'convert' command in Xcas rewrites expressions into different formats. The second argument specifies the target format. Examples include converting 'exp(i*theta)' to 'sincos' to get trigonometric forms, or to 'partfrac' for partial fraction decomposition of rational expressions. ```xcas convert(exp(i*theta),sincos) ``` ```xcas convert((x-1)/(x^2 - x -2), partfrac) ``` -------------------------------- ### Defining Multi-variable Functions in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Shows how to define functions that accept multiple arguments, using the example of converting polar coordinates to rectangular coordinates. Both assignment operator and anonymous function syntax are demonstrated. ```Xcas > p(r,theta) := (r*cos(theta), r*sin(theta)) > p := (r, theta) -> (r*cos(theta),r*sin(theta)) ``` -------------------------------- ### Get First Character of String (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Retrieves the first character of a string using the `head` command. It is equivalent to accessing the character at index 0. ```xcas str := "abcde" head(str) ``` -------------------------------- ### Xcas Primality Test Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Shows the `isprime` function in Xcas, which checks if a given integer is a prime number. It returns `true` if the number is prime and `false` otherwise. ```xcas isprime(37) # Returns true ``` -------------------------------- ### Get String Without First Character (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Returns the portion of a string excluding its first character using the `tail` command. It is equivalent to slicing the string from index 1 to the end. ```xcas str := "abcde" tail(str) ``` -------------------------------- ### Extract Substring (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Extracts a portion of a string (substring) by specifying the start and end indices (inclusive) separated by '..'. The syntax is `string[start_index..end_index]`. Indices are zero-based. ```xcas str := "abcde" str[1..3] ``` -------------------------------- ### Convert ASCII Code to Character (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Converts an ASCII code (or a list of codes) into its corresponding character or string representation using the `char` command. For example, `char(65)` returns 'A'. ```xcas char(65) ``` -------------------------------- ### Convert Character to ASCII Code (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Converts a character (or a string) into its corresponding ASCII code (or a list of codes) using the `asc` command. For example, `asc("A")` returns `[65]`. ```xcas asc("A") ``` -------------------------------- ### Xcas Greatest Common Divisor Example Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 Illustrates the use of the `gcd` function in Xcas to calculate the greatest common divisor of two integers. The function returns the largest integer that divides both input numbers without leaving a remainder. ```xcas gcd(72, 120) # Returns 24 ``` -------------------------------- ### Xcas evalf with Precision Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Shows how to use the 'evalf' function to get an approximate value of a number, optionally specifying the desired precision. 'evalf(sqrt(2))' uses the default precision, while 'evalf(sqrt(2), 50)' requests 50 digits. ```xcas > evalf(sqrt(2)) 1.41421356237 > evalf(sqrt(2),50) 1.4142135623730950488016887242096980785696718753770 ``` -------------------------------- ### Xcas Recursive GCD Program Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel008 An example of a recursive function in Xcas that calculates the greatest common divisor (GCD) of two integers. It utilizes the property that GCD(a, b) = GCD(b, a mod b). ```Xcas pgcdr(a,b) := { if (b == 0) return a; return pgcdr(b, irem(a,b)); }:; ``` -------------------------------- ### Access String Character by Index (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Retrieves a specific character from a string using its zero-based index. The syntax is `string_variable[index]` or `string_literal[index]`. For example, `str[0]` returns the first character. ```xcas str := "abcde" str[0] ``` -------------------------------- ### Solving Multiple Linear Systems with simult Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 The 'simult' command solves multiple linear systems that share the same coefficient matrix. It takes the coefficient matrix and a matrix of solution vectors as input. The output is a matrix where each column represents the solution to a corresponding system. It returns an error if no solution exists for any system and one solution if infinitely many exist. ```xcas simult([[1,1,-1],[1,-1,1],[-1,1,1]],[[1,-2],[1,1],[-2,1]]) ``` -------------------------------- ### Matrix and Vector Operations Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 This section covers basic and advanced operations on vectors and matrices. It includes scalar and cross products for vectors, matrix multiplication, element-wise product, matrix inverse, transpose, rank, determinant, kernel, image, identity matrix generation, random matrix creation, and matrix construction from functions. It also explains how to combine matrices using blockmatrix and how to access elements or submatrices. ```xcas v*w cross(v,w) A*B A.*B 1/A tran(A) rank(A) det(A) ker(A) image(A) idn(n) ranm(m,n) makemat(func,m,n) matrix(m,n,func) blockmatrix(m,n,list_of_matrices) A[i,j] A[i1..i2,j1..j2] ``` -------------------------------- ### Solving Linear Systems with linsolve Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 The 'linsolve' command is used to find the solution to a system of linear equations. Its syntax is similar to the 'solve' command. It returns an empty list if no solution exists, formulas for all solutions if there are infinitely many, and a specific solution otherwise. ```xcas linsolve([2*x + 3*y = 4, 5*x + 4*y = 3],[x,y]) ``` -------------------------------- ### Matrix Combination Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 The 'blockmatrix' command combines several matrices into a larger one. It requires the number of rows and columns of matrices to arrange, and a list of the matrices to be combined in order. ```xcas A := [[1,2,3],[4,5,6]] B := [[1,2],[2,3]] blockmatrix(2,2,[A,B,B,A]) ``` -------------------------------- ### Xcas Large Integer Factorial Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Example of Xcas handling arbitrarily large integers, shown here by calculating the factorial of 500, which results in a number with 1135 digits. ```xcas > 500! [output omitted due to length] ``` -------------------------------- ### Xcas Basic Syntax and Control Flow Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel008 This snippet covers fundamental Xcas programming constructs including variable assignment, input/output operations, loop structures (for, repeat, while, do), and conditional statements (if-then, if-then-else). ```Xcas a:=2; // assignment input("a=",a); // input expression textinput("a=",a); // string input print("a=",a); // output return(a); // return value break; // break out of loop continue; // go to the next iteration if () ; // if...then if () else ; // if...then...else for (j:= a;j<=b;j++) ; // for loop for (j:= a;j<=b;j:=j+p) ; // for loop repeat until ; // repeat loop while () ; // while loop do if () break; od; // do loop ``` -------------------------------- ### Xcas Try-Catch for Error Handling Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel008 Shows how to implement error handling in Xcas using the try-catch construct. This allows programs to gracefully manage runtime errors by executing specific blocks of code when an error occurs. ```Xcas try { block to catch errors } catch (variable) { block to execute when an error is caught } ``` ```Xcas try { A := idn(2) * idn(3) } // Example of potential error catch (error) { print("The error is " + error) } ``` -------------------------------- ### Xcas Integer Arithmetic Functions Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 This section covers various integer arithmetic functions in Xcas. It includes functions for finding remainders, quotients, prime factorizations, greatest common divisors, and performing primality tests. Some functions return single values, while others return lists or coefficients. ```xcas irem(a, p) # remainder iquo(a, p) # quotient iquorem(a, p) # quotient and remainder ifactor(n) # prime factorization ifactors(n) # list of prime factors idivis(n) # list of divisors gcd(a, b) # greatest common divisor lcm(a, b) # least common multiple iegcd(a, b) # Bezout’s identity (returns [u, v, d]) isprime(n) # primality test (returns true or false) nextprime(n) # next prime number previousprime(n) # previous prime number powmod(a, n, p) # a^n modulo p ``` -------------------------------- ### Plotting Functions with Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 The 'plot' command graphs expressions of one or two variables. It accepts a list of expressions, the variable, and optionally a domain for the variable and a list of colors to distinguish multiple curves. Dependencies: None. Input: Expression(s), variable, optional range and colors. Output: A plot of the function(s). ```xcas plot([x^2,x^3],x=-1..1,color=[red,blue]) ``` -------------------------------- ### Xcas Function Declaration Syntax Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel008 Illustrates the syntax for declaring functions in Xcas. This includes defining function names, parameters, local variables, and the structure for statements within the function body. ```Xcas function_name (var1, var2, ...) := { local var_loc1, var_loc2, ... ; statement1; statement2; ... } ``` -------------------------------- ### Get String Length (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Calculates the number of characters in a given string using the `size` command. The command takes a string literal or a string variable as input and returns an integer representing its length. ```xcas size("this string") ``` -------------------------------- ### Xcas Boolean Operators Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel008 Demonstrates the boolean operators available in Xcas for conditional logic and comparisons. These include equality, inequality, relational operators, logical AND/OR, and boolean truth values. ```Xcas == // test for equality != // test for inequality < // test for strictly less than > // test for strictly greater than <= // tes for less than or equal >= // test for greater than or equal to &&, and // infixed “and” ||, or // infixed “or” true // boolean true (same as 1) false // boolean false (same as 0) not, ! // “not” ``` -------------------------------- ### Exact Solution of Equations and Systems with Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel005 The `solve` function in Xcas finds exact solutions for single equations or systems of equations. It can handle polynomial and trigonometric equations. For systems, provide equations and variables as lists. By default, it finds real solutions, but can be configured for complex solutions. For higher-degree polynomials, it may return intermediate or approximate results. ```xcas solve(x^3 -2*x^2 + 1=0, x) solve(x^3+1=0,x) solve(cos(x) + sin(x) = 0, x) solve([x^2 + y - 2, x + y^2 - 2],[x,y]) ``` -------------------------------- ### Placing Text with Legend in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 The 'legend' command is used to place text on the graphics screen. A simple usage involves providing a point and the text string to be displayed at that location. Dependencies: None. Input: Point, text string. Output: Text displayed on the graphics screen. ```xcas legend(point,text) ``` -------------------------------- ### Drawing Polygons with Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 Xcas provides commands to draw polygonal lines and closed polygons. 'polygonplot' and 'scatterplot' take lists of x and y coordinates, while 'polygon' and 'open_polygon' take sequences of points. Dependencies: None. Input: Lists of coordinates or sequences of points. Output: A polygonal line or polygon. ```xcas polygonplot([0,2,0],[0,0,2]) ``` ```xcas open_polygon(point(0,0),point(2,0),point(0,2)) ``` -------------------------------- ### Xcas Infinity Calculations Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Demonstrates the handling of different types of infinity in Xcas. '1/0' results in unsigned infinity, '(1/0)^2' results in positive infinity, and '-(1/0)^2' results in negative infinity. ```xcas > 1/0 ∞ > (1/0)^2 +∞ > -(1/0)^2 −∞ ``` -------------------------------- ### Transforming Expressions into Functions with unapply in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Explains the use of the 'unapply' command to convert an expression into a function. It takes the expression and the variable(s) as arguments and returns a function definition. ```Xcas > unapply(x*exp(x),x) > unapply(f(x),x) ``` -------------------------------- ### Factor Polynomials and Reduce Rational Expressions in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 The 'factor' command in Xcas factors polynomials and reduces rational expressions. It returns the result in a factored form, which can be useful for analysis. For example, factoring x^2 + 3*x + 2 yields (x + 1)*(x + 2). ```xcas factor(x^2 + 3*x + 2) ``` -------------------------------- ### Gauss-Jordan Reduction Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel006 The 'rref' command performs Gauss-Jordan reduction on a given matrix. This is a fundamental method for solving linear systems and analyzing matrices. ```xcas rref(A) ``` -------------------------------- ### Expand Powers and Distribute Multiplication in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 The 'expand' command in Xcas is used to expand integer powers and distribute multiplication across addition within an expression. It takes an expression as input and returns the expanded form. For example, expanding (x+1)^3 results in x^3 + 3*x^2 + 3*x + 1. ```xcas expand((x+1)^3) ``` -------------------------------- ### Plotting 3D Functions with plotfunc Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 The plotfunc command visualizes a function of two variables, z = f(x,y), in a 3D space. It accepts an expression for the function and a list of variables with optional interval specifications. The default domain is used if intervals are not provided. ```Xcas plotfunc(y^2 - x^2,[x=-1..1,y=-1..1]) ``` -------------------------------- ### Xcas Exact vs. Approximate Addition Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Compares the results of adding numbers in Xcas. '3/2 + 1' yields an exact rational number, while '1.5 + 1' yields an approximate decimal number because 1.5 is an approximate input. ```xcas > 3/2 + 1 5/2 > 1.5 + 1 2.5 ``` -------------------------------- ### Creating Polygons in 3D with Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 Xcas supports the creation of polygons and open polygons in three-dimensional space. These commands function similarly to their 2D counterparts but operate within a 3D coordinate system. ```Xcas polygon([[0,0,0],[1,0,0],[0,1,0]]) open_polygon([[0,0,0],[1,0,0],[0,1,0],[1,1,0]]) ``` -------------------------------- ### Xcas Number Conversions Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Functions to convert numbers between exact and approximate representations. 'evalf' approximates a number, 'exact' finds a nearby exact rational number, and 'epsilon' defines the tolerance for 'exact'. ```xcas evalf| approximate a number exact| find an exact number close to the given number epsilon| determine how close a fraction has to be to a floating point number to be returned by exact ``` -------------------------------- ### Function Composition using '@' Operator in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Demonstrates function composition in Xcas using the '@' operator. It shows how to define two functions, 'f' and 'g', and then compose them to create a new function representing f(g(x)). ```Xcas > f(x) := x^2 + 1 > g(x) := sin(x) > f @ g ``` -------------------------------- ### Defining Points in Xcas Plane Geometry Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 The 'point' command defines a point in Xcas's plane geometry environment. It can accept an ordered pair, two real numbers, or a complex number to specify the point's coordinates. Dependencies: None. Input: Ordered pair, two real numbers, or a complex number. Output: A point object. ```xcas point(x,y) ``` ```xcas point(complex_number) ``` -------------------------------- ### Defining Functions using Derivatives with unapply in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Demonstrates a scenario where 'unapply' is necessary to define a function based on a derivative. It highlights that direct assignment of a derivative expression to a function can lead to incorrect evaluation. ```Xcas > g := unapply(diff(x*sin(x),x),x) ``` -------------------------------- ### Xcas Iterative GCD Program Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel008 This Xcas program computes the greatest common divisor (GCD) of two integers using an iterative approach based on the Euclidean algorithm. ```Xcas pgcdi(a,b) := { local r; while (b != 0) { r := irem(a,b); a := b; b := r; } return a; }:; ``` -------------------------------- ### Defining Functions with Assignment Operator (:=) in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Demonstrates defining a function 'f' using the assignment operator ':=', where f(x) is assigned the expression x*exp(x). It also shows how to evaluate the function at a specific value. ```Xcas > f(x) := x*exp(x) > f(2) ``` -------------------------------- ### Defining 3D Geometric Objects in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 Xcas provides commands to define basic 3D geometric objects. The 'point' command creates a point with three coordinates. 'sphere' defines a sphere by its center and radius. 'plane' can be defined using three points, a line and two points, or an equation. ```Xcas point(1,2,3) sphere([0,0,0], 5) plane(x+y+z=1) ``` -------------------------------- ### Xcas Exact vs. Approximate Calculation (sin) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Illustrates the difference between exact and approximate calculations in Xcas using the sin function. 'sin(1)' returns an exact symbolic result, while 'sin(1.0)' uses an approximate input and returns a decimal approximation. ```xcas > sin(1) sin(1) > sin(1.0) 0.841470984808 ``` -------------------------------- ### Defining Functions by Multiplying Functions in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Explains how functions can be combined through arithmetic operations like multiplication. Instead of defining f(x) as an expression, it can be defined as the product of existing functions, like 'sin' and 'exp'. ```Xcas > f := sin*exp ``` -------------------------------- ### Plotting 3D Parametric Surfaces with plotparam Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 The plotparam command can render parametric surfaces defined by a list of three expressions in two variables. Optionally, intervals can be specified for the parameters. This command is useful for creating complex 3D shapes. ```Xcas plotparam([u,u+v,v],u,v) ``` -------------------------------- ### Linear System Solver in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel005 The `linsolve` function in Xcas is specifically designed to solve linear systems of equations. It efficiently finds the solution set for systems composed of linear equations. ```xcas linsolve(a*x+b*y=c, d*x+e*y=f, [x,y]) ``` -------------------------------- ### Drawing Circles in Xcas Plane Geometry Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 The 'circle' command draws a circle in Xcas's plane geometry. It requires a point (the center) and a radius as arguments. Dependencies: 'point' command. Input: Center point, radius. Output: A circle object. ```xcas circle(center_point,radius) ``` -------------------------------- ### Correct Function Definition for Squaring Operation in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Shows the correct ways to define a squaring function. It contrasts the incorrect method of assigning an expression directly to a variable and then to a function, with the correct methods using direct assignment or 'unapply'. ```Xcas > f(x) := x^2 > f := unapply(sq,x) ``` -------------------------------- ### Reduce Rational Functions to Lowest Terms in Xcas (normal, ratnormal) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 The 'normal' and 'ratnormal' commands reduce rational functions to their lowest terms by canceling common factors. 'normal' also considers reductions with algebraic numbers, while 'ratnormal' does not. For instance, (x^3-1)/(x^2-1) reduces to (x^2+x+1)/(x+1). ```xcas normal((x^3-1)/(x^2-1)) ``` ```xcas ratnormal((x^2-2)/(x-sqrt(2))) ``` ```xcas normal((x^2-2)/(x-sqrt(2))) ``` -------------------------------- ### Approximate Polynomial Roots in Xcas Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel005 The `proot` function in Xcas is used to find approximate roots of a polynomial. This function is particularly useful when dealing with polynomials for which exact root finding is computationally intensive or not feasible. ```xcas proot(x^3 -2*x^2 + 1) ``` -------------------------------- ### Plotting 3D Parametric Curves with plotparam Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel007 When given a list of three expressions in a single variable, the plotparam command draws a parametric curve in 3D space. An optional interval can be provided for the parameter. This is useful for visualizing paths or shapes defined parametrically. ```Xcas plotparam([cos(t),sin(t),t],t) ``` -------------------------------- ### Convert List Polynomial to Symbolic (Xcas) Source: https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/doc/en/tutoriel/tutoriel004 Transforms a polynomial represented as a list of coefficients back into its symbolic expression using the `poly2symb` command. It takes the `poly1[...]` format as input and returns a standard polynomial expression. ```xcas poly2symb(poly1[2,0,-4,1]) ```