Szimbolikus programcsomagok, sage, 1. óra
File: /sagenb/sage_install/sage-4.7.2/local/lib/python2.6/site-packages/sage/calculus/functional.py
Type: <type ‘function’>
Definition: derivative(f, *args, **kwds)
Docstring:
The derivative of f.
Repeated differentiation is supported by the syntax given in the examples below.
ALIAS: diff
EXAMPLES: We differentiate a callable symbolic function:
sage: f(x,y) = x*y + sin(x^2) + e^(-x) sage: f (x, y) |--> x*y + e^(-x) + sin(x^2) sage: derivative(f, x) (x, y) |--> 2*x*cos(x^2) + y - e^(-x) sage: derivative(f, y) (x, y) |--> xWe differentiate a polynomial:
sage: t = polygen(QQ, 't') sage: f = (1-t)^5; f -t^5 + 5*t^4 - 10*t^3 + 10*t^2 - 5*t + 1 sage: derivative(f) -5*t^4 + 20*t^3 - 30*t^2 + 20*t - 5 sage: derivative(f, t) -5*t^4 + 20*t^3 - 30*t^2 + 20*t - 5 sage: derivative(f, t, t) -20*t^3 + 60*t^2 - 60*t + 20 sage: derivative(f, t, 2) -20*t^3 + 60*t^2 - 60*t + 20 sage: derivative(f, 2) -20*t^3 + 60*t^2 - 60*t + 20We differentiate a symbolic expression:
sage: var('a x') (a, x) sage: f = exp(sin(a - x^2))/x sage: derivative(f, x) -2*e^(sin(-x^2 + a))*cos(-x^2 + a) - e^(sin(-x^2 + a))/x^2 sage: derivative(f, a) e^(sin(-x^2 + a))*cos(-x^2 + a)/xSyntax for repeated differentiation:
sage: R.<u, v> = PolynomialRing(QQ) sage: f = u^4*v^5 sage: derivative(f, u) 4*u^3*v^5 sage: f.derivative(u) # can always use method notation too 4*u^3*v^5sage: derivative(f, u, u) 12*u^2*v^5 sage: derivative(f, u, u, u) 24*u*v^5 sage: derivative(f, u, 3) 24*u*v^5sage: derivative(f, u, v) 20*u^3*v^4 sage: derivative(f, u, 2, v) 60*u^2*v^4 sage: derivative(f, u, v, 2) 80*u^3*v^3 sage: derivative(f, [u, v, v]) 80*u^3*v^3
File: /sagenb/sage_install/sage-4.7.2/devel/sage/sage/misc/misc_c.pyx
Type: <type 'builtin_function_or_method'>
Definition: prod(x, z=None, recursion_cutoff=5)
Docstring:
Return the product of the elements in the list x. If optional argument z is not given, start the product with the first element of the list, otherwise use z. The empty product is the int 1 if z is not specified, and is z if given. This assumes that your multiplication is associative; we don't promise which end of the list we start at. EXAMPLES: sage: prod([1,2,34]) 68 sage: prod([2,3], 5) 30 sage: prod((1,2,3), 5) 30 sage: F = factor(-2006); F -1 * 2 * 17 * 59 sage: prod(F) -2006 AUTHORS: Joel B. Mohler (2007-10-03 -- Reimplemented in Cython and optimized) Robert Bradshaw (2007-10-26) -- Balanced product tree, other optimizations, (lazy) generator support Robert Bradshaw (2008-03-26) -- Balanced product tree for generators and iterators
File: /sagenb/sage_install/sage-4.7.2/local/lib/python2.6/site-packages/sage/rings/arith.py
Type: <type ‘function’>
Definition: is_prime(n)
Docstring:
Returns True if n is prime, and False otherwise.
AUTHORS:
- Kevin Stueve kstueve@uw.edu (2010-01-17): delegated calculation to n.is_prime()
INPUT:
- n - the object for which to determine primality
OUTPUT:
- bool - True or False
EXAMPLES:
sage: is_prime(389) True sage: is_prime(2000) False sage: is_prime(2) True sage: is_prime(-1) False sage: factor(-6) -1 * 2 * 3 sage: is_prime(1) False sage: is_prime(-2) FalseALGORITHM:
Calculation is delegated to the n.is_prime() method, or in special cases (e.g., Python int``s) to ``Integer(n).is_prime(). If an n.is_prime() method is not available, it otherwise raises a TypeError.