Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 740
License: APACHE

SageMath Worksheets in CoCalc

This is an interactive document for running calculation online.

  • First, notice the additional button bar below the project specific bar. The "Play" button is for evaluating a block.

  • Each block of consecutive lines can either be input of code which is run by the interpreter or some text formatted via markdown.

  • A block is evaluated by placing the cursor into it and either clicking on the "Play" button or by simultaneously pressing the Shift+Return keys.

  • New blocks are inserted at the bottom or when clicking on the delimiter line inbetween two blocks.

  • The first line of each input block signals the type of cell: e.g. %md for markdown, %r for R, %python3 for Python3 or %sage for SageMath.

  • For the evaluation the default mode is usually set to SageMath, but it can be customized by running %default_mode <mode>.

  • On the left side of each block there is a small triangle. It hides or reveals input and output blocks. This can also be accomplished by placing the cursor inside a block and clicking on the "out" toggle button in the menu.

Let's start with a simple calculation:

2873648273648 * 293847293849723847

Here, we define two symbolic variables in Sage

x, y = var('x, y')

Build a symbolic expression z=x1+y2z = \frac{x}{1 + y^2}

z = x / (1 + y^2) show(z)

... and evaluate it at x=4x=4 and y=2y=2

z(x = 4, y = 2)

... define a function "f(x)"

f(x) = 2 * x + cos(x)

... evaluate it at 4π4 \pi

f(4 * pi)

... and plot it for x[10,10]x \in \left[-10, \, 10\right]

plot(f, (x, -10, 10))

Task: where is f(x)=0f(x) = 0 ?

Unfold the next input block to see the answer!

Next, let's go back to first-steps.tasks