Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.6K Views
|
16 Replies
|
19 Total Likes
View groups...
Share
Share this post:

Why doesn't Wolfram compute Ceiling[x] = 1 + Floor[x]?

Posted 4 months ago

I want to understand why Wolfram doesn't compute obvious equalities.

In:  FullSimplify[Ceiling[x] == Floor[x], x \[Element] Integers]
Out: True

OK

In:  FullSimplify[Ceiling[x] == 1 + Floor[x], x \[Element] Reals]
Out: Ceiling[x] == 1 + Floor[x]

Why?

In:  FullSimplify[Ceiling[x] - Floor[x] == 1, x \[Element] Reals && x \[NotElement] Integers]
Out: Ceiling[x] == 1 + Floor[x]

Why?

POSTED BY: Sasha Mandra
16 Replies
POSTED BY: Michael Rogers
Posted 3 months ago

You're gorgeous as always!

There isn't such a function presently

I realize that. I put it that way for brevity. You can leave Ceiling[x] - Floor[x] -1 as the definition of a function on the set of real numbers. The important thing is for Wolfram to prove that this function is -1 if x is an integer and 0 if x is a non-integer.

POSTED BY: Sasha Mandra

The functions KroneckerDelta[Sin[Pi x]] and KroneckerDelta[SawtoothWave[x]] behave disappointingly with respect to derivation and integration:

D[KroneckerDelta[Sin[Pi x]], x]
D[KroneckerDelta[SawtoothWave[x]], x]
Integrate[KroneckerDelta[Sin[Pi x]], x]
Integrate[KroneckerDelta[SawtoothWave[x]], x]

The same for Boole[Element[x, Integers]], which also does not evaluate on floating point integers, such as Boole[Element[1., Integers]]

POSTED BY: Gianluca Gorni

I cannot say that I like the integrals. But the derivatives make good sense to me. The Kronecker delta, unlike its Dirac analog, is not a functional. There are no plausible alternatives for the derivatives that I'm aware of.

POSTED BY: Daniel Lichtblau

I was going to add this from the docs of D[]:

D returns generic results that may not account for discontinuities, cusps or other special points

This is the case for Kronecker[x]. However, the following seems wrong (should be Pi*x, not 2*Pi*x, right?):

D[SawtoothWave[x], x]
(*  Piecewise[{{1, Sin[2*Pi*x] != 0}}, Indeterminate]  *)

Otherwise, we could use SawtoothWave[x] + SawtoothWave[1 - x] for Ceiling[x] - Floor[x].


Further, @Daniel may like this integral better:

Integrate[KroneckerDelta[Sin[Pi x]], {x, 0, x}]
(*  ConditionalExpression[0, x \[Element] Reals]  *)
POSTED BY: Michael Rogers
Posted 3 months ago

In Michaels smart solution DiscreteDelta works the same as KroneckerDelta. And if one wants to extend it to also include negative values of x it is needed to take the absolute value:

In:  Table[DiscreteDelta@SawtoothWave@x, {x, -2, 2, 0.5}]
Out: {0, 0, 0, 0, 1, 0, 1, 0, 1}

In:  Table[DiscreteDelta@SawtoothWave@Abs@x, {x, -2, 2, 0.5}]
Out: {1, 0, 1, 0, 1, 0, 1, 0, 1}
POSTED BY: Hans Milton
Posted 3 months ago
POSTED BY: Eric Rimbey
Posted 3 months ago

Thank you for your response. I apologize if you got the impression that I have any prejudice against you. I just don't think your answer answers my question.

As for 2. [Element] Integers, there is no problem here. Wolfram simply does not attribute any truth value to this expression: neither true nor false.

In:  {2. \[Element] Integers, 2. \[NotElement] Integers} // FullSimplify
Out: {2. \[Element] Integers, 2. \[NotElement] Integers}

But this is irrelevant to my question, since only variables are involved. And there is nothing wrong with variables in Wolfram.

As for my interest, it is pure curiosity: to what extent can Wolfram help in theoretical mathematics? I would like Wolfram to be able to convert an expression Ceiling[x] - Floor[x] - 1 into a function that has zero everywhere except the set of integers, where it has -1. From a theoretical point of view, this is elementary.

POSTED BY: Sasha Mandra
Posted 3 months ago

