{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Homework #3\n", "### Assignment\n", "1. Define a function euclidean_distance that computes the distance between two 1D vectors of size n according to the formula:\n", "\n", "$$\n", "d(a,b) = \\sqrt{\\sum_{i=1}^n{(a_i - b_i)^2}}\n", "$$\n", "\n", "The function should check that the vector have the same size and implement the simplest iterative version and the two methods proposed within this lecture, selectable by an additional parameter mode of the function.\n", "\n", "Test the function with pairs of randomly generated vectors of size [5, 10, 20, 50] and measure its performance with the %timeit magic.\n", "\n", "2. Solve the following linear equations system, in the form $Ax = b$, using numpy functions described in the present lecture:\n", "\n", "$$\n", "4x + 3y + 2z = 25 \\\\\n", "-2x + 2y + 3z = -10 \\\\\n", "3x -5y + 2z = -4\n", "$$\n", "\n", "### Add below your solution to questions 1 & 2 " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Object `at` not found.\n" ] } ], "source": [ "?at" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" } }, "nbformat": 4, "nbformat_minor": 4 }