Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10671 > unrolled thread

Re: Approximate Zero Times A Symbol

Started by"djmpark" <djmpark@comcast.net>
First post2012-06-28 08:06 +0000
Last post2012-07-02 09:29 +0000
Articles 5 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Approximate Zero Times A Symbol "djmpark" <djmpark@comcast.net> - 2012-06-28 08:06 +0000
    Re: Approximate Zero Times A Symbol Richard Fateman <fateman@cs.berkeley.edu> - 2012-07-01 06:07 +0000
    Re: Approximate Zero Times A Symbol "djmpark" <djmpark@comcast.net> - 2012-07-01 06:09 +0000
    Re: Approximate Zero Times A Symbol Richard Fateman <fateman@eecs.berkeley.edu> - 2012-07-01 06:11 +0000
    Re: Approximate Zero Times A Symbol Richard Fateman <fateman@eecs.berkeley.edu> - 2012-07-02 09:29 +0000

#10671 — Re: Approximate Zero Times A Symbol

From"djmpark" <djmpark@comcast.net>
Date2012-06-28 08:06 +0000
SubjectRe: Approximate Zero Times A Symbol
Message-ID<jsh3a9$sir$1@smc.vnet.net>
Thanks Christoph. That does sound like a reasonable argument, yet I would
like to dissent from it.

I don't see why a non-numeric symbol should be considered to have a
precision at all.  Don't we have fields of mathematics, such as algebra or
multilinear algebra, where we have undefined objects or elements to which we
apply various operations? These objects never have numerical values,
although they might have numerical weights. It doesn't seem proper to me to
treat them as numerical quantities so as to combine them with other
numerical factors. If x and y are such objects I can see some justification
for dropping terms such as 0 x, but not 0.0 x and certainly not
automatically converting it to 0.0. The symbol x has a meaning, as one of
the basic elements of the algebra, that the scalar 0.0 does not have. Using
0.0 x -> 0.0 changes the mathematical meaning of the expression. 

For example, in Grassmann algebra one can have general Grassmann numbers
that are multi-graded and have a scalar term + vector terms + bivector terms
etc. The above transformation would incorrectly change a pure vector
expression into a multi-graded expression that has an approximate zero
scalar term (instead of an approximately zero x vector term).


David Park
djmpark@comcast.net 
http://home.comcast.net/~djmpark/index.html 



From: Christoph Lhotka [mailto:christoph.lhotka@fundp.ac.be] 


Hello,

   my argumentation would be as follows:

  0 x = 0  if (0,x) have infinite precision, while 0. x = 0. since the
result has a precision at most of 0., therefore there is no need to keep the
x, which has infinite precision: 
for the expression we only
need x up to precision of 0., therefore 0. * approximate x = 0., which is
true up to the precision of 0.

If I understand well, what you would like to have and if it only concerns
the format it is printed, I would define:

dis[ex_]:=Plus@@({x,y}*(StringTrim/@ToString/@(PaddedForm[Coefficient[ex,#],
{8,8}]&/@{x,y})))

which would give

dis/@{0.x+1.y,0.34324324324324324324324x+1.000000000004y}
{0.00000000 x+1.00000000 y,0.34324324 x+1.00000000 y}

Hope that helps,

   Christoph


On 06/27/2012 10:11 AM, djmpark wrote:
> What is the justification for the following?
>
>
>
> 0. x + 1. y
>
>
>
> 0. + 1. y
>
>
>
> I want to display a dynamic weighted sum of x and y and sometimes one 
> of the coefficients becomes zero. I would like to keep both terms (for 
> a steady
> display) and format with NumberForm.  If Mathematica is going to drop 
> the x, why doesn't it at least also drop the approximate zero?
>
>
>
> If I use SetPrecision we obtain:
>
>
>
> SetPrecision[0. x + 1. y, 10]
>
>
>
> 1.000000000 y
>
>
>
> which is at least more consistent, but not what I want either.
>
>
>
> David Park
>
> djmpark@comcast.net
>
> http://home.comcast.net/~djmpark/index.html
>

[toc] | [next] | [standalone]


#10712

FromRichard Fateman <fateman@cs.berkeley.edu>
Date2012-07-01 06:07 +0000
Message-ID<jsopep$s4$1@smc.vnet.net>
In reply to#10671
On 6/28/2012 1:06 AM, djmpark wrote:
....

  The symbol x has a meaning, as one of
> the basic elements of the algebra, that the scalar 0.0 does not have. Using
> 0.0 x -> 0.0 changes the mathematical meaning of the expression.
>

This is certainly a useful discussion point.  If x is "inches" then 0.0 
* x  still has a dimension (inches).  If x is a vector, there is 
possibly a distinction worth drawing between a zero vector and a scalar. 
  Etc.

On the other hand, 0.0 in Mathematica  means something other than 
mathematical zero in various versions of Mathematica. Though who can
tell about the future.

Try this.



h = 0.50000000000000000000000


Do[ h = 2*h - h}, {i, 1, 50}]

