Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

This repository contains the course materials from Math 157: Intro to Mathematical Software.

Creative Commons BY-SA 4.0 license.

Views: 3037
License: OTHER

This file is a Sage worksheet. It behaves similarly to a Jupyter worksheet, in that it is divided into cells that can be individually executed by typing Shift-Enter. One difference is that it is possible to specify a different programming language for each cell, as illustrated by this worksheet. See the homework notebook 2018-01-19.ipynb for additional instructions.

Here is an example of arrays in Octave, an open-source system which emulates the syntax of MATLAB. We will compare linear-algebra functionality between MATLAB and Sage later.

%octave a = [1,2,3]; b = a; b(1) = 5; a b
a = 1 2 3 b = 5 2 3

Here is an example of arrays in R, an open-source system for statistics which we will study later.

%r a <- c(1,2,3); b <- a; b[1] = 5; a b
  1. 1
  2. 2
  3. 3
  1. 5
  2. 2
  3. 3

Here is an example of arrays in Javascript (for comparison only; we will not study this language further).

%javascript a = [1,2,3]; b = a; b[0] = 5; print("a =",a) print("b =",b)

Here is an example of arrays in Julia, a new language for scientific computing which we will study later.

%julia a = [1,2,3]; b = a; b[1] = 5; println("a =", a, "\nb =", b);
a =[5, 2, 3] b =[5, 2, 3]