# GeoGebra Removes Parentheses Necessary for Evaluation

ztlawton shared this problem 2 years ago
Solved

I am working on a demonstration of gear shapes and have run into an issue when using an IF statement in a parametric equation. I am using the XOR operator to link two expressions that output Boolean values:

`If(IsInteger(k / 4) ⊕ (h(θ, d) ≤ 0), <Then>, <Else> )`
("Then" and "Else" statements removed for brevity)

Where the first expression checks if the number of teeth on the gear (half of the slider-value "k") is even, and the second expression checks if the output of the function "h(x,y)" is less than zero when given the inputs "θ" (from the parametric equation) and "d" (the rotational distance).

This evaluates as expected, with one caveat: when GeoGebra processes this input, it removes the parentheses around the second expression. If anything happens after this point to cause GeoGebra to re-evaluate the parametric equation - including the act of opening the file - it throws an error at the IF statement and replaces the entire parametric equation's definition with "?".

This is what the IF statement is changed to:

`If(IsInteger(k / 4) ⊕ h(θ, d) ≤ 0, <Then>, <Else> )`
This is the error I get:
```Illegal Boolean operation
null = false ∨ 0```
Is there a way to force GeoGebra to leave the parentheses in, or a better way to set this up? Please try the new version (v453) 2

try

`If(IsInteger(k / 4) ⊕ (0>=h(θ, d)), <Then>, <Else> )`

sometimes it works 1

Just tried it. Unfortunately that does the same thing as the original, for me at least - it works the first time I put it in, but GeoGebra still removes the parentheses, and as soon as I change anything else (or save the file, close it, and later re-open it) GeoGebra can't process it.  2

yes

I think there is a bug with xor symbol . I hope developers solve it

meantime you can try

try If((0 ≤ x(E)) != IsInteger(k / 4) , , ) 1

Yep, using this worked! It seems like it is just an issue with XOR, then. I wound up using this for my conditional:

`If(IsInteger(k / 4) != (h(θ, -d) ≤ 0), <Then>, <Else> )`
And GeoGebra leaves in the parentheses and correctly re-evaluates the expression whenever something changes!

EDIT: And after all that, it seems that the XOR issue has been fixed in the latest version, and I just needed to update GeoGebra to get it to work properly, but it's nice to have more than one solution!  1

Hi!

I saw this thread ( https://help.geogebra.org/t... ) and thought ...

Probably it's a bug, but perhaps the problem can be solved by setting paranthesis in another way.

Would you please send a file "minimal example" (like in LaTeX ;-) ) to try out?

kind regards

mire2 2

Ok, another simple idea.

Knowing that "(A XOR B)" is equivalent to "¬(A==B)" what happens now?

```If(¬(IsInteger(k / 4)==(h(θ, d) ≤ 0)), <Then>, <Else> )

```

Upps - it's the same idea mathmagic posted. 1

Thank you! This is what worked for me. It seems that XOR was the cause of the issue.

EDIT: It also seems that the XOR issue has been fixed in the latest version, and I just needed to update GeoGebra to get it to work properly, but it's nice to have more than one solution!  2

Please try the new version (v453) 1

I updated from v452 to v453 and the issue is indeed fixed! My original syntax works just fine in the newest version. Much appreciated! 