MATH1109 - CORE MATHEMATICS

3天干完6个月的活,Claude把模型搬上AMD 一条挺刺激的消息:Anthropic 给投资人的材料里有一张幻灯片,写着它的 Claude Mythos Preview 只花了大约​,就摸清了怎么让另一个 Claude 模型在 AMD 的 MI355X 上跑起来。同一处还写了个对照数字:过去给一块新芯片做推理适配,通常要几十名工程师、​。3 天对 6 个月,这个比值太扎眼,当天中文互联网上就冒出一堆「英伟达的护城河塌了」的说法。我把能翻到的材料都翻了一遍,越看越觉得,塌掉的那一小块是真的,可塌的位置和很多人想的不一样。 阅读详情

DEPARTMENT OF MATHEMATICAL SCIENCES

AUTUMN SEMESTER 2024-2025

MATH1109 - CORE MATHEMATICS

Python Coursework

Deadline: 15:00, Wednesday 27/11/2024

Rules

It is not permitted to use generative artificial intelligence (AI) software for this coursework. Ensure that you have read and have understood the Policy on academic misconduct. One of the things stated in this policy is that “The submission of work that is generated and/or improved by software that is not permitted for that assessment, for the purpose of gaining marks will be regarded as false authorship and seen as an attempt to gain an unpermitted academic advantage”.

You are allowed to work together and discuss in small groups (two to four MATH1109 students) but you must write all code by yourself with the exception that you may copy from material provided on the MATH1109 Moodle page.

You may ask for and receive help from the tutor Richard Rankin although not all questions will be answered and those that are will be answered to all students in the class.

Each student is to submit their own coursework.

You must submit one .py file for each question. A full submission contains three Python files:

• legendre.py,

• square_root.py,

• time_steppers.py.

You are strongly encouraged to use the Spyder IDE (integrated development environment).

Marks breakdown

This coursework is out of 100 marks:

• Q1 – 40 marks.

• Q2 – 30 marks.

• Q3 – 30 marks.

Guidelines

For full output data marks, your functions need to return the correct outputs for the particular input arguments.

For full plot marks, your plot(s) should have the correct data plotted, axis labels, a legend if appropriate, and a descriptive title. Note that you will not be penalised for not using TeX/LaTeX fonts.

You should comment your code as discussed in Appendix 3 of the Python Notes and all functions should have a docstring, see Chapter 7.6 of the Python Notes. Some marks will be assigned for commenting and docstrings.

Please be aware that we will test your functions with an automated marker to check that they work and produce the desired output(s), both with the data given in the templates and with different undisclosed data.

.py files that include template functions can be found in the same folder as this file on the MATH1109 Moodle page.

The template .py files also contain some simple tests of your functions. You are encouraged to write your own tests of your functions in a separate file.

If your modules have filenames that differ to what has been explicitly asked for, then your modules will not run through the automarker, and you risk scoring low output/plot marks.

The automated tests for all questions will be “timed out” if they take too long to run. All questions should only need at most a few seconds to run.

When setting up a figure inside a function, you should first use the following syntax before plotting anything:

fig = plt.figure()

fig can then be returned from the function as if it were any other variable.

Questions

1. The Legendre polynomials {Lu (x)}u≥0 are a set of polynomials that are orthogonal over the interval (−1, 1). This means that

The Legendre polynomials can be constructed using the recurrence relationship:

L0 (x) = 1,

L1 (x) = x,

nLu (x) = (2n − 1)xLu−1 (x) − (n − 1)Lu−2 (x),   for n ≥ 2.

Your task:

(a)  Complete the function found in legendre.py (available on Moodle) with prototype:

def  compute _ legendre (x,p)

• This function should compute the Legendre polynomials up to and including degree p at the points contained in x.

• This function should take as input:

– A one-dimensional numpy.ndarray x - the values at which to evaluate the Legendre polynomials;

– An int p - the maximum polynomial degree to evaluate;