Okay, maybe my response was irrelevant, but I'm not convinced, so let me try again. I see your point about my example using concrete values while you're only interested in the abstraction provided by variables. But Mathematica doesn't want to give an untrue answer (as much as reasonable, there are in fact weird edge cases that one could consider untrue, but I don't think we need to go into that). So, if it were to "solve" the problem with variables but a user wanted to use the solution with values (in particular the values I used as examples), well then they'd get very incorrect results.

As for your questions...

I would like Wolfram to be able to convert an expression Ceiling[x] - Floor[x] - 1 into a function that has zero everywhere except the set of integers, where it has -1.

That's easy. We can just use your expression directly:

myFunc[x_] := Ceiling[x] - Floor[x] - 1;
Table[myFunc[x], {x, -2, 2, 1/4}]
(* {-1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1} *)

There are probably many ways to define such a function, there may even be a built in function for that.

to what extent can Wolfram help in theoretical mathematics?

I'm not the right person to answer that, but as far as I can tell there are many people doing sophisticated mathematics with Wolfram.

POSTED BY: Eric Rimbey
Posted 3 months ago

Sorry, I didn't notice your reply, so I'm replying late.

So, if it were to "solve" the problem with variables but a user wanted to use the solution with values (in particular the values I used as examples), well then they'd get very incorrect results.

And what incorrect results they will get if Wolfram computes it?

In:  FullSimplify[Ceiling[x] - Floor[x] == 1  
 x \[Element] Reals]
Out: x \[NotElement] Integers

Let's be specific!

POSTED BY: Sasha Mandra
Posted 3 months ago

I'm sorry, but I've lost the plot. I don't understand where you're going with this. I don't understand why my answers are confusing, and so I don't know how to improve them. Have you been able to get something to actually work? Have you tried the suggestions offered here, and have they worked or not? I'd really prefer to help you reach your specific objective rather than rathole on some quirk of Mathematica's Simplify implementation.

POSTED BY: Eric Rimbey
Posted 4 months ago

This is why:

In:  Ceiling[x] - Floor[x] /. x -> 2.
Out: 0

In:  IntegerQ[x] /. x -> 2.
Out: False

In:  Head[2.]
Out: Real
POSTED BY: Hans Milton
Posted 4 months ago

What do you mean? Here's another example:

In:  1 \[Element] Rationals
Out: True

In:  Ceiling[x] == 1 + Floor[x] /. x -> 12/5
Out: True

In:  FullSimplify[Ceiling[x] == 1 + Floor[x], x \[Element] Rationals]
Out: Ceiling[x] == 1 + Floor[x]
POSTED BY: Sasha Mandra
Posted 4 months ago

From the documentation of Rationals, under Details:

The domain of integers is taken to be a subset of the domain of rationals.

In:  Element[2, Rationals]
Out: True
POSTED BY: Hans Milton
Posted 4 months ago

I think Hans Milton provided a good example, and your reply to that doesn't seem relevant. Here's another way to look at it:

FullSimplify[Ceiling[x] == Floor[x], x \[Element] Integers]
(* True *)

FullSimplify[Ceiling[x] == Floor[x], x \[Element] Reals]
(* Ceiling[x] == Floor[x] *)

So, you can interpret that as meaning, "when x is real, Mathematica cannot find a simplification that resolves the equality to true or false". And of course, like Hans showed, one example is 2.0. Indeed, we have

2 \[Element] Reals
(* True *)

So, we don't even need an expression with Real as its Head. Furthermore, consider this

2. \[Element] Integers
(* 2. \[Element] Integers *)

2. \[NotElement] Integers
(* 2. \[NotElement] Integers *)

meaning that Mathematica withholds commitment about the integer-valued-ness for a value that you expect to satisfy your assumptions. I think the answer to your original question depends upon the reason for that.

POSTED BY: Eric Rimbey
Posted 4 months ago

Unfortunately, I don't understand you either.

In:  Reduce[Ceiling[x] + Floor[x] == 1, x, Reals]
Out: 0 < x < 1

ОК

In:  Reduce[Ceiling[x] - Floor[x] == 1, x, Reals]
Out: This system cannot be solved with the methods available to Reduce

Why? I'm expecting this response or a similar one:

x \[Element] Reals && x \[NotElement] Integers
POSTED BY: Sasha Mandra
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard