Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Approximate Zero Times A Symbol
Replies: 12   Last Post: Jul 1, 2012 2:11 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 906
Registered: 10/29/11
Re: Approximate Zero Times A Symbol
Posted: Jun 28, 2012 4:04 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Zero times anything is zero (Times help: "0 x evaluates to 0, and 0.0
x evaluates to 0.0."). For an extreme example,

0 * Plot[x, {x, 0, 1}]

0


Another approach:

Manipulate[
theta = angle Degree;
NumberForm[Row[{
Sin[theta], " ", x, " + ",
Cos[theta], " ", y}] // Chop,
{7, 6}],
{{angle, 0, " angle\n{degrees)"}, 0, 90, 0.5,
Appearance -> "Labeled"}]


Bob Hanlon


On Wed, Jun 27, 2012 at 12:25 PM, djmpark <djmpark@comcast.net> wrote:
> Thanks Bob, but I think I didn't express myself clearly enough. What I have
> is a dynamic display where the coefficients are varied and I want to retain
> x and y in the display even when their coefficients are zero.
>
> The following is what I ended up doing, but it does seem like a roundabout
> method to obtain the result.
>
> angle = 0.;
> Slider[Dynamic[angle], {0., 90.}, Appearance -> "Labeled"]
> Dynamic@NumberForm[
> HoldForm[aa x + bb y] /.
> Thread[{aa, bb} -> {Sin[angle Degree], Cos[angle Degree]}] //
> Chop, {7, 6}]
>
> And I still don't understand why Mathematica should drop the x if x is not a
> numeric quantity.
>
> David Park
> djmpark@comcast.net
> http://home.comcast.net/~djmpark/index.html
>
>
>
>
> From: Bob Hanlon [mailto:hanlonr357@gmail.com]
>
>
> Use Rationalize
>
> expr = 0. x + 1. y;
>
> expr // Rationalize
>
> y
>
> expr // Rationalize[#, 0] &
>
> y
>
> If there are any rational factors remaining you can use N with any desired
> precision to return to reals.
>
>
> Bob Hanlon
>
>
> On Wed, Jun 27, 2012 at 4:11 AM, djmpark <djmpark@comcast.net> 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

>



--
Bob Hanlon




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.