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
Kernel: SageMath 8.1

Math 157: Intro to Mathematical Software

UC San Diego, winter 2018

Homework 2: due January 26, 2018

Please enter all answers within this notebook unless otherwise specified. As usual, don't forget to cite sources and collaborators.

Problem 1: Comparison of relevant software

Grading criterion: correctness. Remember to cite all sources!

1a. Specify whether each of the following computer algebra systems fits the Open Source Initiative definition of an "open-source" project (https://opensource.org/definition). If not, identify a criterion which fails to be met.

  • GAP

  • Geogebra

  • Magma

  • Maple

  • Mathematica

  • MATLAB

  • Pari/GP

  • Sage

  • Sympy

1b. For each of the following projects, give a one-sentence description of the project, and indicate in what year and by what person/organization the first version was released.

  • Cython

  • Julia

  • MacSyma / Maxima (treat as one project)

  • Numpy

  • Pandas

  • Python

  • R

  • Sage

  • Scipy

  • TeX / LaTeX (treat as one project)

Problem 2: Under the hood

Grading criterion: correctness.

For each of the following Sage commands, identify one external component of Sage which is used to execute that command, and indicate how you did so. (Hint: in addition to the Sage documentation, inspecting docstrings or even source code may be helpful.)

factor(10^30-13)
plot(lambda x: sin(x), 0, 2*pi)
G = AlternatingGroup(4) G.subgroups()
var('x,y,z') f = (x+y)/z f.derivative(z)
-(x + y)/z^2
z.derivative??
1
R.<x,y,z> = PolynomialRing(QQ) factor(x^3+y^3+z^3-3*x*y*z)

Problem 3: Mersenne primes

Grading criteria: correctness of explanation and code.

3a. A Mersenne prime is a prime number of the form 2p12^p-1 where pp is itself prime. (Note that these are the only possible primes of the form 2n12^n-1 where nn is a positive integer). They are called this because Marin Mersenne was the first person to attempt to list these primes systematically: he claimed that for p257p \leq 257, 2p12^p-1 is prime if and only if p{2,3,5,7,13,17,19,31,67,127,257}.p \in \{2, 3, 5, 7, 13, 17, 19, 31, 67, 127, 257\}. This list turns out to be incorrect; write Sage code to compute the correct list.

# your code goes here

3b. On January 3, 2018, the Great Internet Mersenne Prime Search announced that 27723291712^{77232917}-1 is the "50th known Mersenne prime." Why didn't they announce that it is the "50th Mersenne prime"?

3c. The little Fermat theorem states that if pp is prime, then 2p11(modp)2^{p-1} \equiv 1 \pmod{p}. This can be used as a test for primality (the Fermat test) which has no false negatives, but does have some false positives (see part (d)).

Explain why the following code cannot be used to apply the Fermat test to the number p=2217011p = 2^{21701}-1, then give an alternate approach that does work.

p = 2^21701 - 1 print(2^(p-1) % p) # This won't work.

(your explanation goes here)

# your better code goes here

3d. Find all integers up to 1000 which are false positives for the Fermat test. These include Carmichael numbers, in case you want to read more about this phenomenon.

# your code goes here

Problem 4: Defining and evaluating a function

Grading criteria: correctness of code.

4a. Define in Sage the symbolic function (not a Python function) f(x)=sinh(x2x1)+eπx+arcsin(x)+1x3xef(x) = \sinh(x^2-x-1) + e^{\pi x} + \arcsin(x) + \frac{1}{x^3-x-e}.

4b. Compute f(1/2)f(1/2) exactly (i.e., your answer should be a symbolic expression).

4c. Compute f(1/2)f(1/2) numerically (i.e., your answer should be a decimal expansion).

4d. Plot f(x)f(x) from 1-1 to 11.

Problem 5: Numerical root-finding

Grading criteria: correctness (of code) and thoroughness (of explanation).

5a. Plot the function f(x)=x2+sin(x)f(x) = \displaystyle x^2 + \sin(x) on the interval [2,2][-2,2].

5b. Use Sage to compute the derivative and antiderivative of ff.

5c. Find numerical approximations to all of the zeros of f(x)f(x).

5d. In as much detail as you can, justify mathematically why your list in (c) is complete. Your explanation may include additional Sage code if necessary.

Problem 6: Taylor series

Grading criteria: correctness.

6a. Define the function f(x)=sin(x2)f(x) = \sin(x^2). Find the degree 3 Taylor series p3p_3 of ff about x0=2πx_0 = 2\pi.

6b. Make a single Sage plot on the interval x=[π,3π]x=[\pi, 3\pi] showing both f(x)f(x) and its degree 10 Taylor series p10p_{10} about x0=2πx_0 = 2\pi.