## MATH36031 Problem solving by computer

Project 1 – deadline 27th October 2023, time 1100hrs. Submission of the project is via Blackboard.
In the tasks required for this project you are asked to use an algorithm which originates from the Vedic system of mathematics developed in India several hundred years ago. The algorithm is described in the video clip which is available via Blackboard in the Projects folder.

Write a function myrandi $(\mathrm{n})$ which takes as input a positive integer $\mathrm{n}$ and generates as output a string $a_1, a_2, \ldots, a_n$ containing the digits of a positive number $a_1 a_2 \ldots a_n$. Here the $a_k$ are random integers $0 \leq a_k \leq 9$.

Watch the video clip to learn about the algorithm used to multiply two numbers. In the video clip, the algorithm is described for multiplication of numbers up to 5 digits long. Your task is to generalise the algorithm to work out the patterns to multiply two $n$ digit numbers. In your report you should describe and explain how this algorithm works.

Write a function vedicmultiply to implement this algorithm and such that $\mathrm{c}=$ vedicmultiply $(\mathrm{a}, \mathrm{b})$ returns a string $\mathrm{c}$ which contains all the digits of the multiplication of $\mathrm{a}$ and $\mathrm{b}$ (which are input as a string). Also the integers represented by $a$ and $b$ can have a different number of digits. In your report you should explain and provide details of any testing and validation that you have done.

#### Example c=vedicmultiply (’12’, ’34’) returns c=’ 408 ‘.

function [nyans] - vedicmultiply (a,b)
\%vedicmultiply computes the product a+b
\% vedcimultiply computes the product of the numbers $a+b$ where
$\mathrm{X}$ a and $\mathrm{b}$ are input $8 \mathrm{~s}$ strings (to allow for long integers)
usage: a='12345'; b-'123' c=vedicmultiply (a,b)
myans is a list containing all the digits of the ansuer

Use your myrandi and vedicmultiply functions to give all the digits in the multiplication of two randomly-chosen random positive numbers $\mathrm{a}$ and $\mathrm{b}$ where $\mathrm{a}$ is of length 30 and $\mathrm{b}$ is of length 40 . The full output (showing all the digits) should be given in your report.

Produce a clearly labelled plot showing $N$, the number of digits in the integer along the $x$-axis versus $T$ the average time to do 100 multiplications using two positive random integers each with $N$ digits, on the $y$-axis. Ideally take $N=10: 10: 50$.

# MMath Mathematics / Course details

• Year of entry: 2023

## Overview

TODO: Content for Overview

## Entry requirements

TODO: Content for Entry requirements

## Application and selection

TODO: Content for Application and selection

## Course details

TODO: Content for Course details

## Careers

TODO: Content for Careers

## Course description

This flexible single-honours undergraduate Masters degree programme offers you the widest choice of options, ideal if you are mathematically gifted and wish to keep your options open. You get good all-round mathematical knowledge together with the ability to experience more specialised results, methods, and ideas. You can choose courses from other disciplines and from a huge variety of mathematics options allowing you to graduate with finely-honed skills in your own chosen areas. You get an education in sufficient depth in these specialised areas to enable you to undertake postgraduate studies, conduct mathematical research or work as a specialist mathematician in industry, business, or higher education.

• All coding must be done in MATLAB and you are required to submit your MATLAB functions and $\mathrm{m}$ (or $\mathrm{mlx}$ )-files via the Blackboard submission box. Project reports in pdf form only should be submitted via the Turnitin submission box. Remember the Turnitin software will automatically scan reports for plagiarism.
• Please ask if you need help on any commands, or whether there are built-in command$\mathrm{s} /$ functions to accomplish certain tasks (especially important if you think you have a good approach to the questions, but do not know the related commands).