diff options
author | Purusharth Saxena | 2020-07-20 02:36:27 +0530 |
---|---|---|
committer | GitHub | 2020-07-20 02:36:27 +0530 |
commit | 4160a2aed5007c2e803c02aff8f8fee7321f13c2 (patch) | |
tree | 2c05c2e06e9178e097a1b305f186f8d5d766bbc7 | |
parent | 922a203b47db680a8be8f002b0c73807cac53dd7 (diff) | |
parent | 1cddd7b803966ec1adb7043d65bf4964994543c7 (diff) | |
download | FSF-mathematics-python-code-archive-4160a2aed5007c2e803c02aff8f8fee7321f13c2.tar.gz FSF-mathematics-python-code-archive-4160a2aed5007c2e803c02aff8f8fee7321f13c2.tar.bz2 FSF-mathematics-python-code-archive-4160a2aed5007c2e803c02aff8f8fee7321f13c2.zip |
Merge pull request #76 from vnb09/fsf_tasks
Updated Lagrange Multipliers animations
11 files changed, 140 insertions, 51 deletions
diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/README.md b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/README.md index 05ff51d..903eaed 100644 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/README.md +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/README.md @@ -1,20 +1,26 @@ <h1><div align=”center”><b>SubTopic: Lagrange Multipliers</b></h1></div> <br/></br> -<tab>file1_Extrema_over_g(x,y)=k +<tab>file1_Extrema_over_g(x,y) + +![file1_Extrema_over_g(x,y)](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x%2Cy)%3Dk.gif?raw=true) +<br/></br> +<br/></br> -![file1_Extrema_over_g(x,y)=k](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x%2Cy)%3Dk.gif?raw=true) +<tab>file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3 + +![file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x%5E2%2By%5E2%2Bx%5E3-y%5E3.gif?raw=true) <br/></br> <br/></br> -<tab>file2_Geometric_Proof +<tab>file3_Geometric_Proof -![file2_Geometric_Proof](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.gif?raw=true) +![file3_Geometric_Proof](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.gif?raw=true) <br/></br> <br/></br> -<tab>file3_Constraints_g_and_h +<tab>file4_Constraints_g_and_h -![file3_Constraints_g_and_h](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Constraints_g_and_h.gif?raw=true) +![file4_Constraints_g_and_h](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.gif?raw=true) <br/></br> <br/></br> diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.gif Binary files differindex d423943..9a9042f 100644 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.gif +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.py index a01efb0..b7adcc7 100644 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.py +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.py @@ -4,10 +4,10 @@ import math as m #---- optimizing funtion f(x,y) w.r.t to g(x,y) class ConstrainedExtrema(ThreeDScene): def construct(self): - axes = ThreeDAxes().fade(0.4) - label_x = TextMobject("$x$").shift([5.5,-0.5,0]) #---- x axis - label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5) #---- y axis - + axes = ThreeDAxes().scale(0.7).rotate(math.radians(180)) + label_x = TextMobject("$x$").shift(4*LEFT).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift(3.2*DOWN+0.2*RIGHT).rotate(math.radians(180)).fade(0.4) #---- y axis + surface = ParametricSurface( lambda u, v: np.array([ u, diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.gif Binary files differnew file mode 100644 index 0000000..d8e03fd --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.py new file mode 100644 index 0000000..bbbf238 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.py @@ -0,0 +1,72 @@ +from manimlib.imports import* +import math as m + +#---- contour plot of the surface with constraint circle +class ContourScene(ThreeDScene): + def construct(self): + axes = ThreeDAxes().scale(0.7).rotate(m.radians(180)).fade(0.6) + label_x = TextMobject("$x$").shift(4*LEFT).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift(3.2*DOWN+0.2*RIGHT).rotate(m.radians(180)).fade(0.4) #---- y axis + + #---- surface of the function f(x,y) = x^2+y^2+x^3-y^3 + surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + u**2+v**2+u**3-v**3 + ]),u_min=-0.5,u_max=0.5, v_min=-0.5,v_max=0.5).scale(5).shift([0,-0.5,2.5]).set_color(TEAL).fade(0.5) + + + #---- contour plots of the surface of the function + + c0 = Circle(color = '#800000').scale(0.5).shift([0,-0.5,0]) + c1 = Circle(color = '#800000').scale(1).shift([0,-0.5,0]) + c2 = Circle(color = '#800000').scale(1.5).shift([0,-0.5,0]) + c3 = Circle(color = '#800000').scale(2).shift([0,-0.5,0]) + c4 = Circle(color = '#800000').scale(2.5).shift([0,-0.5,0]) + + #---- constraint circle + circle = Circle(color='#FF00FF',fill_opacity=0.3).shift([-0.5,-1.2,1.5]).rotate(1.9,UP).scale(0.8) + circle2 = Circle(color='#FF00FF',fill_opacity=0.3).shift([0.74,0.95,1.5]).rotate(1.9,UP).scale(0.8) + + maxima = Dot(color = '#4169E1').shift([0.7,0.15,1.5]) #---- point of maxima + minima = Dot(color = '#4169E1').shift([0.8,1.7,1.5]) #---- point of minima + + min_text = TextMobject("minimum over $g(x,y)=k$",color = '#FFA074').scale(0.6).shift([-2,0.16,1.5]) + max_text = TextMobject("maximum over $g(x,y)=k$",color = '#FFA074').shift([-2.3,-2.6,1.5]).scale(0.6).shift(0.5*UP) + + + #---- labelling contour curves + label_c0 = TextMobject("1",color = '#FFA074').shift([0.2,0.1,0.5]).scale(0.5) + label_c1 = TextMobject("2",color = '#FFA074').shift([0.2,-0.6,0.5]).scale(0.5) + label_c2 = TextMobject("3",color = '#FFA074').shift([0.2,-1.1,0.5]).scale(0.5) + label_c3 = TextMobject("4",color = '#FFA074').shift([0.2,-1.6,0.5]).scale(0.5) + label_c4 = TextMobject("5",color = '#FFA074').shift([0.2,-2.1,0.5]).scale(0.5) + + + self.set_camera_orientation(phi=75 * DEGREES, theta = 45*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.wait(1) + self.play(Write(surface)) + self.play(Write(circle)) + self.wait(1) + self.play(FadeOut(circle)) + self.wait(1) + self.move_camera(phi=0 * DEGREES, theta = 90*DEGREES) + self.wait(1) + self.play(Write(c0),Write(c1),Write(c2),Write(c3),Write(c4)) + self.play(FadeOut(surface)) + self.add_fixed_in_frame_mobjects(label_c0) + self.add_fixed_in_frame_mobjects(label_c1) + self.add_fixed_in_frame_mobjects(label_c2) + self.add_fixed_in_frame_mobjects(label_c3) + self.add_fixed_in_frame_mobjects(label_c4) + self.wait(1) + self.play(Write(circle2)) + self.wait(1) + self.play(Write(minima),Write(maxima)) + self.add_fixed_in_frame_mobjects(max_text) + self.add_fixed_in_frame_mobjects(min_text) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Constraints_g_and_h.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Constraints_g_and_h.gif Binary files differdeleted file mode 100644 index 0da30ad..0000000 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Constraints_g_and_h.gif +++ /dev/null diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Constraints_g_and_h.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Constraints_g_and_h.py deleted file mode 100644 index 742d6b5..0000000 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Constraints_g_and_h.py +++ /dev/null @@ -1,41 +0,0 @@ -from manimlib.imports import* -import math as m - -class firstScene(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - label_x = TextMobject("$x$").shift([5.5,-0.5,0]).fade(0.4) #---- x axis - label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5).fade(0.4) #---- y axis - - #---- constraint g(x,y) - cylinder = ParametricSurface( - lambda u, v: np.array([ - np.cos(TAU * u), - np.sin(TAU * u), - 2 * (v) - ]),checkerboard_colors=[YELLOW_C,YELLOW_D,YELLOW_E]).rotate(m.radians(-40),RIGHT).shift([0.5,0.5,0]).scale(0.8) - - #---- constraint h(x,y) - plane = ParametricSurface( - lambda u, v: np.array([ - u, - v, - u+v - ]),checkerboard_colors=[TEAL_C,TEAL_D,TEAL_E]).shift([0,0,0]).rotate(m.radians(-40),RIGHT).scale(2).fade(0.3) - - figure = VGroup(cylinder,plane).rotate(m.radians(-45),DOWN).scale(1.5) - - self.set_camera_orientation(phi=65*DEGREES,theta=45*DEGREES) - self.add(axes) - self.add(label_x) - self.add(label_y) - self.wait(1) - self.play(Write(cylinder)) - self.play(Write(plane)) - self.wait(1) - self.begin_ambient_camera_rotation(rate=0.4) - self.wait(1) - self.wait(1) - self.play(FadeOut(label_x),FadeOut(label_y)) - self.wait(1) - self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.gif Binary files differindex e028a81..e028a81 100644 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.gif +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.py index 2c1d668..2c1d668 100644 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.py +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.py diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.gif Binary files differnew file mode 100644 index 0000000..f1f7974 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.py new file mode 100644 index 0000000..a1396fc --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.py @@ -0,0 +1,52 @@ +from manimlib.imports import* +import math as m + + class Constraints(ThreeDScene): + def construct(self): + axes = ThreeDAxes().rotate(m.radians(75)) + label_x = TextMobject("$x$").shift([-5.5,1,0]).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift([1,5.5,0]).rotate(-4.5).fade(0.4) #---- y axis + + cylinder = ParametricSurface( + lambda u, v: np.array([ + np.cos(TAU * u), + np.sin(TAU * u), + 2 * (1-1.5*v) + ]),checkerboard_colors=[YELLOW_C,YELLOW_D,YELLOW_E]).shift([0.5,0.5,-0.13]).scale(1) + + plane = ParametricSurface( + lambda u, v: np.array([ + u, + v, + u+v + ]),checkerboard_colors=[TEAL_C,TEAL_D,TEAL_E]).shift([0,0,0]).rotate(m.radians(-40),RIGHT).scale(4).fade(0.3) + + c = Circle(color='#FF00FF',fill_opacity=0.3).shift([0.7,-1.3,0.4]).rotate(2.5,UP).scale(1.32) + + f_text = TextMobject("$f(x,y)=x^2+y^2+z^2$",color = '#FFA074').scale(0.6).to_corner(UL) + g_text = TextMobject("$g(x,y)=x^2+y^2+1$",color = '#FFA074').scale(0.6).to_corner(UL) + h_text = TextMobject("$h(x,y)=x+y-z=1$",color = '#FFA074').scale(0.6).to_corner(UL) + + + + self.set_camera_orientation(phi=65*DEGREES,theta=95*DEGREES) + + self.add(axes) + self.add(label_x) + self.add(label_y) + self.wait(1) + self.add_fixed_in_frame_mobjects(f_text) + self.play(Write(c)) + self.wait(1) + self.play(FadeOut(f_text)) + self.wait(1) + self.add_fixed_in_frame_mobjects(g_text) + self.play(Write(cylinder)) + self.wait(1) + self.play(FadeOut(g_text)) + self.wait(1) + self.add_fixed_in_frame_mobjects(h_text) + self.play(Write(plane)) + self.wait(1) + self.play(FadeOut(h_text)) + self.wait(1) |