• The function should output:

– A numpy.ndarray of shape (p+1,len(x)) - the evaluated Legendre polynomials.

Once you have written compute_legendre(), test it by running legendre.py. You should obtain the following:

Legendre  polynomials:

[[ 1. 1. 1. 1. 1. ]

[-1. -0.5 0. 0.5 1. ]

[ 1. -0.125 -0.5 -0.125 1. ]

[-1. 0.4375 -0. -0.4375 1. ]]

(b)  Complete the function found in legendre.py with prototype:

def  plot _ legendre (p)

• This function should plot the Legendre polynomials up to and including degree p over the interval [−1, 1] on a single set of axes.

• This function should take as input:

– An int p - the maximum polynomial degree to plot;

• The function should output:

– A matplotlib.figure .Figure - a handle to the plot created.

Once you have written plot_legendre(), test it by running legendre.py.

[40 marks]

2.  In this question, you will implement an algorithm to find an approximate square root of a > 0. The mathematical square root function has the following Taylor expansion about a point x2:

This motivates the following iteration

where N is some positive integer.

The iteration should begin with an initial guess  is considered sufficiently accurate when

for some give error tolerance ε .

Your task:

Complete the function found in square_root.py (available on Moodle) with the prototype:

def  approx _ square _root (a,N,x0 , eps)

• This function should apply (1) to find the approximate square root of a.

• This function should take as input:

– A float a - the value to be square rooted;

– An int N - to control how many terms in the Taylor expansion are used;

– A float eps - the tolerance at which to stop the iteration;

– A float x0 - the initial guess for the iteration.

• The function should output (in this order):

– A float - the (approximate) positive value of the square root of a;

– An int - the number of iterations required to obtain a sufficiently accurate approximation.

Once you have written approx_square_root(), test it by running square_root .py. You should obtain the following:

sqrt(25) = 5.0 , No_iterations = 4

sqrt(10) = 3.162277660168379 , No_iterations = 2

Note: Very tiny changes to these values are acceptable due to the way Python carries out floating point arithmetic.

[30 marks]

3.  Suppose we wish to solve the scalar initial value problem

A two-point method for approximating solutions to this problem has the time stepping formulae:

yu+2 = yu+1 + δt(3f(tu+1 , yu+1) − f(tu, yu))/2,   n = 0, … , N − 2                      (4)

where, δt = T/N and tu  = nδt, n = 0, … , N.

In order to findy2 , both y0 andy1 are required. y0  is available from the initial condition, but in general, y1 is not known. y1 can be simply provided, as in part (a), or calculated some other way, as in part (b).

Your task:

(a)  Complete the function found in time_steppers.py (available on Moodle) with the prototype:

def  perform _time _ stepping1 (T,N,y0 ,y1 , f)

• This function should use the method shown in (4) to approximately solve the IVP (2)-(3).

• This function should take as input:

– A float T - the final time T;

– An int N - the number of time-steps to perform;

– A float y0 - the initial value y0;

– A float y1 - the value to use for y1;

–  a function f - the function f(t, y).

• The function should output (in this order):

–  a numpy.ndarray - a vector containing all the time points {tn}Nn=0;

–  a numpy.ndarray - a vector containing all the approximations {yn}Nn=0.

Once you have written perform_time_stepping1() test it by running time_steppers .py. You should obtain the following: perform_time_stepping1:

tn  =    [0 .    0 .5  1 .    1 .5  2 .    2 .5  3 .    3 .5  4 .    4 .5  5 .  ]

yn  =     [1 .                  1 .23606798  1 .44647817  1 .6412379     1 .82300795  1 .99402943 2.15596995  2.31011529  2.45747855  2.59887356  2.73496507]

(b)  Complete the function found in time_steppers.py (available on Moodle) with the prototype: def  perform _time _ stepping2 (T,N,M,y0 , f)

• This function should use the method shown in (4) to approximately solve the IVP (2)-(3).

• To find a value for y1  ≈ y(δt), M steps of the forward Euler method should be used.

• This function should take as input:

– A float T - the final time T;

– An int N - the number of time-steps of (4) to perform;

– An int M - the number of time-steps of forward Euler to perform to findy1;

– A float y0 - the initial value y0;

–  a function f - the function f(t, y).

• The function should output (in this order):

–  a numpy.ndarray - a vector containing all the time points {tn}Nn=0;

–  a numpy.ndarray - a vector containing all the approximations {yn}Nn=0 .

Once you have written perform_time_stepping2() test it by running time_steppers .py. You should obtain the following:

perform_time_stepping2: 

tn  =    [0 .    0 .5  1 .    1 .5  2 .    2 .5  3 .    3 .5  4 .    4 .5  5 .  ]

yn  =     [1 .                  1 .23861555  1 .44864405  1 .64325985  1 .82490307  1 .99581873 2.15766904  2.31173637  2.45903135  2.60036596  2.73640354]

[30 marks]

【信息科学与工程学】【数据科学】数据科学领域——第三篇 数学08 几何学00总篇 编号英文名称中文名称简要说明/归属1Foundations of Geometry几何基础公理化方法, Hilbert《几何基础》2Euclidean Geometry (Synthetic)欧几里得几何(综合法)《几何原本》传统3Analytic Geometry解析几何坐标方法, Descartes, Fermat4Plane Geometry平面几何三角形、圆、共点共线等经典问题5Solid Geometry立体几何三维空间中的图形与度量6Non-Euclidean Geometry非欧几何平行公设不 阅读详情

相关推荐

如何处理动态语言(Python / JS)的“隐形”调用链?

本文揭示动态语言(Python/JS)中静态AST解析导致调用链“断链”的核心问题,提出通过运行时追踪补全图谱的解决方案。基于Code-Graph-RAG的cgr trace机制,分别利用pytest插件与V8 Profiler捕获真实调用路径,将动态边合并至静态图谱,并在权重体系中提升动态边优先级。实践表明,该方法可显著提升图谱覆盖率,实现“结构+行为”双视角理解代码,为MCP与Rerank系统提供可靠支持。

xianyinsuifeng的博客 425

MATH1109 - CORE MATHEMATICS AUTUMN SEMESTER 2024-2025Python

40 marks][30 marks]n}Nn=0n}Nn=0;n}Nn=0。

withyouand2的博客 859

Playwright: Pytest vs Library vs LibraryAsync:三者如何选?

Python中Playwright的3个Target:Pytest(推荐用于E2E自动化测试,支持报告、并行、重试)、Library(同步脚本,适合爬虫与简单任务,需手动管理浏览器)、LibraryAsync(异步脚本,适用于高并发批量操作)。选择依据:测试项目选Pytest,轻量脚本选Library,高并发场景选LibraryAsync。

SmallBull的博客 227

本地化部署 DeepSeek,构建单细胞与空间转录组 AI 分析平台

本地化部署 DeepSeek,构建单细胞与空间转录组 AI 分析平台

weixin_53637133的博客 187

MuJoCo 相机图片怎么拿?视角调整获取物体图片及实时显示(附代码)

在Mujoco的仿真中,对于识别抓取场景来说,如何获得添加的body等物体的实时图像很重要,今天就分享下如何添加相机视角及可视化小方块(举例)的实时图片。复制一个scene.xml为scene_withcamera.xml,在xml中添加camera和小方块如下。设置xml文件中添加的相机body id。需要创建一个离屏渲染器。

darcsdn 2128

安装Anaconda和Labelme的教程

1 登录Anaconda官网,选择Download https://www.anaconda.com/distribution/ 2 选择你想下载的Python版本,选择你的操作系统和位数,然后点击Download按钮就开始下载了 3 开始安装 下面两个框框都勾选 点击next,等待安装成功 打开Anaconda Navigator 点击红色圈圈的按钮 在cmd中输入 (1)创建虚拟环境 conda create -n labelme python=3.6 (2)激活虚拟环境 conda activa

