Hw2p3 - function[d1 d2 = Find the distance 1st and 2nd 3rd and 4th hw2p3 b/w the first to second root and third to fourth root root around 3pi/2

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
function [d1, d2] = hw2p3() % Find the distance b/w the first to second root and third to fourth root. % 1st and 2nd root: around 3pi/2 % 3rd and 4th root: around 7pi/2 % approximate the solution to the first two roots [zp zm] = z_star(3); % perform a few steps of newton % since |z[k+1] - z[k]| = |f(z[k])| and that z >> f(z), we use 1000 % iterations at every step to reduce the search time. y = f(3,zp); while abs(y) > 1e-24 zp = zp + gap1000(3, zp); y = f(3,zp); zm = zm - gap1000(3, zm); end d1 = zp+abs(zm); % f(zp) and f(zm) are small enough such that this approximation is % already good enough [zp zm] = z_star(7); d2 = zp+abs(zm); end function y = f(n, z) trig = sin(z)^2/(1+cos(z)); y = trig - erfc(n*pi/2+z); end function dz = gap1000(n,z) % since exp(-(3*pi/2+z)^2) ~ -sqrt(pi)/2, dy is ~= -1 for all z in % interval % dy = (2*exp(-(n*pi/2+z)^2))/sqrt(pi) - cos(z); % dz = y / dy; % process 1000 iterations in a single step since dy=-1 implies that the % function is about linear around this section. y = f(n,z);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/12/2012 for the course CS 3220 taught by Professor Marschner during the Spring '09 term at Cornell University (Engineering School).

Page1 / 2

Hw2p3 - function[d1 d2 = Find the distance 1st and 2nd 3rd and 4th hw2p3 b/w the first to second root and third to fourth root root around 3pi/2

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online