Informatics1-2019/Lab10

A MathWikiből
(Változatok közti eltérés)
a (Server)
23. sor: 23. sor:
 
## Use '''bool''' to convert to logical value
 
## Use '''bool''' to convert to logical value
 
## Is it true for real numbers? Positive numbers? ('''assume''')
 
## Is it true for real numbers? Positive numbers? ('''assume''')
# Prove '''(x-y)(x+y) == x^2-y^2'''
+
# Prove <math>(x-y)(x+y) = x^2-y^2</math>
# Prove '''(-1)^(2n) == 1''' where '''n''' is integer!
+
# Prove <math>(-1)^{2n} = 1</math> where '''n''' is integer!
  
 
=== Sage functions, methods ===
 
=== Sage functions, methods ===
30. sor: 30. sor:
 
# Is 2018 a prime? (use the ''is_prime()'' function)
 
# Is 2018 a prime? (use the ''is_prime()'' function)
 
# Were you born on a prime day? (use the D variable!)
 
# Were you born on a prime day? (use the D variable!)
# Solve the equation D*x^2 + M*x - b*r = 0  using the ''solve(fv, variable)'' function! (x needs to be a symbolic variable!)
+
# Solve the equation <math>Dx^2 + Mx - br = 0</math> using the ''solve(f, variable)'' function!
# Solve the equation numerically! Use the ''find_root(fv == 0, min, max)''  function, where min and max defines an interval where Sage looks for the solution.
+
#* ''x'' needs to be a symbolic variable!
 +
#* ''f'' can be a function, formula or an equation.
 +
# Solve the equation numerically! Use the ''find_root(f, min, max)''  function, where min and max defines an interval where Sage looks for the solution.
 +
#* this only works is you have one variable!
 
# Solve the above equation symbolically (make D, M, b, r symbolic variables, then use solve)!
 
# Solve the above equation symbolically (make D, M, b, r symbolic variables, then use solve)!
# Differentiate the function sin(x)cos(x)x^2.
+
# Differentiate the function <math>\sin(x)\cdot\cos(x)\cdotx^2</math>.
 
# Integrate the previous function.
 
# Integrate the previous function.
# Calculate the limit of (1 + 3/n)^4n, if n->oo
+
# Calculate the limit of <math>\lim_{n\to\infty}\right(1 + \frac3n\left)^{4n}</math>
# Let f be the following function: f = (x+2*y)^3
+
# Let f be the following function: f(x,y) = (x+2*y)^3
 
# Substitute 3 into x; then 4 into x and 2 into y. What's the result? ( use the ''subs()'' method of f)
 
# Substitute 3 into x; then 4 into x and 2 into y. What's the result? ( use the ''subs()'' method of f)
 
# Expand f! (''expand()'')
 
# Expand f! (''expand()'')
# Using the above, calculate the [https://en.wikipedia.org/wiki/Taylor_series Taylor series] of sin(x)cos(x)x^2 up until the 4th member. (you can differentiate and integrate a function '''f''' by '''f.diff(x)''')
+
# Using the above, calculate the [https://en.wikipedia.org/wiki/Taylor_series Taylor series] of <math>\sin(x)\cdot\cos(x)\cdotx^2</math> up until the 4th member. (you can differentiate and integrate a function '''f''' by '''f.diff(x)''')
  
 
=== Plotting with Sage (plot) ===
 
=== Plotting with Sage (plot) ===
  
 
# Plot a cosine curve from 0 to 4*pi!  
 
# Plot a cosine curve from 0 to 4*pi!  
# Plot the (x-2)^2 + 3 polynomial from -2 to 4, color it green!
+
# Plot the <math>(x-2)^2 + 3</math> polynomial from -2 to 4, color it green!
# Plot next to the previous one (using the ''show'' function) the function x^3-3*x + 6 in red!
+
# Plot next to the previous one (using the ''show'' function) the function <math>x^3-3*x + 6</math> in red!
 
# Plot a circle: ''cirlce((coordinates of the center), radius, optional)''. The "optional" can be: color, ''aspect_ratio=True'' so that the ratio of the x and y axis are kept, otherwise we might get an ellipse.
 
# Plot a circle: ''cirlce((coordinates of the center), radius, optional)''. The "optional" can be: color, ''aspect_ratio=True'' so that the ratio of the x and y axis are kept, otherwise we might get an ellipse.
  
 
[[Informatics1-2019/Lab09|Previous]] - [[Informatics1-2019#Labs|Up]] - [[Informatics1-2019/Lab11|Next]]
 
[[Informatics1-2019/Lab09|Previous]] - [[Informatics1-2019#Labs|Up]] - [[Informatics1-2019/Lab11|Next]]

A lap 2019. december 2., 15:24-kori változata

Previous - Up - Next

Tartalomjegyzék

Sage

Server

https://jupyter.math.bme.hu:8888/

You can log in with your leibniz username and password.

You can use this, or install it on your own from here: http://www.sagemath.org/

Tasks

Using variables

  1. Let Y be your year of birth, M the month, and D the day, create these variables.
  2. How much is Y divided by D? Associate this value with the b variable.
  3. Let r be the remainder of Y / M.
  4. What's the difference r - b?

Symbolic calculations

  1. Is it true that the square root of the square of a number is the number itself?
    1. Use bool to convert to logical value
    2. Is it true for real numbers? Positive numbers? (assume)
  2. Prove (xy)(x + y) = x2y2
  3. Prove ( − 1)2n = 1 where n is integer!

Sage functions, methods

  1. Is 2018 a prime? (use the is_prime() function)
  2. Were you born on a prime day? (use the D variable!)
  3. Solve the equation Dx2 + Mxbr = 0 using the solve(f, variable) function!
    • x needs to be a symbolic variable!
    • f can be a function, formula or an equation.
  4. Solve the equation numerically! Use the find_root(f, min, max) function, where min and max defines an interval where Sage looks for the solution.
    • this only works is you have one variable!
  5. Solve the above equation symbolically (make D, M, b, r symbolic variables, then use solve)!
  6. Differentiate the function Értelmezés sikertelen (ismeretlen függvény\cdotx): \sin(x)\cdot\cos(x)\cdotx^2

.

  1. Integrate the previous function.
  2. Calculate the limit of Értelmezés sikertelen (formai hiba): \lim_{n\to\infty}\right(1 + \frac3n\left)^{4n}
  1. Let f be the following function: f(x,y) = (x+2*y)^3
  2. Substitute 3 into x; then 4 into x and 2 into y. What's the result? ( use the subs() method of f)
  3. Expand f! (expand())
  4. Using the above, calculate the Taylor series of Értelmezés sikertelen (ismeretlen függvény\cdotx): \sin(x)\cdot\cos(x)\cdotx^2
up until the 4th member. (you can differentiate and integrate a function f by f.diff(x))

Plotting with Sage (plot)

  1. Plot a cosine curve from 0 to 4*pi!
  2. Plot the (x − 2)2 + 3 polynomial from -2 to 4, color it green!
  3. Plot next to the previous one (using the show function) the function x3 − 3 * x + 6 in red!
  4. Plot a circle: cirlce((coordinates of the center), radius, optional). The "optional" can be: color, aspect_ratio=True so that the ratio of the x and y axis are kept, otherwise we might get an ellipse.

Previous - Up - Next

Személyes eszközök