Message Boards Message Boards

0
|
1646 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Different results from two equal functions?

Posted 11 months ago

In the enclosed notebook, the functions ts and ts2 are equivalent, both in theory and in Mathematica computation. However, when used in the same formula, see z3b1 and z3b2, the former works, the latter returns complex infinity. Is this a bug or is there some subtlety that I am unaware of? Thanks.

Leon

POSTED BY: Leon Fairbanks
6 Replies
Posted 11 months ago

It seems that, in the case of these examples, the correct answer is that they do not converge since the magnitude of the terms in the sum does not go to zero. Hence the finite values returned by Mathematica are in error. I would like to know how Mathematica arrived at those values. Perhaps Mathematica came up with a formula based upon the form of the equations, but failed to check the domain upon which the formula is valid.


  • List item
POSTED BY: Leon Fairbanks
Posted 11 months ago

Here's another example where Mathematica fails.

POSTED BY: Leon Fairbanks

If I am not mistaken, your sum is a geometric progression:

Sin[(i \[Pi])/2^(n - 1) (3/2 + k)] // TrigToExp
% /. Exp[a_] :> (Exp[Cancel[a/i]])^i
POSTED BY: Gianluca Gorni
Posted 11 months ago

Gianluca, I see, you are referring to the function ts. That does look like a nice way to prove the result, which is

Sum[Sin[A + i D], {i, 0, n - 1}] = ( Sin[(n D)/2] Sin[A + ((n - 1) D)/2] )/Sin[D/2]

POSTED BY: Leon Fairbanks
Posted 11 months ago

This

{ts[112,3], ts2[112,3]}

shows that the form of the two expressions are different.

This

FullSimplify[ts[112,3]==ts2[112,3]]

shows that the two expressions are exactly equal if you are using exact math at every step.

Turning ts and ts2 into numerical approximations requires working through the parts of each expression one step at a time and turning those into approximate MachinePrecision numerical expressions. During that is where slight differences in approximate math show different approximate results that you are seeing.

I suspect exactly the same is the cause of what you are seeing for z3b1 and z3b2, but I didn't wait long enough to see the final result of summing those from zero to Infinity.

POSTED BY: Bill Nelson
Posted 11 months ago

Bill, Thanks for responding. I understand that the internal representation of the two expressions are equal only up to the required significant digits. It does seem like the accumulation of those differences in an infinite sum caused one computation to fail. Then would you agree that this seems to be a bug in Mathematica in that it could not maintain the requested level of significant digits? On the other hand, perhaps it is impossible to in every case maintain a requested level of precision and reporting "Internal precision limit reached" is the best they can do. I wonder if there is a way to confirm what is going on and if a work-around exists.

POSTED BY: Leon Fairbanks
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract