Informatics1-2017/Practice10
A MathWikiből
A lap korábbi változatát látod, amilyen Kkovacs (vitalap | szerkesztései) 2017. november 13., 04:53-kor történt szerkesztése után volt.
Tartalomjegyzék |
Using Sage
Sage server
If your browser finds the certificate untrustworthy, accept it manually!
Public
From home (if you want to install, optional)
http://doc.sagemath.org/html/en/installation/index.html
Command line
On leibniz write sage into a command prompt, this starts the sage interactive shell.
Most sage commands work here, for example:
23^19
Tasks
- Calculate the squareroot of 2017!
- Caltulate the 4th root of 2017!
- Calculate the 2017^6!
- What's the remaider of 123*321 divided by 11?
Text completion and help
Sage can complete your commands, try the following:
V = Vec[press TAB]
Sage completes the command to Vector, and offers additional options. Complete it to match the following:
V = VectorSpace(QQ,3)
This way V will be the 3 dimensional vector space over the rational field.
Now write V. and press TAB. Now we can see all the possible operations with V. Writing a questionmark at the end of a command gives a detailed description of the command. For example:
V.bases?
Try it:
V.bases()
Sage notebook
- Go to the sage notebook page: notebook
- Login with the username and password provided.
- Top right Settings change your password.
- After logging in again with the new password, you can open a new notebook with New Worksheet.
- Name it something like Practical10
Introduction
- You can write any sage command in the cells, even multiple ones, for example:
A = Matrix([[1, 1], [1, 0]]) B = Matrix([[-2, 0], [-1, 1]])
- Run the commands with SHIFT + ENTER. The commands run one after the other.
- Try writing just A or B in a cell and run it. Then try A*B.
Tasks
Using variables
- Legyen Y a születési éved, M a születési hónapod, és D a születésed napja, ezekhez vedd fel a három változót.
- Hányszor van meg D Y-ban? Legyen az érték a b változóhoz rendelve.
- Legyen r a születési évednek a hónappal vett maradéka.
- Mennyi most b és r különbsége?
Beépített Sage függvények, metódusok
- Prímszám-e 2011? (használd az is_prime() függvényt)
- Prímedik napján születtél-e a hónapnak? (használd a D változót!)
- Oldd meg a D*x^2 + M*x - b*r = 0 egyenletet a solve(fv, változó) függvény segítségével! (Ne felejtsd el bevezetni az x-et szimbolikus változóként!)
- Numerikusan is oldd meg az egyenletet! Használd a find_root(fv == 0, min, max) függvényt.
- Oldd meg a fenti egyenletet szimbolikusan is (fejezd ki x-et b, D, M és r-rel)!
- Deriváld le az sin(x)cos(x)x^2 függvényt.
- Integráld le az elõzõ függvényt.
- Számold ki a határértékét az (1 + 3/n)^4n függvénynek, ha n->oo
- Legyen f a következő függvény: f = (x+2*y)^3
- Helyettesíts be x helyére 3-at; utána x helyére 4-et és y helyére 2-t. Mennyi az eredmény? ( használd f-nek a subs() függvényét)
- Bontsd összeggé f-et! (expand())
- Az elõbb tanultakat használva, számold ki az 4. tagig a sin(x)cos(x)x^2 függvény Taylor-sorát (deriválni / integrálni, ha f egy függvény úgy is lehet, hogy f.diff(x))
Rajzolás a Sage segítségével (plot)
- Rajzolj egy cosinus-görbét 0-tól 4*pi -ig!
- Rajzold ki az (x-2)^2 + 3 másodfokú polinomot -2-től 4-ig, zöld színnel!
- Rajzold az előző mellé (a show függvénnyel) az x^3-3*x + 6 harmadfokú polinomot pirossal!
- Rajzoljunk kört: cirlce((középpont koordinátái), sugár, egyebek). Az "egyebek" lehetnek: szín, aspect_ratio=True hogy az x és y tengelyek skálázása azonos legyen (különben ellipszist kaphatunk!).