Change of variables with a double integral

3 次查看(过去 30 天)
I have to write a code for changing variables from (x,y) to (u,v) with no in built matlab features. I am given four points in (x,y) and then told to transform it to (u,v) as (0,0) P1 to this point,(1,0) P2 to this point, (0,1) P3 to this point, and (1,1) P4 to this point. In our notes we are given that
x = au + bv +c or x = au + b and y = du + ev + f or y = cv + d to change the function from f(x,y) to f(u,v) given the new bounds as [0,1]X[0,1].
I'm just getting stuck on how to do this without any in built functions.

回答(1 个)

Zahrah Walid
Zahrah Walid 2022-11-18
Example to illustrate the flow:
syms u v
%integration limits
x_min=0;
x_max=1;
y_min=2;
y_max=4;
F_original=@(x,y) x*y;
%variables relations
a_y=2;
b_y=3;
c_y=1;
a_x=1;
b_x=2;
c_x=3;
y= a_y*u+b_y*v+c_y;
x= a_x*u+b_x*v+c_x;
%change of limits (you can do it manually for simple relationships)
u_min=sym2poly(solve(a_y*u+b_y*v+c_y-y_min, a_x*u+b_x*v+c_x-x_min).u);
v_min=sym2poly(solve(a_y*u+b_y*v+c_y-y_min, a_x*u+b_x*v+c_x-x_min).v);
u_max=sym2poly(solve(a_y*u+b_y*v+c_y-y_max, a_x*u+b_x*v+c_x-x_max).u);
v_max=sym2poly(solve(a_y*u+b_y*v+c_y-y_max, a_x*u+b_x*v+c_x-x_max).v);
%change of respect value
dy_du=sym2poly(diff(y,u));
dy_dv=sym2poly(diff(y,v));
dx_du=sym2poly(diff(x,u));
dx_dv=sym2poly(diff(x,v));
sub_F=@(u,v) F_original(a_x*u+b_x*v+c_x,a_y*u+b_y*v+c_y).*dy_du*dy_dv*dx_du*dx_dv;
then preform the integration by the whatever method you prefer.
  2 个评论
Torsten
Torsten 2022-11-18
So
value1 = integral2(F_original,x_min,x_max,y_min,y_max)
value2 = integral2(sub_F,u_min,u_max,v_min,v_max)
should give the same value ?
But the values differ ...
Zahrah Walid
Zahrah Walid 2022-11-18
编辑:Zahrah Walid 2022-11-18
You are right but I guess that the change of limits is the reason as it is not neccessarly that x lower limit occurs with y lower limit to results in u or v lower limits, it is related to the transformation of integration area new limits which may be not any combination between x and y limits; I was just showing the overall flow. For a simpler example with limits directly mapped, it works as required.
syms u v
%integration limits
x_min=0;
x_max=1;
y_min=2;
y_max=4;
F_original=@(x,y) x.*y;
%variables relations
a_y=2;
c_y=1;
a_x=1;
c_x=3;
y= a_y*u+c_y;
x= a_x*v+c_x;
%change of limits
u_min=sym2poly(solve(a_y*u+c_y-y_min, u));
u_max=sym2poly(solve(a_y*u+c_y-y_max, u));
v_min=sym2poly(solve(a_x*v+c_x-x_min,v));
v_max=sym2poly(solve(a_x*v+c_x-x_max,v));
%change of respect value
dy_du=sym2poly(diff(y,u));
dx_dv=sym2poly(diff(x,v));
sub_F=@(u,v) F_original(a_x*v+c_x,a_y*u+c_y).*dy_du*dx_dv;
value1 = integral2(F_original,x_min,x_max,y_min,y_max)
value2 = integral2(sub_F,u_min,u_max,v_min,v_max)
Sorry for inconvenience and many thanks for your comment

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by