Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python matplotlib Interference occurs when two (or more) waves originating from different positions meet each other, their relative phase depending on the position where they

Python matplotlib

image text in transcribed

Interference occurs when two (or more) waves originating from different positions meet each other, their relative phase depending on the position where they meet. In this exercise, you will display two grayscale maps of the interference of two waves originating from point sources: one displaying the height of the sum of the waves, and the other displaying the square of the sum (thereby distinguishing crests from nodes). Define two linspaces (x and y) and use the following lambda function. def source (dist): Takes a single float: dist (x-displacement of source) Outputs a function that takes two values (x, y) - can be int, float, array- and outputs a float or array containing wave heights depending on (x, y) SC - lambda x, y: np.cos (np.sqrt ((x - dist) ** 2 + y ** 2)) return sc How do we get an array containing our function values out of source? Add two sources together, located in different places (dist). Store the sum in a variable A. (Make sure that the type of A is an array!) Store the square of this sum in another variable B. Create a figure with two subplots. Plot A and B as heat maps. To find out how to do this, look at the matplotlib documentation for imshow. To get a good image, you may need to change the limits of your linspaces, place the sources closer or further apart. Play around with it until you get a nice image. Name the subplots. Interference occurs when two (or more) waves originating from different positions meet each other, their relative phase depending on the position where they meet. In this exercise, you will display two grayscale maps of the interference of two waves originating from point sources: one displaying the height of the sum of the waves, and the other displaying the square of the sum (thereby distinguishing crests from nodes). Define two linspaces (x and y) and use the following lambda function. def source (dist): Takes a single float: dist (x-displacement of source) Outputs a function that takes two values (x, y) - can be int, float, array- and outputs a float or array containing wave heights depending on (x, y) SC - lambda x, y: np.cos (np.sqrt ((x - dist) ** 2 + y ** 2)) return sc How do we get an array containing our function values out of source? Add two sources together, located in different places (dist). Store the sum in a variable A. (Make sure that the type of A is an array!) Store the square of this sum in another variable B. Create a figure with two subplots. Plot A and B as heat maps. To find out how to do this, look at the matplotlib documentation for imshow. To get a good image, you may need to change the limits of your linspaces, place the sources closer or further apart. Play around with it until you get a nice image. Name the subplots

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago