Boolean value problem

Stefan Poka shared this question 3 months ago
Answered

In the example below the input box is related to b=?, a=random({2,sqrt(2)}), and c is a==b.


I do not understand why c=false when the the input is sqrt(2) and a=sqrt(2).


Please help me out! Thanks!

Comments (9)

photo
1

your attachment doesn't quite match your description.

however sqrt(2) != 1.41 because sqrt(2) == 1.414213562373095 (although only 1.41 is displayed, depending on the round)

A Possible Solution

c = abs(sqrt(a) - b) < 0.005

photo
1

The value entered in the input box is sqrt(2): the value of a is also sqrt(2), so c which is sqrt(2)==sqrt(2) is false !!! This is embarrassing me! For the moment I'm still trying to understand why the return for a==a is false.

Many thanks!

photo
1

on my system I have no problems with the version in the attachment.

ggb5.0.620 windows 10 and ggb6.0.620 classic WEB chrome windows 10

photo
1

the value is true typing sqrt(2) in input box . I have not problem

photo
1

One more example shows what my question is:


In the attachment f=sqrt(13), a=? is the undefined variable related to the input box, and b is a==f.


If we input for a ( in the input box ) sqrt(13), b says sqrt(13)==sqrt(13) is false! Unbelievable!!!


What's wrong ?!


Thanks again!

photo
1

Input Box -> Object Properties -> Algebra -> Symbolic will make it work like you want

photo
1

new for me, thanks!

photo
1

Thanks a lot!

photo
photo
1

I think the following is wrong:

quote: "If we input for a ( in the input box ) sqrt(13)"

--------------------------

give in a the same as in the input-box (f) and the boolean b is true.

example: a=sqrt(13) input-box=sqrt(13)

BUT!!!! If you give 2 time enter in the InputBox then f is not sqrt(13)

This is the reason why the input box is normally used as in the attachment.

-------------------------------------

Addendum:

I think Michael Borcherds version is (usually) better

© 2021 International GeoGebra Institute