slow_learner
slow_learner

Reputation: 495

Changing Sinc function to regular sin in mathematica

I have a mathematica function which output is a sum of Sinc https://reference.wolfram.com/language/ref/Sinc.html functions. I need to send said output to a coworker who uses Pyomo https://www.pyomo.org/ for optimization. We have discovered that said optimization software doesn't understand Sinc even if regular Python does. I need to know if there is a way to change the output so instead of using Sinc it returns Sin(x)/x.

I have looked for a solution in Mathworks, but the function seems very limited. I have also checked question like https://mathematica.stackexchange.com/questions/19855/simplify-sinx-x-to-sincx/19856 or https://mathematica.stackexchange.com/questions/144899/simplify-is-excluding-indeterminate-expression-from-output.

However, I haven't found a way to solve the issue.

I have attempted to define by hand sinc as six(x)/x, but this doesn't work due to the indetermination at 0

This is how I define sinc:

sinc = Sinc[Pi #] & ;
sincB = (Sin[Pi #]/(Pi #)) & ;

This is where I use the data to construct an analytic expression. The upper one is the one I used in the past and the lower one is the one that I have constructed now.

shannonIP[v_, w_] = 
 Total[#3* sinc[(v - #1)/dDelta]*sinc[(w - #2)/dDelta] & @@@ 
   interpolatedData]
shannonIPB[v_, w_] = 
 Total[#3* sincB[(v - #1)/dDelta]*sincB[(w - #2)/dDelta] & @@@ 
   interpolatedData]

The resulting expression of the upper code returns a sum of Sincs, the resulting expression of the lower code returns a sum of sin(x)/x, but if evaluated at some points I run in the error of 1/0.

Is there a way to "fix" the output of the lower code or to transform the output of the upper one to an expression readable by Pyomo?

enter image description here This figure is the function constructed using Sinc.

enter image description here This figure is the function constructed using Sin[x]/(x+0.0000000000000001)

Upvotes: 0

Views: 233

Answers (1)

Paul Janssens
Paul Janssens

Reputation: 722

for arguments near zero, you should compute sinc(x) as 1-(x^2)/6+(x^4)/120

Upvotes: 1

Related Questions