qq_42178122的博客 3817

【第 009 讲】全面掌握 Python 注释:注释的定义与作用 | 单行注释 | 三引号与多行注释 | 注释使用的最佳实践

本文系统讲解 Python 注释的完整知识体系:从注释的定义与作用讲起,梳理单行注释的书写位置、临时屏蔽用法与 PEP 8 排版规范,剖析注释被忽略的底层机制;进而说明三引号字符串的本质与嵌套问题;最后给出注释使用的三条实践原则,帮助读者写好可读性高的注释。

大模型全栈工程师 · Thanks_ks 1159

关于42步进电机驱动——基于STM32 HAL库实现

我找了好多资料,好多关于42步进电机的都是文档,这么文档都需要积分,需要积分就算了内容还非常差,浪费时间和电脑的内存。关于大部分是基于Arduino和51去驱动的 42步进电机驱动硬件如下: 首先你要了解步进电机的驱动原理,我也不啰嗦了,请看这边博客: 二相四线,四相五线,四相六线步进电机接线及驱动方法 , 看完这篇你就知道驱动和接线的原理了。 起初我也为如何接线烦恼,因为有些博客在讲述这些问题的时候没有讲的很透彻。 方法如下: ①用万用表调到欧姆档,用其中一个表笔搭在一个引脚上,依次测其它.

Jodan132的博客 1万+

AI全栈实战 | 3.9-01 爬虫入门:requests 加 BeautifulSoup 三分钟跑通,但 90% 的人栽在这 4 个“礼貌“问题上

⚠️:本文内容仅用于。请遵守目标站点的服务条款与相关法律法规,不得对目标服务造成负担,不得采集、传播个人隐私数据。技术是中性的,边界在你手里。爬虫的入门技术(requests 发请求 + BeautifulSoup 解析)三分钟就能学会。真正区分"会用爬虫"和"会做爬虫的人"的,是这篇我们跑通"请求→解析→存储"的最小闭环,然后重点把"合规与礼貌"这根弦给你绷上。

源码获取 | 运行部署 | 定制二开修改,如果回复不及时请耐心等待,请见谅。 441

基于STM32L4XX 、HAL库的DRV8311三相无刷直流电机(BLDC)驱动应用C语言程序设计

是德州仪器(TI)推出的一款针对三相无刷直流(BLDC)电机或永磁同步电机(PMSM)的集成驱动器芯片。:集成了三个半桥MOSFET、门极驱动电路、电荷泵(支持100%占空比)、稳压器以及多种保护电路。:工作电压最高可达,持续输出电流可达,峰值电流可达。:通过引脚直接控制每个半桥的PWM和使能。这种方式需要MCU输出6路信号,控制更灵活。:通过SPI总线配置内部寄存器,仅需PWMA/B/C三路PWM信号即可控制电机。可以读取故障状态、配置参数(如死区时间、电流保护阈值等),是更常用和推荐的方式。

PP_Cottage的博客 560

深入理解JVM虚拟机第一篇:Java跨平台和字节码以及多语言混合编程

本位描述了Java的跨平台和JVM的跨平台的作用,Java语言的字节码的概念多语言混合编程应用到JVM虚拟机以及Java发展的重大事件。

七叔的博客 1万+

Python 的 yield from 到底转发了什么:拆开 send、throw 和那个 return 值

很多人把yield from记成「省一层 for 循环的语法糖」。写和写,结果看着一样,于是就当它只是少敲几个字。这个理解会在三个地方翻车:调用方.send()的值送不进去、子生成器return的值拿不到、异常和close()传不下去。yield from真正做的事是,外层生成器退成一个透明通道。本文所有输出来自本机 CPython 3.13.14 实测。yield from不是循环,是委托——nextsendthrowclose四个方向的流量全部直通子生成器,并且子生成器return。

