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

https://sage.math.bme.hu/

If your browser finds the certificate untrustworthy, accept it manually!

Public

SageMathCloud

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

  1. Calculate the squareroot of 2017!
  2. Caltulate the 4th root of 2017!
  3. Calculate the 2017^6!
  4. 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

  1. 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.
  2. Hányszor van meg D Y-ban? Legyen az érték a b változóhoz rendelve.
  3. Legyen r a születési évednek a hónappal vett maradéka.
  4. Mennyi most b és r különbsége?

Beépített Sage függvények, metódusok

  1. Prímszám-e 2011? (használd az is_prime() függvényt)
  2. Prímedik napján születtél-e a hónapnak? (használd a D változót!)
  3. 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!)
  4. Numerikusan is oldd meg az egyenletet! Használd a find_root(fv == 0, min, max) függvényt.
  5. Oldd meg a fenti egyenletet szimbolikusan is (fejezd ki x-et b, D, M és r-rel)!
  6. Deriváld le az sin(x)cos(x)x^2 függvényt.
  7. Integráld le az elõzõ függvényt.
  8. Számold ki a határértékét az (1 + 3/n)^4n függvénynek, ha n->oo
  9. Legyen f a következő függvény: f = (x+2*y)^3
  10. 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)
  11. Bontsd összeggé f-et! (expand())
  12. 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)

  1. Rajzolj egy cosinus-görbét 0-tól 4*pi -ig!
  2. Rajzold ki az (x-2)^2 + 3 másodfokú polinomot -2-től 4-ig, zöld színnel!
  3. Rajzold az előző mellé (a show függvénnyel) az x^3-3*x + 6 harmadfokú polinomot pirossal!
  4. 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!).

Polinomgyûrûk és vektorterek

Személyes eszközök