This is the command ginsh that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

**PROGRAM:**

**NAME**

ginsh - GiNaC Interactive Shell

**SYNPOSIS**

**ginsh**[

__file...__]

**DESCRIPTION**

**ginsh**is an interactive frontend for the GiNaC symbolic computation framework. It is

intended as a tool for testing and experimenting with GiNaC's features, not as a

replacement for traditional interactive computer algebra systems. Although it can do many

things these traditional systems can do, ginsh provides no programming constructs like

loops or conditional expressions. If you need this functionality you are advised to write

your program in C++, using the "native" GiNaC class framework.

**USAGE**

**INPUT**

**FORMAT**

After startup, ginsh displays a prompt ("> ") signifying that it is ready to accept your

input. Acceptable input are numeric or symbolic expressions consisting of numbers (e.g.

**42**,

**2/3**or

**0.17**), symbols (e.g.

**x**or

**result**), mathematical operators like

**+**and

*****, and

functions (e.g.

**sin**or

**normal**). Every input expression must be terminated with either a

semicolon (

**;**) or a colon (

**:**). If terminated with a semicolon, ginsh will evaluate the

expression and print the result to stdout. If terminated with a colon, ginsh will only

evaluate the expression but not print the result. It is possible to enter multiple

expressions on one line. Whitespace (spaces, tabs, newlines) can be applied freely between

tokens. To quit ginsh, enter

**quit**or

**exit**, or type an EOF (Ctrl-D) at the prompt.

**COMMENTS**