小小张说故事的博客 163

【即插即用模块】Transformer篇 | MICCAI 2025 | ReLULA:Q/K双ReLU线性注意力,既轻又准!

本文介绍了一种基于线性注意力的多实例学习模块(Lin-MIL),适用于高分辨率视觉任务。该模块通过转置计算顺序和使用ReLU激活,将计算复杂度从O(n²d)降至O(nd²),同时提升特征判别性。核心创新包括Q/K双ReLU激活、可学习温度系数和数值稳定归一化。实验表明,该模块在轻量化视觉任务中优于传统线性注意力和Mamba架构。代码实现了模块化矩阵乘法,支持即插即用替换ViT自注意力层。该模块特别适合计算病理学等需要处理大量图像补丁的任务。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 140

从一段视频到可漫游的 4D 有声场景:思路拆解与最小复现手记

只需一段手机视频,你就能生成可"走进去"的 4D 有声场景:转头时狗叫声方向随之变化,走近时声音更清晰。本文拆解 Video-to-4DAVScene 的核心思路,手把手带你用几十行 Python 搭出最小管线,把视频中的运动物体变成带空间位置的声源,并附上三个真实踩坑的排障经验,代码可直接跑。🎧

helloagent的博客 246

uni-app - 最详细 H5 网页接入微信登录功能,提供公众号配置与详细注释示例代码(移动端网页实现点击登录按钮后 调用微信公众号授权登录功能 详细讲解接入流程与详细示例代码)官方最新超级详细教程

uniapp中H5微信登录,uniapp H5微信授权登录,微信公众号第三方网页(H5)授权登录(OAuth2.0)流程及逻辑详细教程,UNIAPP 开发H5 怎么实现微信公众号登录功能,uniapp如何实现H5网页的公众号微信登录,怎么做uniapp微信登录,uniapp h5项目怎么实现微信登录的功能,uniapp微信浏览器H5授权微信登录,UniApp开发H5接入微信登录的全过程,uniapp的H5页面使用微信登录,uniapp H5微信授权登录,H5之微信授权登陆 (uniapp网页版微信授权登录)

🏆 前端领域优质创作者 7410

软考「系统规划与管理师(第2版)」考后复盘|考试大纲深度解读

第2版大纲其实在定义一种新岗位:不是“会运维的人”,而是“能站在业务战略高度,规划信息系统、治理服务过程、驱动数字化转型的总设计师”。你读大纲,别只看到24章。基础篇给你世界观方法篇给你规划力能力篇给你管理力实践篇给你落地感格局决定分数,责任决定高度。先懂大纲要什么样的人,再决定自己怎么学。官方大纲以中国计算机技术职业资格网最新公布版本为准:https://www.ruankao.org.cn。

软件行业技术文化交流。 46

【每天一个 Python 小案例30】Python 基础知识综合小项目:我的工具盒

作为系列收官,本篇把前 29 篇的知识点合成一个能直接用的命令行工具"我的工具盒":计算器(用 ast 解析表达式,不碰 eval)、单位换算与温度转换(一张换算表 + 特例分支)、记账与分类统计(Decimal + JSON 持久化)、以及用"字典当命令表"把菜单和业务逻辑解耦的主循环。文中对比了 eval 的安全隐患与 ast 白名单的做法,解释了 lambda 闭包在字典里的写法与晚绑定陷阱,并在最后给出整个系列的知识地图,把变量、数据结构、控制流、函数、类、异常、文件、标准库八块内容对应到具体篇目。

xinjiyaya的博客 432

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

双路径优化+双容差校准

默认使用向量化路径处理常规数据,当检测到内存非连续或需要极致短路性能时,自动切换至 Numba JIT 路径。“当 CI 宽度中位数为 $W$ 时,实际判定容差为 $10^{-12} + 10^{-9} \times W$"针对表征谱算子 2 的实际输出量纲(例如 $10^{-3}$ 至 $10^3$),调整。准确标记了哪些数组被复制。非短路、静默拷贝风险、量纲耦合容差),本方案重构了核心逻辑。,并完善审计元数据以记录内存拷贝状态。, 确保在不同量纲下判定标准的一致性。,否则需排查上游数据生成逻辑。

