Composition of functions

Hi everyone,

I would like to ask please,

I defined the following functions :

h1(z)=(abs(z)-1)^2*(1+2*abs(z)), for -1<z<1 otherwise h1(z)=0.


and would like to compose h1(z(x,y))

I created two functions in FF++ but when I composed them, FF++ doesn’t compute the composed function.

real theta=pi/4;
real c=1;
real lambda=1;
real xr=3,yr=3;
real x0=xr+lambdacos(theta),y0=yr+lambdasin(theta);

func h1= ((abs(z)-1)^2*(1+2abs(z)))(z>-1 && z<1);
func z=((x-x0)*cos(theta)+(y-y0)sin(theta)+ct)/lambda;
func utilde=h1(z(x,y));// compse h1(z)

but FF++ tells me that there is an error in the definition of utilde.

Thank you!


Hi. naively there are most likely missing types and arguments , you define func z with no arguments… maybe something like

func real h1(real zz)= ((abs(zz)-1)^2*(1+2abs(zz)))(zz>-1 && zz<1);
func real z0(real xx, real yy)=((xx-x0)*cos(theta)+(yy-y0)sin(theta)+ct)/lambda;
func real utilde=h1(z0(x,y));// compse h1(z)

Note that maybe z is a reserved word. Also you could simply use macros like

macro z(xx,yy)=((xx-x0)*cos(theta)+(yy-y0)sin(theta)+ct)/lambda //EOM

Thank you so much Julien, for your reply! I appreciate it.

I tried to use the macro command.

the code runs but, it doesn’t give the right result.

the right result should be that from the right, top and left edges of the square there should be a wave propagating in one direction.

Could you please check where is the problem?

Thank you,

u incident.edp (1.4 KB)