Anything following a double slash (

**//**) up to the end of the line, and all lines starting

with a hash mark (

**#**) are treated as a comment and ignored.

**NUMBERS**

ginsh accepts numbers in the usual decimal notations. This includes arbitrary precision

integers and rationals as well as floating point numbers in standard or scientific

notation (e.g.

**1.2E6**). The general rule is that if a number contains a decimal point

(

**.**), it is an (inexact) floating point number; otherwise it is an (exact) integer or

rational. Integers can be specified in binary, octal, hexadecimal or arbitrary (2-36)

base by prefixing them with

**#b**,

**#o**,

**#x**, or

**#**

__n__

**R**, respectively.

**SYMBOLS**

Symbols are made up of a string of alphanumeric characters and the underscore (

**_**), with

the first character being non-numeric. E.g.

**a**and

**mu_1**are acceptable symbol names, while

**2pi**is not. It is possible to use symbols with the same names as functions (e.g.

**sin**);

ginsh is able to distinguish between the two.

Symbols can be assigned values by entering

__symbol__

**=**

__expression__

**;**

To unassign the value of an assigned symbol, type

**unassign('**

__symbol__

**');**

Assigned symbols are automatically evaluated (= replaced by their assigned value) when

they are used. To refer to the unevaluated symbol, put single quotes (

**'**) around the name,

as demonstrated for the "unassign" command above.

Symbols are considered to be in the complex domain by default, i.e. they are treated as if

they stand in for complex numbers. This behavior can be changed by using the keywords

**real_symbols**and

**complex_symbols**and affects all newly created symbols.

The following symbols are pre-defined constants that cannot be assigned a value by the

user:

**Pi**Archimedes' Constant

**Catalan**Catalan's Constant

**Euler**Euler-Mascheroni Constant

**I**sqrt(-1)

**FAIL**an object of the GiNaC "fail" class

There is also the special

**Digits**

symbol that controls the numeric precision of calculations with inexact numbers.

Assigning an integer value to digits will change the precision to the given number of

decimal places.

**WILDCARDS**

The has(), find(), match() and subs() functions accept wildcards as placeholders for

expressions. These have the syntax

**$**

__number__

for example $0, $1 etc.

**LAST**

**PRINTED**

**EXPRESSIONS**

ginsh provides the three special symbols

%, %% and %%%

that refer to the last, second last, and third last printed expression, respectively.

These are handy if you want to use the results of previous computations in a new

expression.

**OPERATORS**

ginsh provides the following operators, listed in falling order of precedence:

**!**postfix factorial

**^**powering

**+**unary plus

**-**unary minus

*****multiplication

**/**division

**+**addition

**-**subtraction

**<**less than

**>**greater than

**<=**less or equal

**>=**greater or equal

**==**equal

**!=**not equal

**=**symbol assignment

All binary operators are left-associative, with the exception of

**^**and

**=**which are right-

associative. The result of the assignment operator (

**=**) is its right-hand side, so it's

possible to assign multiple symbols in one expression (e.g.

**a**

**=**

**b**

**=**

**c**

**=**

**2;**).

**LISTS**

Lists are used by the

**subs**and

**lsolve**functions. A list consists of an opening curly brace

(

**{**), a (possibly empty) comma-separated sequence of expressions, and a closing curly brace

(

**}**).

**MATRICES**

A matrix consists of an opening square bracket (

**[**), a non-empty comma-separated sequence

of matrix rows, and a closing square bracket (

**]**). Each matrix row consists of an opening

square bracket (

**[**), a non-empty comma-separated sequence of expressions, and a closing

square bracket (

**]**). If the rows of a matrix are not of the same length, the width of the

matrix becomes that of the longest row and shorter rows are filled up at the end with

elements of value zero.

**FUNCTIONS**

A function call in ginsh has the form

__name__

**(**

__arguments__

**)**

where

__arguments__is a comma-separated sequence of expressions. ginsh provides a couple of

built-in functions and also "imports" all symbolic functions defined by GiNaC and

additional libraries. There is no way to define your own functions other than linking

ginsh against a library that defines symbolic GiNaC functions.

ginsh provides Tab-completion on function names: if you type the first part of a function

name, hitting Tab will complete the name if possible. If the part you typed is not unique,

hitting Tab again will display a list of matching functions. Hitting Tab twice at the

prompt will display the list of all available functions.

A list of the built-in functions follows. They nearly all work as the respective GiNaC

methods of the same name, so I will not describe them in detail here. Please refer to the

GiNaC documentation.

**charpoly(**

__matrix__

**,**

__symbol__

**)**- characteristic polynomial of a matrix

**coeff(**

__expression__

**,**

__object__

**,**

__number__

**)**- extracts coefficient of object^number from a

polynomial

**collect(**

__expression__

**,**

__object-or-list__

**)**- collects coefficients of like powers (result

in recursive form)

**collect_distributed(**

__expression__

**,**

__list__

**)**- collects coefficients of like powers

(result in distributed form)

**collect_common_factors(**

__expression__

**)**- collects common factors from the terms of sums

**conjugate(**

__expression__

**)**- complex conjugation

**content(**

__expression__

**,**

__symbol__

**)**- content part of a polynomial

**decomp_rational(**

__expression__

**,**

__symbol__

**)**- decompose rational function into polynomial

and proper rational function

**degree(**

__expression__

**,**

__object__

**)**- degree of a polynomial

**denom(**

__expression__

**)**- denominator of a rational function

**determinant(**

__matrix__

**)**- determinant of a matrix

**diag(**

__expression...__

**)**- constructs diagonal matrix

**diff(**

__expression__

**,**

__symbol__

__[__

**,**

__number]__

**)**- partial differentiation

**divide(**

__expression__

**,**

__expression__

**)**- exact polynomial division

**eval(**

__expression__

__[__

**,**

__level]__

**)**- evaluates an expression, replacing symbols by their

assigned value

**evalf(**

__expression__

__[__

**,**

__level]__

**)**- evaluates an expression to a floating point number

**evalm(**

__expression__

**)**- evaluates sums, products and integer powers of matrices

**expand(**

__expression__

**)**- expands an expression

**factor(**

__expression__

**)**- factorizes an expression (univariate)

**find(**

__expression__

**,**

__pattern__

**)**- returns a list of all occurrences of a pattern in an

expression

**fsolve(**

__expression__

**,**

__symbol__

**,**

__number__

**,**

__number__

**)**- numerically find root of a real-valued

function within an interval

**gcd(**

__expression__

**,**

__expression__

**)**- greatest common divisor

**has(**

__expression__

**,**

__pattern__

**)**- returns "1" if the first expression contains the pattern

as a subexpression, "0" otherwise

**integer_content(**

__expression__

**)**- integer content of a polynomial

**inverse(**

__matrix__

**)**- inverse of a matrix

**is(**

__relation__

**)**- returns "1" if the relation is true, "0" otherwise (false or

undecided)

**lcm(**

__expression__

**,**

__expression__

**)**- least common multiple

**lcoeff(**

__expression__

**,**

__object__

**)**- leading coefficient of a polynomial

**ldegree(**

__expression__

**,**

__object__

**)**- low degree of a polynomial

**lsolve(**

__equation-list__

**,**

__symbol-list__

**)**- solve system of linear equations

**map(**

__expression__

**,**

__pattern__

**)**- apply function to each operand; the function to be

applied is specified as a pattern with the "$0" wildcard standing for the operands

**match(**

__expression__

**,**

__pattern__

**)**- check whether expression matches a pattern; returns a

list of wildcard substitutions or "FAIL" if there is no match

**nops(**

__expression__

**)**- number of operands in expression

**normal(**

__expression__

__[__

**,**

__level]__

**)**- rational function normalization

**numer(**

__expression__

**)**- numerator of a rational function

**numer_denom(**

__expression__

**)**- numerator and denumerator of a rational function as a

list

**op(**

__expression__

**,**

__number__

**)**- extract operand from expression

**power(**

__expr1__

**,**

__expr2__

**)**- exponentiation (equivalent to writing expr1^expr2)

**prem(**

__expression__

**,**

__expression__

**,**

__symbol__

**)**- pseudo-remainder of polynomials

**primpart(**

__expression__

**,**

__symbol__

**)**- primitive part of a polynomial

**quo(**

__expression__

**,**

__expression__

**,**

__symbol__

**)**- quotient of polynomials

**rank(**

__matrix__

**)**- rank of a matrix

**rem(**

__expression__

**,**

__expression__

**,**

__symbol__

**)**- remainder of polynomials

**resultant(**

__expression__

**,**

__expression__

**,**

__symbol__

**)**- resultant of two polynomials with

respect to symbol s

**series(**

__expression__

**,**

__relation-or-symbol__

**,**

__order__

**)**- series expansion

**sprem(**

__expression__

**,**

__expression__

**,**

__symbol__

**)**- sparse pseudo-remainder of polynomials

**sqrfree(**

__expression__

__[__

**,**

__symbol-list]__

**)**- square-free factorization of a polynomial

**sqrt(**

__expression__

**)**- square root

**subs(**

__expression__

**,**

__relation-or-list__

**)**

**subs(**

__expression__

**,**

__look-for-list__

**,**

__replace-by-list__

**)**- substitute subexpressions (you

may use wildcards)

**tcoeff(**

__expression__

**,**

__object__

**)**- trailing coefficient of a polynomial

**time(**

__expression__

**)**- returns the time in seconds needed to evaluate the given

expression

**trace(**

__matrix__

**)**- trace of a matrix

**transpose(**

__matrix__

**)**- transpose of a matrix

**unassign(**

__'symbol'__

**)**- unassign an assigned symbol (mind the quotes, please!)

**unit(**

__expression__

**,**

__symbol__

**)**- unit part of a polynomial

**SPECIAL**

**COMMANDS**

To exit ginsh, enter

**quit**

or

**exit**

ginsh can display a (short) help for a given topic (mostly about functions and operators)

by entering

**?**

__topic__

Typing

**??**

will display a list of available help topics.

The command

**print(**

__expression__

**);**

will print a dump of GiNaC's internal representation for the given

__expression__. This is

useful for debugging and for learning about GiNaC internals.

The command

**print_latex(**

__expression__

**);**

prints a LaTeX representation of the given

__expression__.

The command

**print_csrc(**

__expression__

**);**

prints the given

__expression__in a way that can be used in a C or C++ program.

The command

**iprint(**

__expression__

**);**

prints the given

__expression__(which must evaluate to an integer) in decimal, octal, and

hexadecimal representations.

Finally, the shell escape

**!**[

__command__[

__arguments__]]

passes the given

__command__and optionally

__arguments__to the shell for execution. With this

method, you can execute shell commands from within ginsh without having to quit.

**EXAMPLES**

> a = x^2-x-2;

-2-x+x^2

> b = (x+1)^2;

(x+1)^2

> s = a/b;

(x+1)^(-2)*(-2-x+x^2)

> diff(s, x);

(2*x-1)*(x+1)^(-2)-2*(x+1)^(-3)*(-x+x^2-2)

> normal(s);

(x-2)*(x+1)^(-1)

> x = 3^50;

717897987691852588770249

> s;

717897987691852588770247/717897987691852588770250

> Digits = 40;

40

> evalf(s);

0.999999999999999999999995821133292704384960990679

> unassign('x');

x

> s;

(x+1)^(-2)*(-x+x^2-2)

> series(sin(x),x==0,6);

1*x+(-1/6)*x^3+1/120*x^5+Order(x^6)

> lsolve({3*x+5*y == 7}, {x, y});

{x==-5/3*y+7/3,y==y}

> lsolve({3*x+5*y == 7, -2*x+10*y == -5}, {x, y});

{x==19/8,y==-1/40}

> M = [ [a, b], [c, d] ];

[[-x+x^2-2,(x+1)^2],[c,d]]

> determinant(M);

-2*d-2*x*c-x^2*c-x*d+x^2*d-c

> collect(%, x);

(-d-2*c)*x+(d-c)*x^2-2*d-c

> solve quantum field theory;

parse error at quantum

> quit

**DIAGNOSTICS**

parse error at

__foo__

You entered something which ginsh was unable to parse. Please check the syntax of

your input and try again.

argument

__num__to

__function__must be a

__type__

The argument number

__num__to the given

__function__must be of a certain type (e.g. a

symbol, or a list). The first argument has number 0, the second argument number 1,

etc.

Use ginsh online using onworks.net services