2301_77211362的博客 202

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

yolo 和 deft 算法的区别

你应该是打错了:是,不是 defrat;

曾大强博客 274

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级 备考:莫队算法离线区间查询详解

备赛进行时:第十八届蓝桥杯软件赛报名已于 2026-10-08 10:00 开启、12-18 14:00 截止,省赛定在 2027-04-10(C/C++·Python 程序设计 9:00–13:00);中国电子学会 2026 年 12 月软件编程(C/C++ 一级至十级、Python 一级至六级)考级报名 9/23–12/2 16:00、统考 12-12;全国青少年信息素养大赛 2026—2027 赛季算法应用主题赛也已进入复盘练兵窗口。

IT_Scratch的博客 184

两张表合并之后,行数悄悄多了一倍

pandas merge 行数异常膨胀源于右表键不唯一,导致数据静默复制。实测显示,未聚合的右表(756行)与左表合并后行数增至504行,合计膨胀3.5倍,但无报错。validate 参数仅在检查键唯一性时有效,one_to_one 和 many_to_one 可拦截问题,但需结合 duplicated() 前置检查。正确做法为先按键聚合右表,再合并,避免重复。建议合并前后核对行数、合计,并使用 indicator=True 排查匹配情况,确保数据一致性。

patrickstar231的博客 251

我用 200 行代码写了个“代码屎山检测器“,扫完公司的老项目后我沉默了

这个工具不能帮你把屎山铲平,但至少能让你知道自己面对的是多大的山,也能在代码评审时用数据说话——“这个 PR 把圈复杂度从 12 推到了 18,能不能拆一下?毕竟,不能量化的东西,就没法改进。

xixiaoyunya的博客 272

智慧农业实战:育秧车间秧盘计数与苗情分级的Python实现

首先,建立统一的数据结构,保存每盘秧苗的编号、批次、覆盖度、叶色得分和播种天数。A = "壮苗"B = "合格苗"C = "弱苗"@dataclassdays: int。

荆棘鸟智能的博客 138

Java Arrays.asList 常见坑详解|UnsupportedOperationException、数组联动、基本类型 bug

解析 Arrays.asList 常见开发陷阱,演示 UnsupportedOperationException、底层数组引用共享、基本类型数组问题,区分 Arrays 内部 ArrayList 与 java.util.ArrayList,给出数组转 List 的各种场景正确代码。

weixin_42617033的博客 511

【每天一个 Python 小案例29】Python 实现商品购物车

本篇实现一个购物车:商品目录、加入商品、修改数量、移除商品、查看小计、计算满减与 VIP 折扣、结算扣库存。核心设计是"目录与购物车分离"——目录存商品主数据,购物车只存 {商品编号: 数量};金额一律用 Decimal 并做 ROUND_HALF_UP 舍入。折扣部分讲清阶梯满减的匹配顺序(阈值从高到低、命中即停)与叠加顺序(先满减、后打折),并用一次完整结算演示 706 元如何变成 613.70 元。

xinjiyaya的博客 219

Python的字典

Python字典是存储键值对的数据结构,通过键(key)快速查找对应的值(value)。可使用{}定义,支持增删改查操作:通过dict[key]查询或修改值,get()方法安全获取并设置默认值,del dict[key]删除键值对,keys()、values()和items()用于遍历。items()结合双变量循环可高效遍历所有键值对,提升代码可读性与灵活性。

qq_43010954的博客 199
上一篇: ACFIM0019 Financial Management
下一篇: EMATM0061: Statistical Computing and Empirical
wx____codinghelp
博客等级 码龄2年 771粉丝 115原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值