### Example: AnglePath with initial position and specified distances/angles Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/AnglePath.md Illustrates AnglePath with a specified starting point and varying distances and angles for each step. ```mathematica >> AnglePath({{1, 1}, 90*Degree}, {{1, 90*Degree}, {2, 90*Degree}, {1, 90*Degree}, {2, 90*Degree}}) {{1, 1}, {0, 1}, {0, -1}, {1, -1}, {1, 1}} ``` -------------------------------- ### Package Definition Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/BeginPackage.md This example demonstrates how BeginPackage affects the context path. After starting a new package, the context path is updated. EndPackage then reverts this change. ```mathematica >> BeginPackage("Test`") >> $ContextPath {Test`,System`} >> EndPackage( ) >> $ContextPath {Test`,System`,Global`} ``` -------------------------------- ### SquareFreeQ Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/SquareFreeQ.md Examples demonstrating the usage of SquareFreeQ for integer inputs. ```mathematica >> SquareFreeQ(9) False ``` ```mathematica >> SquareFreeQ(105) True ``` -------------------------------- ### Example Usage Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Ratios.md Demonstrates the usage of the Ratios function with an example. ```APIDOC ## Examples ``` >> Ratios({a,b,c,d,e,f,g,h},5) {(b^5*d^10*f)/(a*c^10*e^5),(c^5*e^10*g)/(b*d^10*f^5),(d^5*f^10*h)/(c*e^10*g^5)} ``` ``` -------------------------------- ### Example: Array with function, 2D dimension, and origin Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Array.md Demonstrates creating a 2x3 matrix with indices starting from (4, 6). ```mathematica >> Array(f, {2, 3}, {4, 6}) {{f(4,6),f(4,7),f(4,8)},{f(5,6),f(5,7),f(5,8)}} ``` -------------------------------- ### Save Example: Saving a list of functions Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Save.md Demonstrates how to save a list of function definitions to a temporary file and then retrieve them using Get. ```APIDOC ### Example: Save a definition with dependent symbol definitions into temporary file ``` >> g(x_) := x^3; >> g(x_,y_) := f(x,y); >> SetAttributes(f, Listable); >> f(x_) := g(x^2); >> temp = FileNameJoin({$TemporaryDirectory, "savedlist.txt"});Print(temp); >> Save(temp, {f,g}) >> ClearAll(f,g) >> "Attributes(f) >> {f(2),g(7)} >> Get(temp) >> {f(2),g(7)} {64,343} >> Attributes(f) {Listable} ``` ``` -------------------------------- ### Start New Context Definition with Begin Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Begin.md Use the Begin function to start a new context definition. This function takes a context name as a string argument. The example demonstrates creating a context named 'mytest`', then switching back to the default context. ```matheclipse Begin("mytest`") ``` ```matheclipse Context() ``` ```matheclipse mytest` ``` ```matheclipse $ContextPath ``` ```matheclipse End() ``` ```matheclipse mytest` ``` ```matheclipse Context() ``` ```matheclipse Global` ``` ```matheclipse $ContextPath ``` -------------------------------- ### Split Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Split.md Examples demonstrating the usage of the Split function. ```APIDOC ## Examples ### Example 1: Splitting into identical elements ``` >> Split({x, x, x, y, x, y, y, z}) {{x,x,x},{y},{x},{y,y},{z}} ``` ### Example 2: Splitting with a test function (equality) ``` >> Split({x, x, x, y, x, y, y, z}, x) {{x},{x},{x},{y},{x},{y},{y},{z}} ``` ### Example 3: Splitting into increasing or decreasing runs ``` >> Split({1, 5, 6, 3, 6, 1, 6, 3, 4, 5, 4}, Less) {{1,5,6},{3,6},{1,6},{3,4,5},{4}} >> Split({1, 5, 6, 3, 6, 1, 6, 3, 4, 5, 4}, Greater) {{1},{5},{6,3},{6,1},{6,3},{4},{5,4}} ``` ### Example 4: Splitting based on the first element ``` >> Split({x -> a, x -> y, 2 -> a, z -> c, z -> a}, First(#1) === First(#2) &) {{x->a,x->y},{2->a},{z->c,z->a}} ``` ### Example 5: Splitting an empty list ``` >> Split({}) {} ``` ``` -------------------------------- ### Start BeakerX Server Source: https://github.com/axkr/symja_android_library/wiki/BeakerX-usage Command to start the BeakerX server, typically used before creating a new notebook. ```bash beakerx ``` -------------------------------- ### Initialize SymjaTalk Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-api/src/main/resources/org/matheclipse/api/indexapi.html Call the setupExamples() function to initialize the interactive examples for SymjaTalk. This function is typically called after the page has loaded to ensure all necessary components are ready. ```javascript setupExamples(); ``` -------------------------------- ### Output of the Print Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Print.md Shows the expected console output when the example code snippet is executed. ```text 1 2 3 4 5 ``` -------------------------------- ### Start Symja JSON API Server Source: https://github.com/axkr/symja_android_library/wiki/API This command starts the Symja JSON API server using a batch script. Ensure Java 11 is installed and JAVA_HOME is set correctly. The classpath includes all libraries in the 'lib' directory. ```bash "%JAVA_HOME%\bin\java" -Dfile.encoding=UTF-8 -classpath "lib/*" org.matheclipse.api.SymjaServer ``` -------------------------------- ### Do Function Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Do.md Illustrative examples of how to use the Do function, including basic iteration, nested loops, and control flow with Break and Continue. ```APIDOC ### Examples ``` >> Do(Print(i), {i, 2, 4}) | 2 | 3 | 4 >> Do(Print({i, j}), {i,1,2}, {j,3,5}) | {1, 3} | {1, 4} | {1, 5} | {2, 3} | {2, 4} | {2, 5} ``` You can use `Break()` and `Continue()` inside `Do`: ``` >> Do(If(i > 10, Break(), If(Mod(i, 2) == 0, Continue()); Print(i)), {i, 5, 20}) | 5 | 7 | 9 >> Do(Print("hi"),{1+1}) | hi | hi ``` The [A005132 Recaman's sequence](http://oeis.org/A005132) integer sequence ``` >> a = {1}; Do( If( a[ [ -1 ] ] - n > 0 && Position( a, a[ [ -1 ] ] - n ) == {}, a = Append( a, a[ [ -1 ] ] - n ), a = Append( a, a[ [ -1 ] ] + n ) ), {n, 2, 70} ); a {1,3,6,2,7,13,20,12,21,11,22,10,23,9,24,8,25,43,62,42,63,41,18,42,17,43,16,44,15,45,14,46,79,113,78,114,77,39,78,38,79,37,80,36,81,35,82,34,83,33,84,32,85,31,86,30,87,29,88,28,89,27,90,26,91,157,224,156,225,155} ``` ``` -------------------------------- ### PDF Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/PDF.md Illustrative examples demonstrating the usage of the PDF function with different distributions and values. ```APIDOC ### Examples ``` >> PDF(NormalDistribution(n, m)) 1/(Sqrt(2)*E^((-n+#1)^2/(2*m^2))*m*Sqrt(Pi))& >> PDF(GumbelDistribution(n, m),k) E^(-E^((k-n)/m)+(k-n)/m)/m >> Table(PDF(NormalDistribution( ), x), {m, {-1, 1, 2}},{x, {-1, 1, 2}})//N {{0.24197,0.24197,0.05399},{0.24197,0.24197,0.05399},{0.24197,0.24197,0.05399}} ``` ``` -------------------------------- ### Graphics3D Example with Multiple Cylinders and Color Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Cylinder.md Shows how to create a 3D graphic with multiple cylinders of radius 1, colored yellow, and defined by specific start and end points. ```mathematica >> Graphics3D({Yellow, Cylinder({{-1, 0, 0}, {1, 0, 0}, {0, 0, Sqrt(3)}, {1, 1, Sqrt(3}}, 1)}) ``` -------------------------------- ### Example: Array with function, 2D dimension, and single origin value Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Array.md Demonstrates creating a 2x3 matrix where the starting index for both dimensions is 3. ```mathematica >> Array(f, {2, 3}, 3) {{f(3, 3), f(3, 4), f(3, 5)}, {f(4, 3), f(4, 4), f(4, 5)}} ``` -------------------------------- ### FixedPoint Example: Cosine Convergence Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FixedPoint.md Demonstrates finding the fixed point of the Cosine function starting from 1.0. The result is the value where Cos(x) = x. ```mathematica >> FixedPoint(Cos, 1.0) 0.7390851332151607 ``` -------------------------------- ### SubtractFrom Example Usage Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/SubtractFrom.md Demonstrates the usage of the SubtractFrom function with a numerical example. ```mathematica >> a = 10 >> a -= 2 8 >> a 8 ``` -------------------------------- ### Load Package using Get() Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Get.md Use the Get function to load a package from a specified file path. This function requires a file system to be available. ```mathematica Get("path-to-package-file-name") ``` -------------------------------- ### Append to File Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/OpenAppend.md This example shows how to write initial content to a file using OpenWrite, then append new content using OpenAppend. The file is closed after each operation. ```mathematica >> f = FileNameJoin({$TemporaryDirectory, "test_open.txt"}) /tmp/test_open.txt ``` ```mathematica >> str = OpenWrite(f); >> Write(str, x^2 - y^2) >> Close(str); ``` ```mathematica >> FilePrint(f) x^2 - y^2 ``` ```mathematica >> str = OpenAppend(f); >> Write(str, x^2 + y^2) >> Close(str); ``` ```mathematica >> FilePrint(f) x^2 - y^2 x^2 + y^2 ``` -------------------------------- ### Start a New Context Definition with Begin Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Begin.md Use Begin() to start a new context definition. This function is useful for creating isolated environments for calculations or definitions. ```matheclipse Begin("") ``` -------------------------------- ### InputString Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Input.md Demonstrates the usage of InputString with a specific input. This example shows how to use InputString to process input, in this case, cubing the input "::". ```java >> InputString("::")^3 ``` -------------------------------- ### ArrayRules Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/ArrayRules.md Examples demonstrating the usage of the ArrayRules function. ```APIDOC ### Examples ``` >> a = {{{0,0},{1,1}},{{0,1},{0,1}}} {{{0,0},{1,1}},{{0,1},{0,1}}} >> ArrayRules(a) {{1,2,1}->1,{1,2,2}->1,{2,1,2}->1,{2,2,2}->1,{_,_,_}->0} ``` ``` -------------------------------- ### Example: FileHash with StringToStream and MD5 Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FileHash.md Demonstrates computing the MD5 hash of a string converted to a stream. This example shows a practical application of the FileHash function. ```java >> FileHash(StringToStream("Hello World"),"MD5") 235328152096874191772633713977838157797 ``` -------------------------------- ### File Preparation and Initial Write Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/OpenAppend.md Prepares a file by joining a directory and filename, then opens it for writing and adds initial content. This sets up the file for subsequent appending. ```mathematica >> f = FileNameJoin({$TemporaryDirectory, "test_open.txt"}) /tmp/test_open.txt >> str = OpenWrite(f); >> Write(str, x^2 - y^2) >> Close(str); ``` -------------------------------- ### FixedPoint Example: Iterative Addition Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FixedPoint.md Shows an example of using FixedPoint with an anonymous function for iterative addition. It adds 1 to the starting value 1, for 20 iterations. ```mathematica >> FixedPoint(#+1 &, 1, 20) 21 ``` -------------------------------- ### StringFreeQ Example 1 Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/StringFreeQ.md Demonstrates basic usage of StringFreeQ with a simple string and pattern. ```mathematica >> StringFreeQ("symja", "s" ~~__ ~~"a") False ``` -------------------------------- ### Predefined Constant Usage Example Source: https://github.com/axkr/symja_android_library/wiki/expression-types Refer to built-in constants. Names start with an uppercase letter. ```plaintext Degree, E, Pi, False, True, ... ``` -------------------------------- ### PolynomialQ Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/PolynomialQ.md Demonstrates the usage of PolynomialQ with different expressions and variables. These examples show how the function evaluates to true or false based on whether the expression is a polynomial. ```Symja >> PolynomialQ(x^2 + 7*x + 6) True ``` ```Symja >> PolynomialQ(Cos(x*y), Cos(x*y)) True ``` ```Symja >> PolynomialQ(2*x^3,x^2) False ``` -------------------------------- ### Example: Default Alphabet Output Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Alphabet.md Demonstrates the output when calling Alphabet() to get the English alphabet. ```text >> Alphabet() {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z} ``` -------------------------------- ### Context Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Context.md Demonstrates the usage of the Context function with different symbols and shows the current context path. ```mathematica >> $ContextPath {System`,Global`} >> Context(a) Global` >> Context(Sin) System` ``` -------------------------------- ### Example: SparseArray Initialization from Rules Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/SparseArray.md Demonstrates the creation of a SparseArray using a rule-based definition. The output shows the number of elements, dimensions, and the default value. ```mathematica >> SparseArray({{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}) SparseArray(Number of elements: 4 Dimensions: {3,3} Default value: 0) ``` -------------------------------- ### Get Inverse Function Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/InverseFunction.md Returns the inverse function for the symbol `head`. For example, the inverse of `Sin` is `ArcSin`. ```mathematica >> InverseFunction(Sin) ArcSin ``` -------------------------------- ### Increment Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Increment.md Shows a practical example of using the increment operator. Assigns 2 to 'a', then increments 'a' and shows the returned value (2), followed by the new value of 'a' (3). ```mathematica >> a = 2; >> a 2 >> a = 2; >> a++ 2 >> a 3 ``` -------------------------------- ### Sign of an Interval Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Interval.md Determines the sign of a given interval. This example shows how to get the sign for a negative interval. ```java Sign(Interval({-43, -42})) ``` -------------------------------- ### FixedPointList Example: Cosine Convergence Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FixedPointList.md Demonstrates the convergence of `FixedPointList` with the `Cos` function starting from 1.0 for 4 iterations. ```mathematica >> FixedPointList(Cos, 1.0, 4) {1.0,0.5403023058681398,0.8575532158463934,0.6542897904977791,0.7934803587425656} ``` -------------------------------- ### Creating and Showing a JFrame Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/JavaShow.md This example demonstrates creating a new `javax.swing.JFrame` and then displaying it using the `JavaShow` function. Ensure that Java classes are loaded and accessible before attempting to create and show them. ```mathematica >> frame= JavaNew["javax.swing.JFrame", "Simple JFrame Demo"]; JavaShow[frame] ``` -------------------------------- ### Example: InputForm for Contexts Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Contexts.md Demonstrates the InputForm representation of the `Contexts[]` command, showing the expected output format for a list of contexts. ```mathematica >> Contexts[] // InputForm {"Global`","Rubi`","System`"} ``` -------------------------------- ### Predefined Function Call Example Source: https://github.com/axkr/symja_android_library/wiki/expression-types Call built-in functions. Function names start with an uppercase letter, and arguments are in parentheses. ```plaintext Sin(0), PrimeQ(13) ``` -------------------------------- ### Get System Symbols by Pattern Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Names.md Use the Names function with a pattern to retrieve all symbols starting with 'System`'. The result can then be filtered further. ```mathematica >> sysnames = Names("System`*"); >> Select(sysnames, MemberQ(Attributes(#), OneIdentity) &) // InputForm ``` -------------------------------- ### Gaussian Integer Primality Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/PrimeQ.md Illustrates the use of PrimeQ with GaussianIntegers->True to check for primality of Gaussian integers. Shows examples of composite and prime Gaussian integers. ```mathematica >> PrimeQ(2, GaussianIntegers->True) False ``` ```mathematica >> PrimeQ(5+2*I, GaussianIntegers->True) True ``` -------------------------------- ### TimesBy Usage Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/TimesBy.md Demonstrates the usage of the TimesBy function with an example. Initialize a variable and then apply TimesBy for multiplication. ```mathematica >> a = 10 >> a *= 2 20 >> a 20 ``` -------------------------------- ### Example: AssociationThread with Rules Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/AssociationThread.md Illustrates creating an association using the rule-based syntax. This example shows how to define key-value mappings directly within the function call. ```mathematica >> AssociationThread({"U","V"} :> {1,2}) <|U:>1,V:>2|> ``` -------------------------------- ### Get Cycles of a Permutation Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Cycles.md The PermutationCycles function returns the canonical cycle decomposition of a permutation. This example shows how singletons are handled. ```Symja >> PermutationCycles({4,2,7,6,5,8,1,3}) Cycles({{1,4,6,8,3,7}}) ``` -------------------------------- ### Example: Principle Components Calculation (Correlation Method) Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/PrincipleComponents.md Demonstrates the calculation of principle components using the Correlation method. ```java >> PrincipalComponents({{90.0, 60, 90},{90, 90, 30},{60, 60, 60},{60, 60, 90},{30, 30, 30}}, Method->"Correlation") {{ 0.911826,-0.942809,0.440421}, {1.38323,1.41421,-0.0309834}, {-0.169031,0.0,-0.169031}, {0.0666714,-0.942809,-0.404733}, {-2.1927,0.471405,0.164326}} ``` -------------------------------- ### UnsameQ Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/UnsameQ.md Demonstrates the usage of UnsameQ with different inputs. Any object is the same as itself, and numerical equality is checked. ```mathematica >> a=! =a False ``` ```mathematica >> 1=! =1.0 True ``` -------------------------------- ### Example: FourierDCTMatrix(3, 1) Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FourierDCTMatrix.md Demonstrates the creation of a 3x3 DCT matrix using method 1. The output shows the resulting matrix elements. ```mathematica >> FourierDCTMatrix(3, 1) {{1/2,1/2,1/2}, {1,0,-1}, {1/2,-1/2,1/2}} ``` -------------------------------- ### Find All Occurrences of a Pattern Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/StringPosition.md Use StringPosition to get a list of all starting and ending positions where a pattern matches within a given string. ```Symja StringPosition("string", patt) ``` -------------------------------- ### Get Fractional Part of a Number Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FractionalPart.md Use FractionalPart to extract the decimal portion of a number. For example, FractionalPart(1.5) returns 0.5. ```mathematica FractionalPart(number) ``` ```mathematica >> FractionalPart(1.5) 0.5 ``` -------------------------------- ### Example: Import GraphML Graph Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Import.md Demonstrates importing a graph in GraphML format from a local file path and the expected output. ```Java >> Import("c:\\temp\\dotgraph.graphml", "GraphML") Graph({1, 2, 3}, {(1,2), (2,3), (3,1)}) ``` -------------------------------- ### Basic PrimeQ Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/PrimeQ.md Demonstrates the basic usage of PrimeQ for various integer inputs, including positive, negative, and composite numbers. ```mathematica >> PrimeQ(2) True ``` ```mathematica >> PrimeQ(-3) True ``` ```mathematica >> PrimeQ(137) True ``` ```mathematica >> PrimeQ(2 ^ 127 - 1) True ``` ```mathematica >> PrimeQ(1) False ``` ```mathematica >> PrimeQ(2 ^ 255 - 1) False ``` -------------------------------- ### Distribute Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Distribute.md Demonstrates how the Distribute function expands a product of sums into a sum of products. ```mathematica >> Distribute((a+b)*(x+y+z)) ``` -------------------------------- ### Get Function Usage Documentation Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/beakerx/SymjaGroovy.ipynb Display the documentation for a given function, including its signature, description, and examples. This is helpful for learning how to use Symja functions. ```python usage(Im) ``` -------------------------------- ### InterpolatingPolynomial Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/InterpolatingPolynomial.md Demonstrates how to get the polynomial representation for a given data-list using the InterpolatingPolynomial function. The input is a list of coordinate pairs and a symbol for the polynomial variable. ```mathematica >> InterpolatingPolynomial({{1,7},{3,11},{5,27}},x) (3/2*x-5/2)*(x-1)+7 ``` -------------------------------- ### Example: Principle Components Calculation (Covariance Method) Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/PrincipleComponents.md Demonstrates the calculation of principle components using the default Covariance method. ```java >> PrincipalComponents({{90.0, 60, 90},{90, 90, 30},{60, 60, 60},{60, 60, 90},{30, 30, 30}}) {{ 34.37098,-13.66927,-10.38202}, {9.98346,47.68821,1.47161}, {-3.93481,-2.31599,3.89274}, {14.69692,-25.24923,9.08167}, {-55.11655,-6.45371,-4.06399}} ``` -------------------------------- ### Example: PearsonCorrelationTest returning TestData Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/PearsonCorrelationTest.md Demonstrates how to use PearsonCorrelationTest to get the test data for two sample vectors. The result is a list containing the correlation coefficient and the p-value. ```mathematica >> PearsonCorrelationTest({1, 2, 3, 5, 8}, {0.11, 0.12, 0.13, 0.15, 0.18}, "TestData") {1.0,0.0} ``` -------------------------------- ### Example: AssociationThread with Lists Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/AssociationThread.md Demonstrates creating an association by providing separate lists for keys and values. The output shows the resulting association with key-value pairs. ```mathematica >> AssociationThread({"U","V"},{1,2}) <|U->1,V->2|> ``` -------------------------------- ### Gather Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Gather.md Demonstrates how the Gather function groups elements. The first example shows default grouping, and the second shows grouping with a custom test (implicit equality for fractions). ```Symja >> Gather({1, 7, 3, 7, 2, 3, 9}) {{1},{7,7},{3,3},{2},{9}} ``` ```Symja >> Gather({1/3, 2/6, 1/9}) {{1/3,1/3},{1/9}} ``` -------------------------------- ### DirectedInfinity Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/DirectedInfinity.md Demonstrates the usage and output of DirectedInfinity with various inputs. Note that division by DirectedInfinity results in 0. ```mathematica >> DirectedInfinity(1) Infinity ``` ```mathematica >> DirectedInfinity() ComplexInfinity ``` ```mathematica >> DirectedInfinity(1 + I) DirectedInfinity((1+I)/Sqrt(2)) ``` ```mathematica >> 1 / DirectedInfinity(1 + I) 0 ``` ```mathematica >> DirectedInfinity(1) + DirectedInfinity(-1) Indeterminate ``` ```mathematica >> DirectedInfinity(1+I)+DirectedInfinity(2+I) DirectedInfinity((1+I)/Sqrt(2))+DirectedInfinity((2+I)/Sqrt(5)) ``` ```mathematica >> DirectedInfinity(Sqrt(3)) Infinity ``` -------------------------------- ### Get System Symbols Matching a Pattern Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Names.md Use the Names function with a string pattern to retrieve symbols from the 'System' context. The example then filters these symbols to find those with the 'OneIdentity' attribute. ```mma >> sysnames = Names("System`*"); >> Select(sysnames, MemberQ(Attributes(#), OneIdentity) &) // InputForm {"And","Composition","Dot","GCD","Intersection","Join","Max","Min","Or","Plus","Power","StringExpression","StringJoin","TensorProduct","Times","Union","Xor"} ``` -------------------------------- ### Generate Points on Unit Circle Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/CirclePoints.md Use CirclePoints with a positive integer to get the specified number of points on the unit circle. For example, CirclePoints(4) returns four points. ```mathematica CirclePoints(i) ``` ```mathematica >> CirclePoints(4) {{1/Sqrt(2),-1/Sqrt(2)},{1/Sqrt(2),1/Sqrt(2)},{-1/Sqrt(2),1/Sqrt(2)},{-1/Sqrt(2),-1/Sqrt(2)}} ``` -------------------------------- ### LengthWhile Usage Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/LengthWhile.md Returns the number of elements at the start of a list for which a given predicate returns True. The predicate is applied using the '# < 10 &' syntax, meaning 'element less than 10'. ```mathematica >> LengthWhile({1, 2, 3, 10, 5, 8, 42, 11}, # < 10 &) 3 ``` -------------------------------- ### Example: SparseArray Initialization with Default Value Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/SparseArray.md Illustrates creating a SparseArray with explicit rules, dimensions, and a default value. The output confirms the number of elements, dimensions, and the specified default value. ```mathematica >> SparseArray({{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}, Automatic, 0) SparseArray(Number of elements: 4 Dimensions: {3,3} Default value: 0) ``` -------------------------------- ### Example: NestList with FromDigits Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FromDigits.md Illustrates a sequence generation using NestList, where each element is converted from base 8 to base 9. The output shows the first 50 iterations starting from 8. ```Symja >> NestList(FromDigits(IntegerDigits(#, 8), 9) &, 8, 50) {8,9,10,11,12,13,14,15,16,18,20,22,24,27,30,33,37,41,46,51,57,64,81,100,121,145,"181,221,275,345,433,541,761,1036,1471,2014,2787,3927,5533,8537,13555,21441,34102,60891,103386,185033,329032,651411,1286139,2551404,5654254} ``` -------------------------------- ### Example: Full Permutation List Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Ordering.md Demonstrates calculating the full permutation list for a given set of numbers. ```java >> Ordering({1,3,4,2,5,9,6}) {1,4,2,3,5,7,6} ``` -------------------------------- ### Example: FindMinimum of Sin(x) Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FindMinimum.md Demonstrates finding the minimum of the sine function for a single variable 'x' starting at 0.5. The output shows the minimum value and the corresponding variable assignment. ```mathematica >> FindMinimum(Sin(x), {x, 0.5}) {-1.0,{x->-1.5708}} ``` -------------------------------- ### SlotSequence Usage with Plus Function Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/SlotSequence.md Demonstrates how SlotSequence (##) is used to pass a sequence of arguments to the Plus function. The first example uses all arguments, while the second uses arguments starting from the second one. ```java >> Plus(##)& [1, 2, 3] 5 ``` ```java >> Plus(##2)& [1, 2, 3] 5 ``` -------------------------------- ### Example: FindMaximum of Sin(x) Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/FindMaximum.md Demonstrates finding the local maximum of the sine function for a univariate variable `x` starting at `0.5`. The output shows the maximum value and the corresponding variable assignment. ```mathematica FindMaximum(Sin(x), {x, 0.5}) ``` -------------------------------- ### Example: FindMaximum of a Multivariate Function with BOBYQA Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FindMaximum.md Demonstrates finding the maximum of a complex multivariate function with constraints using the 'BOBYQA' optimization method. The output includes the maximum value and the variable assignments at that point. ```mathematica >> FindMaximum({(1-x)^2+100*(y-x^2)^2, x >= -2.0 && 2.0 >= x && y >= -0.5 && 1.5 >= y}, {{x, -1.2}, {y,1.0}}, Method->"BOBYQA") {2034.0,{x->-2.0,y->-0.5}} ``` -------------------------------- ### Alternative Method for Getting Coefficients of a Variable Power Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Coefficient.md This provides an alternative syntax to the previous example, specifying the variable and its exponent separately. It yields the same result, returning a combined expression for all terms with x^5. ```mathematica >> Coefficient(poly, x, 5) 84*c^5*y^2-84*c^5*y*z+21*c^5*z^2 ``` -------------------------------- ### Load VectorAnalysis Package Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Get.md Example of loading the VectorAnalysis.m package from the file system. ```mathematica <<"VectorAnalysis.m" ``` -------------------------------- ### Example: Multivariate Optimization with BOBYQA Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/FindMaximum.md Finds the local maximum of a multivariate function with constraints using the 'BOBYQA' method. The function is `(1-x)^2+100*(y-x^2)^2`, with bounds on `x` and `y`, starting at `x=-1.2` and `y=1.0`. ```mathematica FindMaximum({(1-x)^2+100*(y-x^2)^2, x >= -2.0 && 2.0 >= x && y >= -0.5 && 1.5 >= y}, {{x, -1.2}, {y,1.0}}, Method->"BOBYQA") ``` -------------------------------- ### Load Package using << Syntax Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Get.md The << syntax provides an alternative way to load packages from the file system. Ensure a file system is accessible when using this method. ```mathematica <<"path-to-package-file-name" ``` ```mathematica <<"VectorAnalysis.m" ``` -------------------------------- ### Save Dependent Definitions to a Temporary File Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Save.md Saves a function definition along with its dependent symbols' definitions to a temporary file. This example demonstrates saving a function `f` which depends on `g`, then clearing them, and finally retrieving them using `Get`. ```mathematica >> g(x_) := x^3; >> g(x_,y_) := f(x,y); >> SetAttributes(f, Listable); >> f(x_) := g(x^2); >> temp = FileNameJoin({$TemporaryDirectory, "savedlist.txt"});Print(temp); >> Save(temp, {f,g}) >> ClearAll(f,g) >> "Attributes(f) >> {f(2),g(7)} >> Get(temp) >> {f(2),g(7)} {64,343} >> Attributes(f) {Listable} ``` -------------------------------- ### Save Dependent Definitions to Temporary File Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Save.md Saves a function definition along with its dependent symbols to a temporary file. The saved definitions can be retrieved later using Get. This example demonstrates saving and then clearing definitions, followed by retrieving them. ```mathematica >> g(x_) := x^3; >> g(x_,y_) := f(x,y); >> SetAttributes(f, Listable); >> f(x_) := g(x^2); >> temp = FileNameJoin({$TemporaryDirectory, "savedlist.txt"});Print(temp); >> Save(temp, {f,g}) >> ClearAll(f,g) >> "Attributes(f) >> {f(2),g(7)} >> Get(temp) >> {f(2),g(7)} {64,343} >> Attributes(f) {Listable} ``` -------------------------------- ### Implement DiagonalMatrix Builtin Function in Java Source: https://github.com/axkr/symja_android_library/wiki/EvalEngine Example of implementing a Symja builtin function like DiagonalMatrix by extending AbstractFunctionEvaluator. The `evaluate()` method handles the function's logic, `expectedArgSize()` defines argument constraints, and `setUp()` can configure symbol attributes. Return F.NIL to indicate unevaluated results. ```java private static class DiagonalMatrix extends AbstractFunctionEvaluator { @Override public IExpr evaluate(final IAST ast, EvalEngine engine) { ... ... // the return value F.NIL has the special meaning "return unevaluated": return F.NIL; } @Override public int[] expectedArgSize(IAST ast) { // this function allows one or two arguments return ARGS_1_2; } @Override public void setUp(final ISymbol newSymbol) { // if necessary set attributes here: // newSymbol.setAttributes(ISymbol.FLAT | ISymbol.ONEIDENTITY); } } ``` -------------------------------- ### Begin Function Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Begin.md Starts a new context definition by providing a context name. This function is useful for managing different scopes of definitions. ```APIDOC ## Begin ``` Begin("") ``` ### Description Starts a new context definition. ### Parameters #### Path Parameters - **""** (string) - Required - The name of the new context to define. ### Examples ``` >> Begin("mytest`") >> Context() mytest` >> $ContextPath {System`,Global`} >> End() mytest` >> Context() Global` >> $ContextPath {System`,Global`} ``` ``` -------------------------------- ### SlotSequence Starting from Nth Argument Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/SlotSequence.md Shows how to use SlotSequence to start from the n-th argument. '##2' indicates starting from the second argument. ```java >> Plus(##2)& [1, 2, 3] 5 ``` -------------------------------- ### StieltjesGamma Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/StieltjesGamma.md Examples demonstrating the usage of the StieltjesGamma function. ```mathematica >> StieltjesGamma(0) EulerGamma ``` ```mathematica >> StieltjesGamma(0,a) -PolyGamma(0,a) ``` -------------------------------- ### FullSimplify with Options Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/FullSimplify.md This demonstrates how to use FullSimplify with additional options to control the simplification process. Options like Assumptions and ComplexFunction can be used. ```mathematica FullSimplify(expr, option1, option2, ...) ``` -------------------------------- ### Symbolic Product with Factorial Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Product.md Shows how symbolic products can be simplified using factorial notation. ```java Product(k, {k, 3, n}) ``` -------------------------------- ### View All Contexts in InputForm Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Contexts.md This example demonstrates how to display all available contexts using the `InputForm` representation in Symja. It shows the typical output format for context listing. ```symja Contexts[] // InputForm ``` -------------------------------- ### Additional examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/D.md Various other examples demonstrating the D function's capabilities. ```APIDOC ## Additional examples ### Examples ``` >> D(2/3*Cos(x) - 1/3*x*Cos(x)*Sin(x) ^ 2,x)//Expand 1/3*x*Sin(x)^3-1/3*Sin(x)^2*Cos(x)-2/3*Sin(x)-2/3*x*Cos(x)^2*Sin(x) >> D(f(#1), {#1,2}) f''(#1) >> D((#1&)(t),{t,4}) 0 >> Attributes(f) = {HoldAll}; Apart(f''(x + x)) f''(2*x) >> Attributes(f) = {}; Apart(f''(x + x)) f''(2*x) >> D({#^2}, #) {2*#1} ``` ``` -------------------------------- ### Initial Expression Setup Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/Share.md Sets up an initial expression 'people' with nested rules, which will be used to demonstrate the Share function. ```mathematica >> people = <|236234 -> <|"name" -> "bob", "age" -> 18, "sex" -> "M"|>,253456 -> <|"name" -> "sue", "age" -> 25, "sex" -> "F"|>, 323442 -> <|"name" -> "ann", "age" -> 18, "sex" -> "F"|>|> <|236234-><|name->bob,age->20,sex->M|>,253456-><|name->sue,age->25,sex->F|>,323442-><|name->ann,age->18,sex->F|>|> ``` -------------------------------- ### Example: Fitting a Model and Accessing Properties Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/LinearModelFit.md Demonstrates fitting a linear model with multiple variables and accessing its properties like BestFit, ParameterErrors, and RSquared. ```mathematica >> nlm=LinearModelFit({{1, 1, 6.5}, {2, 1, 8.4}, {1, 2, 9.6}, {2, 2, 12.1}, {3, 2, 14.0}},{1, a, b, a*b},{a, b}) ``` ```mathematica >>nlm // Normal ``` ```mathematica >> nlm("BestFit") ``` ```mathematica >> nlm("BestFitParameters") ``` ```mathematica >> nlm("EstimatedVariance") ``` ```mathematica >> nlm("FitResiduals") ``` ```mathematica >> nlm("ParameterErrors" ``` ```mathematica >> nlm("RSquared") ``` -------------------------------- ### Asymptotic Integration of Sine Function Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/AsymptoticIntegrate.md Demonstrates the asymptotic integration of the sine function around x=0. This example shows how the function approximates the behavior of sin(x) near zero. ```java >> AsymptoticIntegrate(Sin(x), x, x -> 0) -1 ``` -------------------------------- ### DateString() - Example with Timestamp Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/DateString.md Example of using DateString with a Unix timestamp. ```APIDOC ## DateString(timestamp) ### Description Converts a Unix timestamp into a formatted date string. ### Method N/A (Function call) ### Parameters - **timestamp** (number) - Required - The Unix timestamp. ### Request Example ``` >> DateString(3155673600) Sat 01 Jan 2000 00:00:00 ``` ### Response Returns the date and time corresponding to the provided Unix timestamp, formatted as a string. ``` -------------------------------- ### PowerRange Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/PowerRange.md An example demonstrating the usage of the PowerRange function with symbolic expressions. ```APIDOC ### Example ``` >> PowerRange(1, x^10, Sqrt(x)) {1,Sqrt(x),x,x^(3/2),x^2,x^(5/2),x^3,x^(7/2),x^4,x^(9/2),x^5,x^(11/2),x^6,x^(13/2),x^7,x^(15/2),x^8,x^(17/2),x^9,x^(19/2),x^10} ``` ``` -------------------------------- ### Example: FourierDSTMatrix with DST-1 Method Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/FourierDSTMatrix.md Demonstrates the usage of FourierDSTMatrix with dimension 3 and method 1 (DST-1), showing the resulting matrix. ```mathematica >> FourierDSTMatrix(3, 1) {{1/2,1/Sqrt(2),1/2}, {1/Sqrt(2),0,-1/Sqrt(2)}, {1/2,-1/Sqrt(2),1/2}} ``` -------------------------------- ### ChineseRemainder Example 3 Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/ChineseRemainder.md Another example with large numbers and negative remainders. ```mathematica >> ChineseRemainder({-2,-17}, {284407855036305,47}) 9669867071234368 ``` -------------------------------- ### ChineseRemainder Example 2 Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/ChineseRemainder.md An example demonstrating the ChineseRemainder function with large numbers. ```mathematica >> ChineseRemainder({1,-15}, {284407855036305,47}) 8532235651089151 ``` -------------------------------- ### Calculate BesselK Example Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/BesselK.md Example of calculating the BesselK function for a specific input. ```mathematica >> BesselK(1, 3.6) 0.019795 ``` -------------------------------- ### Array examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Array.md Demonstrates various ways to use the Array function for creating lists and matrices with different dimensions and origins. ```mathematica >> Array(f, 4) {f(1),f(2),f(3),f(4)} ``` ```mathematica >> Array(f, {2, 3}) {{f(1,1),f(1,2),f(1,3)},{f(2,1),f(2,2),f(2,3)}} ``` ```mathematica >> Array(f, {2, 3}, {4, 6}) {{f(4,6),f(4,7),f(4,8)},{f(5,6),f(5,7),f(5,8)}} ``` ```mathematica >> Array(f, 4) {f(1), f(2), f(3), f(4)} ``` ```mathematica >> Array(f, {2, 3}) {{f(1, 1), f(1, 2), f(1, 3)}, {f(2, 1), f(2, 2), f(2, 3)}} ``` ```mathematica >> Array(f, {2, 3}, 3) {{f(3, 3), f(3, 4), f(3, 5)}, {f(4, 3), f(4, 4), f(4, 5)}} ``` ```mathematica >> Array(f, {2, 3}, {4, 6}) {{f(4,6),f(4,7),f(4,8)},{f(5,6),f(5,7),f(5,8)}} ``` -------------------------------- ### ArcTan Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/matheclipse-core/src/main/resources/doc/functions/ArcTan.md Examples demonstrating the usage of the ArcTan function with single and double arguments. ```mathematica >> ArcTan(1) Pi/4 ``` ```mathematica >> ArcTan(1.0) 0.7853981633974483 ``` ```mathematica >> ArcTan(-1.0) -0.7853981633974483 ``` ```mathematica >> ArcTan(1, 1) Pi/4 ``` ```mathematica >> ArcTan(-1, 1) 3/4*Pi ``` ```mathematica >> ArcTan(1, -1) -Pi/4 ``` ```mathematica >> ArcTan(-1, -1) -3/4*Pi ``` ```mathematica >> ArcTan(1, 0) 0 ``` ```mathematica >> ArcTan(-1, 0) Pi ``` ```mathematica >> ArcTan(0, 1) Pi/2 ``` ```mathematica >> ArcTan(0, -1) -Pi/2 ``` -------------------------------- ### Example: PolynomialGCD Calculation Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/PolynomialGCD.md This example demonstrates calculating the GCD of two specific polynomials. ```mathematica >> PolynomialGCD(x^2 + 7*x + 6, x^2-5*x-6) 1+x ``` -------------------------------- ### Example: Subdivide(5) Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Subdivide.md Demonstrates subdividing the default range [0, 1] into 5 intervals. ```mathematica >> Subdivide(5) {0,1/5,2/5,3/5,4/5,1} ``` -------------------------------- ### Erfc Function Examples Source: https://github.com/axkr/symja_android_library/blob/master/symja_android_library/doc/functions/Erfc.md Provides examples of calculating the Erfc function for specific values. ```plaintext >> Erfc(1.0) 0.15729920705028488 ``` ```plaintext >> Erfc(0) 1 ```