Numerical Analysis Lab1 V1
Short Description
Lab 1...
Description
Numerical Analysis Fall 2014 Problem 1: Implement the function xex − f (x) = x xe +
1 x2 1 x2
Try to evaluate this function for x=10, 100, 1000. Please explain the result. Find a way to increase accuracy of the evaluation. Problem 2: Implement the following procedure Let c=0.1 for x from 1 to 15 2x r = 10(1+ 10 ) − 10(1+2xc) display r end do Please explain obtained results. Problem 3: Compute the integral Ik = that
R 1 −x k e x dx 0
for k=0,1,2. Using integration by parts show
Ik = kIk−1 − e−1 I0 = 1 − e−1 Using your favorite programming system compute Ik for k=0,1,2,3,. . .,25. Do you notice anything wrong with your answers? To analyze this suppose that the only error is in I0 : Ib0 = I0 + . Then if all calculations are exact, what is the error in Ik ? What error do you expect if = u, where u is the unit of roundoff ? Problem 4: On October 14, 2010 Benout B. Mandelbrot, a famous mathematician have died. Mandelbrot is known as the inventor of fractals and this problem is dedicated to him. In this problem you will generate the so-called quadratic Julia Sets, a well-known fractal example. Given two complex numbers, c and z0 , the following recursion is defined 2 zn = zn−1 +c
For an arbitrary given choice of c and z0 , this recursion leads to a sequence of complex numbers z1 , z2 , z3 . . . called the orbit of z0 . Depending on the exact choice of c and z0 , a large range of orbit patterns are possible. For a given fixed c, most choices of z0 yield orbits that tend towards infinity. (That is, |zn | → ∞ as n → ∞). For some values of certain choices of z0 yield orbits that eventually will go into a periodic loop. Finally, some starting values yield orbits that appear to dance around 1
the complex plane, apparently at random (an example of chaos).These initial values of z0 make up the Julia set of this recurrsion, denoted by Jc . Write a script that visualizes a slightly different set, called the filled-in Julia set denoted by Kc , which is the set of all z0 with orbits which do not tend towards infinity. The ”normal” Julia set Jc is the edge of the filled-in Julia set. The figure below illustrates a filled-in Julia Set for one particular value of c. a) It has been shown that if |zn | > 2 for some n then it is guaranteed that the orbit will tend to infinity. The value of n for which this becomes true is called the escape velocity of a particular z0 . Write a function that returns the escape velocity of a given z0 and c. The function declaration should be: n = EscV el(z0 , c, N ), where N is the maximum allowed escape velocity (i.e. if |zn | ≤ 2 for n < N , return N as the escape velocity, so you will prevent infinite loops). b) To generate the filled-in Julia Set, write the following function M = JuliaSet(zM ax , c, N ) where zM ax will be the maximum of the real and imaginary parts of the various of z0 for which we will compute esape velocities, c and N are the same as defined above, and M is the matrix that contains the escape velocity of various z0 . 1. In this function, you first want to make a 500 × 500 matrix that contains complex numbers with real part between −zM ax and zM ax , and imaginary part between −zM ax and zM ax. Call this matrix Z. Make the imaginary part vary along the y-axis of this matrix. You can most easily do this by using linspace and meshgrid commands, but you can also do it with a loop. 2. For each element of Z, compute the escape velocity (by calling your EscVel function) and store it in the same location in a matrix M . When done, the matrix M should be the same size as Z and contain escape velocities with values between 1 and N. 3. Run your JuliaSet function with various zM ax , c, and N values to generate various fractals. To display the fractal nicely, use imagesc command to visualize arctan(0.1 ∗ M ), (taking the arctangent of M makes the image look nicer, you also can use axisxy command so that y values arent flipped). Below are some examples of figures obtained using different values of c: M = JuliaSet(1, −0.297491 + i ∗ 0.641051, 100) and M = JuliaSet(1, −0.491 + 0.74 ∗ i, 100) Bonus Point: Use methods provided by your environment to find the hotspot. Evaluate overall programming complexity (Big O notation) of your implementation. Provide some experimental evidence that complexity was computed correctly.
2
Figure 1: Plot of JuliaSet(1,-0.297491+i*0.641051,100)
Figure 2: Plot of JuliaSet(1,-0.491 + 0.74*i,100)
3
View more...
Comments