1
$\begingroup$

I'm having trouble with with Duffy Coordinate Transformation routine within Mathematica. I'm able to use NIntegrate`DuffyCoordinatesIntegrand command correctly as indicated in the manual (link) for the given example functions.

Where Mathematica fails is when using a piecewise function. It works if I define the piecewise functions to be the same in every 'piece' but when the pieces are different it fails.

Working example code:

kf = Pi/2; t[x_, y_] = 
NIntegrate`DuffyCoordinatesIntegrand[
Piecewise[{{ 1/Sqrt[(x - kf)^2 + (y - kf)^2], (x + y)/2 < kf }, { 
  1/Sqrt[(x - kf)^2 + (y - kf)^2], (x + y)/2 >= kf}}], {x, 0, 
kf}, {y, kf, Pi}, 
Method -> {"DuffyCoordinates", "Corners" -> {{1, 0}}}] // 
FullSimplify

Output:

(\[Pi] x)/Sqrt[x^2 (1 + y^2)]

Problematic code example:

 kf = Pi/2; 
 t[x_, y_] = 
 NIntegrate`DuffyCoordinatesIntegrand[
 Piecewise[{{ 1/Sqrt[(x - kf)^2 + (y - kf)^2], (x + y)/2 < kf }, { 
  2/Sqrt[(x - kf)^2 + (y - kf)^2], (x + y)/2 >= kf}}], {x, 0, 
 kf}, {y, kf, Pi}, 
 Method -> {"DuffyCoordinates", "Corners" -> {{1, 0}}}] // 
 FullSimplify

Output:

 (\[Pi]^3 x (2 (Sqrt[(4 + \[Pi]^2 (1 + x)^2) (2 + \[Pi] (-1 + 
          x y))^2] + 
    Sqrt[(2 + \[Pi] (-1 + 
          x))^2 (4 + (\[Pi] + \[Pi] x y)^2)]) + \[Pi] (-Sqrt[(4 + \
 \[Pi]^2 (1 + x)^2) (2 - \[Pi] + \[Pi] x y)^2] - 
    Sqrt[(2 + \[Pi] (-1 + x))^2 (4 + (\[Pi] + \[Pi] x y)^2)] + 
    x (Sqrt[(4 + \[Pi]^2 (1 + x)^2) (2 - \[Pi] + \[Pi] x y)^2] + 
       y Sqrt[(2 + \[Pi] (-1 + 
              x))^2 (4 + (\[Pi] + \[Pi] x y)^2)]))))/(4 Sqrt[(4 + \
 \[Pi]^2 (1 + x)^2) (2 + \[Pi] (-1 + x y))^2]
Sqrt[(2 + \[Pi] (-1 + x))^2 (4 + (\[Pi] + \[Pi] x y)^2)])

The expected result is:

(3 \[Pi] x)/(2 Sqrt[x^2 (1 + y^2)])

The difference between the working and the problematic example is just a constant factor 2 in the second triangle.

Is there a way to fix this?

Kind regards, sofista

$\endgroup$
  • $\begingroup$ If I add //PowerExpand//Simplify to your problematic code, I get a much shorter answer than you, but still not your expected answer. $\endgroup$ – Bill Watts Jan 8 '18 at 1:11
  • $\begingroup$ Hi, thanks for the response. Expanding does not help :( I think the problem lies somewhere deep in Mathematica code that prevents it from loading in piecewise functions when this particular transformation (Duffy transformation) option is used. I do have a work around, and its doing it myself :). I might post the steps but its still not a Mathematica solution that I'm looking for. $\endgroup$ – Sofista 137 Jan 8 '18 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.