医疗保健计算机编程代写 HIM3002代写 Healthcare代写
568HIM3002: Computer Programming for Healthcare Lab Assignment 1: Basic Programming (10%) 医疗保健计算机编程代写 Background In Lecture 1 to Lecture 4, we learned the python programming skills t...
View detailsSearch the whole station
数值分析编程代写 Problem 1. Write a Python function: roots = findroots(p, a, b) whose arguments are: p: a list or ndarray of double-precision floating point numbers
roots = findroots(p, a, b)
whose arguments are:
and which computes all real roots of p(x) on the interval [a, b]. The function should return a list of the real roots in increasing order : if p has k roots xisuch that a ≤ x1 ≤ x2 ≤ · · · ≤ xk ≤ b, then roots[i] (1 <= i <= k) gives the value of xi. If there are no roots, then f returns an empty list (i.e. len(roots) == 0).
To implement this function, one idea is to use Sturm’s theorem recursively combined with a 1D rootfinder (see this page for more details about how to apply Sturm’s theorem—we will also discuss it in class). For this problem, you are free to use the scipy function brentq.
Test your function as you develop it—namely, use polyroots to check the whether the roots you compute are correct!
An algebraic surface (click through to see pictures of many examples) is defined as the locus of points which satisfies:
p(x, y, z) = 0, (x, y, z) ∈ R3, (1)
where p is a multivariable polynomial. Goursat’s surface is a quartic algebraic surface defined by (1) where:
p(x, y, z) = x4 + y4 + z4 + a(x2 + y2 + z2)2 + b(x2 + y2 + z2 ) + c = 0, (2)
for some choice of the parameters a, b, c ∈ R.
Using findroots, we will use raytracing to render an image of Goursat’s surface. We pick a point r0 = (x0, y0, z0), a unit ray direction d = (dx, dy, dz), and define the ray:
r(t) = r0 + td = (x0 + tdx, y0 + tdy, z0 + tdz), t ≥ 0. (3)
We then find the values of t for which (1) holds:
p(r(t)) = 0, t ≥ 0. (4)
Note that the composition of a multivariate polynomial with a single variable polynomial is just a single variable polynomial. This means that we can use findroots to solve (4).
In our simplified raytracing, we will set up a grid of rays, one for each pixel in an image, solve (4) using findroots to find the first intersection along the ray, and color each pixel using a simple Lambertian model of reflectance:
Cij= cos(αij)C. (5)
We will represent the image as an m × n × 3 ndarray, where img[i, j, :] gives the RGB values for the (i, j)th pixel. So, we use the same direction vector d for each pixel, but must vary the initial ray position so that we get a different parallel ray for each pixel. See this image. After creating the image, use plt.imsave to save it to disk.
Note that to use findroots to solve (4), we need to write p(r(t)) as a polynomial in t. This is tricky to do automatically using numpy, but you are welcome to try. Two other options: use sympy, or write down the polynomial by hand and then implement it as a new Python function (e.g., p of r(t, r, d, a, b, c)—note the dependence on the parameters).
更多代写:DATABASE代写 proctoru review作弊 英国psychology网课代修 essay conclusion怎么写 ethical approval怎么写 英文report怎么写
合作平台:essay代写 论文代写 写手招聘 英国留学生代写
HIM3002: Computer Programming for Healthcare Lab Assignment 1: Basic Programming (10%) 医疗保健计算机编程代写 Background In Lecture 1 to Lecture 4, we learned the python programming skills t...
View detailspython代写哪里找的价位便宜?代写Python的通过率高不高? python代写 随着人们生活水平的提高,人们的精神追求也在逐步的提高。对于出国留学都有了新的认识有了很高的思想觉悟,不再有人认为出国留学就是有钱...
View detailsPython2 Python算法代写 测试数据 工单数量自由设定,先设定为 20 机器数量自由设定,先设定为 6,编号为[1 2 3 4 5 6] 工人数量自由设定,先设定为 2,编号为[1 2] PTq[5 10 15 20 25 5 10 15 20 25 5 10 15 20 2...
View detailsCSCI 3022 Final Exam CS考试代考 Read the following: • RIGHT NOW! Write your name, student ID and section number on the top of your exam. If you’re handwriting your exam, Read the fol...
View details