How to set a function value or expression over a domain in Maple

477 Views Asked by At

I have a function $f(x,y,z)$ and would like to impose the condition $$f(x,y,z)|_{x^2+y^2<1}=x-y$$ That is, $f$ is set to be equal to $x-y$ within the unit circle in the xy-plane.

How would I write this in Maple? I tried with eval but it won't allow the inequality sign.

3

There are 3 best solutions below

3
On BEST ANSWER

An adjustment to mrf's tentative suggestion.

restart:

f:=proc(x,y,z)
      if x::numeric and y::numeric and x^2+y^2<1 then
        x-y;
      else
        'procname'(args);
      end if;
end proc:

f(a,b,c);
                       f(a, b, c)

f(1/2,1/3,z);
                           1
                           -
                           6

f(2,2,z);
                       f(2, 2, z)
2
On

I can't quite think of a use case for this (normally, you wouldn't specify the domain of a function when using Maple), but perhaps

f := proc (x, y, z) if x^2+y^2 < 1 then x-y else ('f')(x, y, z) end if end proc

is what you're looking for? (The drawback being that f(a,b,c) raises an error about not being able to determine whether $a^2+b^2 < 1$.)

3
On
f:= proc(x,y,z)
     try
          if x^2+y^2 < 1 then x-y else 'procname'(args) end if
     catch "cannot determine if this expression is true or false: ":
          'procname'(args)
     end try
end proc;