Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168754
Image: ubuntu2004
class fibonacci(list): "Fibonacci" def __init__(self,n): list.__init__(self,range(1,n+1)) self[1]=1 for each in range(2,n): self[each]=self[each-1]+self[each-2] def __repr__(self): return "Fibonacci numbers" def show(self,n): return int((((1.0+sqrt(5.0))/2.0)**n-((1.0-sqrt(5.0))/2.0)**n)/sqrt(5.0))
x=fibonacci(10)#建立实体时,自动执行--init--方法 len(x)
10
x#实体直接运行时自动执行--init--方法
Fibonacci numbers
list(x)
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
x.show(11)
89
2**8+123456*23
2839744
exp?

File: /usr/local/sage2/local/lib/python2.6/site-packages/sage/functions/log.py

Type: <class ‘sage.functions.log.Function_exp’>

Definition: exp(x, coerce=True, hold=False, prec=None, dont_call_method_on_arg=False)

Docstring:

The exponential function, \exp(x) = e^x.

EXAMPLES:

sage: exp(-1)
e^(-1)
sage: exp(2)
e^2
sage: exp(2).n(100)
7.3890560989306502272304274606
sage: exp(x^2 + log(x))
e^(x^2 + log(x))
sage: exp(x^2 + log(x)).simplify()
x*e^(x^2)
sage: exp(2.5)
12.1824939607035
sage: exp(float(2.5))
12.182493960703473
sage: exp(RDF('2.5'))
12.1824939607
sage: exp(pi*I/2)
I
sage: exp(pi*I)
-1
sage: exp(8*pi*I)
1
sage: exp(7*pi*I/2)
-I

TEST:

sage: latex(exp(x))
e^{x}
sage: latex(exp(sqrt(x)))
e^{\sqrt{x}}
sage: latex(exp)
\exp
sage: latex(exp(sqrt(x))^x)
\left(e^{\sqrt{x}}\right)^{x}
sage: latex(exp(sqrt(x)^x))
e^{\left(\sqrt{x}^{x}\right)}

Test simplifications when taking powers of exp, #7264:

sage: var('a,b,c,I')
(a, b, c, I)
sage: model_exp = exp(I)**a*(b)
sage: sol1_l={b: 5.0, a: 1.1}
sage: model_exp.subs(sol1_l)
5.00000000000000*(e^I)^1.10000000000000
sage: exp(3)^I*exp(x)
(e^3)^I*e^x
sage: exp(x)*exp(x)
e^(2*x)
sage: exp(x)*exp(a)
e^(a + x)
sage: exp(x)*exp(a)^2
e^(2*a + x)

Another instance of the same problem, #7394:

sage: 2*sqrt(e)
2*sqrt(e)
exp(1/(0.1^2))
2.68811714181610e43
x=y=z=234
x
234
y
234
z
234
x=22;y=234 x,y=y,x
x
234
y
22
load DATA+'z.sage' x
101
attach DATA+'z.sage'
x
101
load z.sage x
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_25.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("bG9hZCB6LnNhZ2UKeA=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmp2M7DOL/___code___.py", line 2, in <module> sage.misc.preparser.load(sage.misc.preparser.base64.b64decode("ei5zYWdl"),globals(),False) File "/usr/local/sage2/local/lib/python2.6/site-packages/sage/misc/preparser.py", line 1503, in load exec(preparse_file(open(filename).read()), globals) IOError: [Errno 2] No such file or directory: 'z.sage'