h

One might think that h, being 0.  would have the property that h*x would 
be 0.  Also that h+1  would be 1. But you would be wrong.

In the version 8 Mathematica, numbers like that 0. are displayed in a 
pink box, but of course there is no requirement that you print the 
result, and if you utter   If[h==0,yes,no]  the answer is "yes".
So for programs it might as well be 0 if it is equal to 0.

Aside: The pink box is not quite the right size. Too small. My 
suggestion (and implementation) was to display numbers with no 
significant digits in red.

http://forums.wolfram.com/mathgroup/archive/2010/Jan/msg00897.html

I should have patented it :)

[toc] | [prev] | [next] | [standalone]


#10715

From"djmpark" <djmpark@comcast.net>
Date2012-07-01 06:09 +0000
Message-ID<jsopji$u9$1@smc.vnet.net>
In reply to#10671
Thanks for your reply Richard.

Basically I was interested in formatting a vector a x + b y to so many
places and keeping both terms present even when a or b was an approximate
zero. (My dislike of Dynamic displays that jitter and jump.) Your example
set me onto:

0.00000000000000000000000 x 
0.*10^-23 x 

The x was not dropped! Why was that? Because there is a difference between
Precision and Accuracy and Mathematica behaves differently in this respect.
(I don't know the rationale.)

This lead me to:

0.000``7 x + 0.9823645 y
NumberForm[%, {7, 6}, NumberFormat -> (# &)] 
0.*10^-7 x + 0.982365 y 
0.000000 x  +0.982364 y

where the NumberFormat option is necessary. But how do I get the Accuracy
set on the coefficients before Mathematica drops the x or y? I finally
settled on the following:

angle = 0.0``8;
Slider[Dynamic[angle, (angle = SetAccuracy[#, 8]) &], {0., 90.}, 
 Appearance -> "Labeled"]
Dynamic@NumberForm[Cos[angle Degree] x + Sin[angle Degree] y, {7, 6}, 
  NumberFormat -> (# &)] 

That works, but my complaint is the time required to find a work-around
because Mathematica normally drops an undefined symbol.  One has to know the
Accuracy "trick" and the NumberFormat "trick".  How likely is the average
user going to find that out, just to get a steady dynamic display? There are
other methods, Bob Hanlon has presented a couple, and I was using a Rule
replacement. But it still chews up time.


David Park
djmpark@comcast.net 
http://home.comcast.net/~djmpark/index.html 






From: Richard Fateman [mailto:fateman@cs.berkeley.edu] 

On 6/28/2012 1:06 AM, djmpark wrote:
....

  The symbol x has a meaning, as one of
> the basic elements of the algebra, that the scalar 0.0 does not have. 
> Using
> 0.0 x -> 0.0 changes the mathematical meaning of the expression.
>

This is certainly a useful discussion point.  If x is "inches" then 0.0
* x  still has a dimension (inches).  If x is a vector, there is possibly a
distinction worth drawing between a zero vector and a scalar. 
  Etc.

On the other hand, 0.0 in Mathematica  means something other than
mathematical zero in various versions of Mathematica. Though who can tell
about the future.

Try this.



h = 0.50000000000000000000000


Do[ h = 2*h - h}, {i, 1, 50}]

h

One might think that h, being 0.  would have the property that h*x would be
0.  Also that h+1  would be 1. But you would be wrong.

In the version 8 Mathematica, numbers like that 0. are displayed in a pink
box, but of course there is no requirement that you print the 
result, and if you utter   If[h==0,yes,no]  the answer is "yes".
So for programs it might as well be 0 if it is equal to 0.

Aside: The pink box is not quite the right size. Too small. My suggestion
(and implementation) was to display numbers with no significant digits in
red.

http://forums.wolfram.com/mathgroup/archive/2010/Jan/msg00897.html

I should have patented it :)

[toc] | [prev] | [next] | [standalone]


#10727

FromRichard Fateman <fateman@eecs.berkeley.edu>
Date2012-07-01 06:11 +0000
Message-ID<jsopnd$10f$1@smc.vnet.net>
In reply to#10671
I don't know much about NumberFormat or Sliders, but look at this:

Coefficient[a*x+b*y, {x,y}]     returns {a,b}
Coefficient[    b*y,{ x,y}]     returns {0,b}

I get the feeling that there is something resembling a "thought crime" 
that is causing you
problems.  That is, confusing the "computation of a value"   and the 
"display of some
attributes of a value".  It is not necessary to change the Accuracy or 
Precision of a value
to display it.  It is not necessary for you to make Mathematica to (not) 
simplify 0.0*x to 0.0.
All you have to do is figure out what you want to display, as above.

NumberForm is essentially a way of taking values and computing some 
strings of
characters.  The string for a number has some relation with the actual 
value,
  but  given a result of {0,b}  from Coefficient, presumably you can make
any kind of string you wish, e.g.

      x-coefficient        y-coefficient
  ----------------------------------------
  |.........0........|..........b........|
  ----------------------------------------
RJF



On 6/30/2012 12:01 PM, djmpark wrote:
> Thanks for your reply Richard.
>
> Basically I was interested in formatting a vector a x + b y to so many
> places and keeping both terms present even when a or b was an approximate
> zero. (My dislike of Dynamic displays that jitter and jump.)
..big snip...

[toc] | [prev] | [next] | [standalone]


#10741

FromRichard Fateman <fateman@eecs.berkeley.edu>
Date2012-07-02 09:29 +0000
Message-ID<jsrpme$d4a$1@smc.vnet.net>
In reply to#10671
On 6/30/2012 8:35 PM, djmpark wrote:
> You look on Mathematica as a programming language (which it is in a way) but
> I look on it as a "piece of paper" on which I can do, write and communicate
> mathematics.

I don't disagree with that generally,  and most computer algebra systems look that way, with a "document" paradigm lurking somewhere.

I think where we disagree is to what extent a system that is designed at a particular time by a particular group of people, and is more or less bound to some backward-compatible notions and design guidelines can be expected to do encompass everything and anything that someone else can envision.

I think that the best chance for success is for the system to do the mathematically correct thing whenever that can be unequivocally determined. Sometimes called the principle of "no surprises".

Even so, such a system cannot do everything for everyone, since there are disagreements about matters in which there are several distinct approaches. Mathematicians, to a surprising extent, deal with ambiguous situations and notations. Context is quite important.

In these situations it helps to have a programming language in which each of the competing camps can define particular approaches.

In a situation where you'd like to obtain something that does not fall automatically out of the system in the most obvious way, you can argue that the system should do what you want done,  or you can do the programming.

Arguing that the system should do what you want can best  be done if what you want is unequivocally the right thing.  That is, mathematical correctness demands it.  A good but weaker, argument is that what you want can also make it easier to do the alternatives at that point  (one thought is that the programming language should also be nicely designed, and the representation should be elegant, compact, versatile, etc.)

A common line of complaint about CAS is that (for some user with a specific notation and computational viewpoint) the CAS does not do exactly what that user expects.  Changing the underlying mathematics should be considered if the underlying mathematics is wrong.   I don't know about simplifying 0.0* x,  but it seems to me your requirement of knowing the coefficient of x is simple enough to program.  But maybe I've misunderstood your requirement.




>
> It is actually pretty good at that because, as an example, one can just use
> NumberForm on an expression to obtain nice display, not to speak of all the
> other wonderful features. But then it falls apart, out of the blue, because
> Mathematica automatically converts 0.0 x to 0.0, but only if it has a set
> precision and not a set accuracy. So yes, you can sneak around it by using a
> HoldForm and a Rule, or by making a Row construction (but isn't that what
> NumberForm was supposed to do?) or a String construction or by generating
> the coefficients with a set accuracy and probably other methods. It's the
> kind of programming I would rather not do. It chews up time - including the
> time spent on: Why did Mathematica do that?.
>
> So if we have 0.0 x and x is a Symbol why can't Mathematica just leave it
> alone? What is the rationale?
>
>
> David Park
> djmpark@comcast.net
> http://home.comcast.net/~djmpark/index.html
>
>
>
> From: Richard Fateman [mailto:fateman@eecs.berkeley.edu]
>
>
> I don't know much about NumberFormat or Sliders, but look at this:
>
> Coefficient[a*x+b*y, {x,y}]     returns {a,b}
> Coefficient[    b*y,{ x,y}]     returns {0,b}
>
> I get the feeling that there is something resembling a "thought crime"
> that is causing you
> problems.  That is, confusing the "computation of a value"   and the
> "display of some
> attributes of a value".  It is not necessary to change the Accuracy or
> Precision of a value to display it.  It is not necessary for you to make
> Mathematica to (not) simplify 0.0*x to 0.0.
> All you have to do is figure out what you want to display, as above.
>
> NumberForm is essentially a way of taking values and computing some strings
> of characters.  The string for a number has some relation with the actual
> value,
>    but  given a result of {0,b}  from Coefficient, presumably you can make
> any kind of string you wish, e.g.
>
>        x-coefficient        y-coefficient
>    ----------------------------------------
>    |.........0........|..........b........|
>    ----------------------------------------
> RJF
>
>
>
> On 6/30/2012 12:01 PM, djmpark wrote:
>> Thanks for your reply Richard.
>>
>> Basically I was interested in formatting a vector a x + b y to so many
>> places and keeping both terms present even when a or b was an
>> approximate zero. (My dislike of Dynamic displays that jitter and
>> jump.)
> ..big snip...
>


[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web