extrema of change of variables in matlab

To find the extrema (maximum and minimum) of a function resulting from a change of variables in MATLAB, you can follow these general steps:

  1. Define your new variables in terms of the original variables.
  2. Determine the function representing the change of variables.
  3. Find the extrema by taking the derivative w.r.t. the new variables and setting it equal to zero.

Here's an example illustrating these steps:

Suppose you have a function f(x, y) = x^2 + y^2 and you make a change of variables u = x + y and v = x - y. The corresponding function g(u, v) can be found by substituting x = (u + v)/2 and y = (u - v)/2 into f(x, y).

main.m
syms u v;
g = subs(x^2 + y^2, [x, y], [(u + v)/2, (u - v)/2]);
63 chars
3 lines

Next, calculate the extrema of g(u, v) by computing the derivative w.r.t. u and v:

main.m
dg_du = diff(g, u);
dg_dv = diff(g, v);
s = solve([dg_du == 0, dg_dv == 0], [u, v]);
extrema_u = s.u;
extrema_v = s.v;
119 chars
6 lines

The variables extrema_u and extrema_v will contain the values of u and v at which the extrema occur.

Remember, this is a general example and specific steps might vary based on the original function and the specific change of variables you are using.

related categories

gistlibby LogSnag