Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question requires Matlab to answer Someone need to know how to use Matlab to answer. If you do not know how to use Matlab

image text in transcribed

image text in transcribed

image text in transcribed

This question requires Matlab to answer

Someone need to know how to use Matlab to answer. If you do not know how to use Matlab then please stop making comments.

Introduction The documentation for this problem initially lists a collection of Matlab commands and how they related to Calculus 3. At the end there is a list of problems you need to do by typing and submitting a Matlab script. Plotting Things Here are some of the things that we've plotted. Notice how there are several different Matlab commands. Note: Before each plot put the single command figure - this ensures all your plots show up and ensures the grading behaves itself First the function y=x-xsin x3 syms figure Fplot(x^2-x* sin(x)) We could also have done: syms x F(x) = **2-x*sin(x) figure fplot(f(x)) Then the 20 vector-valued function t} = (1 + cost) + 2 + sin ni with 0 315 : Symst figure Fplot(1+ces(t),2+sin(t),[0.pi]) Then the 30 vector-valued function t = (108) + rsin + t for OSIS 10 Syms figure fplot3(t*cos(L), t* sin(t),t,[0,10)) The the all-powerful paraboloid. The wrapper matlabFunction is required to convert our function into a form which Matlab can plot more easily. Sym f(x,y)=sin(x)+2*cos(y) figure fsurf(natlabFunction()) Partial Derivatives We can of course also do partial derivatives by telling Matlab what to differentiate with respect to: syms x y diff(x*y*cos(x^2*y),x) We can do a calculation like , Ly) for f(x, y) = xy+ by doing. syms xy F(x,y) = x^2*y+x/y; dift(diff(+(x,y),x),y) Naturally we can substitute afterwards, so for example to assign g(x, y = and then find 8x12, 3) we do syms x y g(x,y) = (x+y)/(x^2-y-2) subs(diff(diff(g(x,y).y),x), {x,y},{-2,3}) The Gradient and Directional Derivatives Matlab has a gradient command but it doesn't do what we want. Instead to do Vf we use Matlab's jacobian command: The the all-powerful paraboloid. The wrapper matlabFunction is required to convert our function into a form which Matlab can plot more easily syissy f(x,y)=sin(x)=2*cos(y) Figure tsurf (matlabFunction(+>> Partial Derivatives We can of course also do partial derivatives by telling Matlab what to differentiate with respect to: syms y diff(x*y*cos(x^2*y),x) We can do a calculation like S, x, y) for S x, y) = x+y + by doing syms y F(x,y) = x^2y+x/y; diff(diff(f(x,y),x),y) Naturally we can substitute afterwards, so for example to assign gx, y) = ** and then find 8:1-2,3) we do: symy $(x,y) = (x+y)/(x^2-y-2) subs (diff(diff(g(x,y),y),x),(x,y),4-2,3}) The Gradient and Directional Derivatives Matlab has a gradient command but it doesn't do what we want. Instead to do Vf we use Matlab's jacobian command: symy F(x,y) = x^2'y-x/y: Jacobian(+(x,y). IX.y!) In order to do directional derivatives well use the fact that DJ = 7 - Vf for any unit vector u and functions. If a vector is not a unit vector we have to make it so first. Here is an example - can you understand what it does? symsy 2 F(x, y, z) = x^2'y-x/y+22; u = [2,1,5); dot(uorm(u), jacobian(F(x,y,z),(x,y,2])) Finding Critical Points Matlab's solve command can solve systems of equations, we just need to know how to assign the answers correctly. If we're solving for two variables we need to assign two answers. For example to find the critical points of f(x,y) = x22xy +1-3y we do this: symy F(x,y) = x^2-2*x+y+1/3+y^3-3*y; [xsolnysoin] = solve( jacobian(+(x,y).[x,y])) This code will find the gradient and set it equal to zero which effectively sets both f, and f, to zero. If you run this code you'll see that there are multiple solutions. The x-values will be stored in xsoln and the matching y-values will be stored in ysoln. Lagrange Multipliers Matlab can do an entire Lagrange multipliers problem in a few lines. In the following example we find the data giving us the extreme values of S X. y) = 3x + 2y? - 4y+ I with the constraint x2 + y2 = 16. syms y F(x,y) = 3*x^2-2y^2-4*y+1; 8(x,y) = x^2+y^2-16; firstpart = jacobian (F(x,y),(x,y))-L*jacobian(g(x,y).[x,y]): [Lsoin,xsoin,ysoin) = solve(firstpart,81) subs(F(x,y), {x,y}, {xsoln,yoln}) The last two lines are key. The result of the second-to-last fine will be list of x-values as well as matching y-values and s-values. The last line plugs these all into and produces a list of f-values. You can then pick out the maximum and/or minimum f-value and see which x and y it came from: syms xy f(x,y) = 3*x2+2y^2-4*y+1; 8(x,y) = x^2+y^2-16; Firstpart - jacobian (F(x,y),(x,y])-L*jacobian(g(x,y).[x,y]); [Lsoln xsoin,ysoln= solve([firstpart.81) subs(F(x,y),(x,y}, {xsoin, ysoin}) The last two lines are key. The result of the second-to-last line will be list of x-values as well as matching y-values and A-values. The last line plugs these all into and produces a list of f-values. You can then pick out the maximum and/or minimum 5-value and see which x and it came from. Now the Project... Write a single script which does each of the following in turn. Make sure you run the script in order to see the results and possible errors!) before submitting it! 1. Plot the function f(x,y)=v7+y and assign the result to g1. 2. Plot the function f x,y) = cos(x + y2 and assign the result to 42 3. Find the derivative and assign the result to 43 Judy x-casty By 4. Assign gx,y). and calculate 1.2.3.8 (triple derivative!) and assign the result to 94. +y 5. Assign f(x,y) = x - xy + V. Find Vf/2,9) and assign the result to 45. You'll need subs too. 8. Find the directional derivative of S x.y = x/y+sin xy) in the direction of i=31 - 2and assign the result to 6 7. Find all critical points for f(x,y) = (y-2) In (xy). In Matlab In is done with log. Assign the result to [972,4771 8. Use Lagrange multipliers to find the maximum and minimum values of f(x,y) = xy subject to the constraint x2 + y = 16. Assign the second-to-last line to [48L,48x48y) and the last line to q8f. Introduction The documentation for this problem initially lists a collection of Matlab commands and how they related to Calculus 3. At the end there is a list of problems you need to do by typing and submitting a Matlab script. Plotting Things Here are some of the things that we've plotted. Notice how there are several different Matlab commands. Note: Before each plot put the single command figure - this ensures all your plots show up and ensures the grading behaves itself First the function y=x-xsin x3 syms figure Fplot(x^2-x* sin(x)) We could also have done: syms x F(x) = **2-x*sin(x) figure fplot(f(x)) Then the 20 vector-valued function t} = (1 + cost) + 2 + sin ni with 0 315 : Symst figure Fplot(1+ces(t),2+sin(t),[0.pi]) Then the 30 vector-valued function t = (108) + rsin + t for OSIS 10 Syms figure fplot3(t*cos(L), t* sin(t),t,[0,10)) The the all-powerful paraboloid. The wrapper matlabFunction is required to convert our function into a form which Matlab can plot more easily. Sym f(x,y)=sin(x)+2*cos(y) figure fsurf(natlabFunction()) Partial Derivatives We can of course also do partial derivatives by telling Matlab what to differentiate with respect to: syms x y diff(x*y*cos(x^2*y),x) We can do a calculation like , Ly) for f(x, y) = xy+ by doing. syms xy F(x,y) = x^2*y+x/y; dift(diff(+(x,y),x),y) Naturally we can substitute afterwards, so for example to assign g(x, y = and then find 8x12, 3) we do syms x y g(x,y) = (x+y)/(x^2-y-2) subs(diff(diff(g(x,y).y),x), {x,y},{-2,3}) The Gradient and Directional Derivatives Matlab has a gradient command but it doesn't do what we want. Instead to do Vf we use Matlab's jacobian command: The the all-powerful paraboloid. The wrapper matlabFunction is required to convert our function into a form which Matlab can plot more easily syissy f(x,y)=sin(x)=2*cos(y) Figure tsurf (matlabFunction(+>> Partial Derivatives We can of course also do partial derivatives by telling Matlab what to differentiate with respect to: syms y diff(x*y*cos(x^2*y),x) We can do a calculation like S, x, y) for S x, y) = x+y + by doing syms y F(x,y) = x^2y+x/y; diff(diff(f(x,y),x),y) Naturally we can substitute afterwards, so for example to assign gx, y) = ** and then find 8:1-2,3) we do: symy $(x,y) = (x+y)/(x^2-y-2) subs (diff(diff(g(x,y),y),x),(x,y),4-2,3}) The Gradient and Directional Derivatives Matlab has a gradient command but it doesn't do what we want. Instead to do Vf we use Matlab's jacobian command: symy F(x,y) = x^2'y-x/y: Jacobian(+(x,y). IX.y!) In order to do directional derivatives well use the fact that DJ = 7 - Vf for any unit vector u and functions. If a vector is not a unit vector we have to make it so first. Here is an example - can you understand what it does? symsy 2 F(x, y, z) = x^2'y-x/y+22; u = [2,1,5); dot(uorm(u), jacobian(F(x,y,z),(x,y,2])) Finding Critical Points Matlab's solve command can solve systems of equations, we just need to know how to assign the answers correctly. If we're solving for two variables we need to assign two answers. For example to find the critical points of f(x,y) = x22xy +1-3y we do this: symy F(x,y) = x^2-2*x+y+1/3+y^3-3*y; [xsolnysoin] = solve( jacobian(+(x,y).[x,y])) This code will find the gradient and set it equal to zero which effectively sets both f, and f, to zero. If you run this code you'll see that there are multiple solutions. The x-values will be stored in xsoln and the matching y-values will be stored in ysoln. Lagrange Multipliers Matlab can do an entire Lagrange multipliers problem in a few lines. In the following example we find the data giving us the extreme values of S X. y) = 3x + 2y? - 4y+ I with the constraint x2 + y2 = 16. syms y F(x,y) = 3*x^2-2y^2-4*y+1; 8(x,y) = x^2+y^2-16; firstpart = jacobian (F(x,y),(x,y))-L*jacobian(g(x,y).[x,y]): [Lsoin,xsoin,ysoin) = solve(firstpart,81) subs(F(x,y), {x,y}, {xsoln,yoln}) The last two lines are key. The result of the second-to-last fine will be list of x-values as well as matching y-values and s-values. The last line plugs these all into and produces a list of f-values. You can then pick out the maximum and/or minimum f-value and see which x and y it came from: syms xy f(x,y) = 3*x2+2y^2-4*y+1; 8(x,y) = x^2+y^2-16; Firstpart - jacobian (F(x,y),(x,y])-L*jacobian(g(x,y).[x,y]); [Lsoln xsoin,ysoln= solve([firstpart.81) subs(F(x,y),(x,y}, {xsoin, ysoin}) The last two lines are key. The result of the second-to-last line will be list of x-values as well as matching y-values and A-values. The last line plugs these all into and produces a list of f-values. You can then pick out the maximum and/or minimum 5-value and see which x and it came from. Now the Project... Write a single script which does each of the following in turn. Make sure you run the script in order to see the results and possible errors!) before submitting it! 1. Plot the function f(x,y)=v7+y and assign the result to g1. 2. Plot the function f x,y) = cos(x + y2 and assign the result to 42 3. Find the derivative and assign the result to 43 Judy x-casty By 4. Assign gx,y). and calculate 1.2.3.8 (triple derivative!) and assign the result to 94. +y 5. Assign f(x,y) = x - xy + V. Find Vf/2,9) and assign the result to 45. You'll need subs too. 8. Find the directional derivative of S x.y = x/y+sin xy) in the direction of i=31 - 2and assign the result to 6 7. Find all critical points for f(x,y) = (y-2) In (xy). In Matlab In is done with log. Assign the result to [972,4771 8. Use Lagrange multipliers to find the maximum and minimum values of f(x,y) = xy subject to the constraint x2 + y = 16. Assign the second-to-last line to [48L,48x48y) and the last line to q8f

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