# If and Conditional functions

Hellsla shared this problem 11 months ago
Solved

Hi,

Drawing conditional functions is easy with the If-command, but I have noticed something strange if I want to calculate something with these functions.

If the condition involves double inequation's GeoGebra's CAS can't calculate for example the limit of a function for a value.

So for example:

"g1(x):=If(x<-3, 4x+13,x<2,x^2+2x-2,x>=2,5x+1)"

limit(g1,-3) gives 1

but

"g2(x):=If(x<-3,4x+13, -3<=x<2,x^2+2x-2,x>=2,5x+1)"

"limit(g2-3)" gives ?

I noticed this same problems comes with for example

"f(x):=If(-2<x<2,x)"

"limit(f,0)" gives ?

Br, Lauri Hellsten 2

Please try with the simpler definition:

```f(x) = If(x < -3, 4x + 13, x < 2, x² + 2x - 2, x ≥ 2, 5x + 1)
``` 2

Hi Michael,

Thanks for the suggestion,

Like I said in my original post I know how I can write the original conditional function so that it works.

I am merely asking, why the double inequations for example

"f(x):=If(-2<x<2,x)" and "limit(f,0)" gives "?".

This is pretty fustrating for students, because if you have an conditional function in three parts you don't give it like this:

"f(x) = If(x < -3, 4x + 13, x < 2, x² + 2x - 2, x ≥ 2, 5x + 1) "

Most likely you would give it like this:

"f(x) = If(x < -3, 4x + 13, - 3 <= x < 2, x² + 2x - 2, x ≥ 2, 5x + 1) "

They both draw it the same, but the latter does not calculate the limit correctly.

Is this an attribute of GeoGebra or is there something else to this?

Br, Lauri 1

I will attach a screenshot of the problem:

Both functions draw correctly the same function. You can't calculate the limit with function f1 although that would be the natural way to assign the function.

Another example of using the double inequations in a conditional function is in the GeoGebra Wiki ( https://wiki.geogebra.org/e... )

f(x) =If(x<-1,x²,-1<=x<=1,1,-x²+2) <- This will not calculate the limit in anywhere.

Is this a bug?

Br, Lauri 2

I have a similar problem:

f(x):=If(x<1,1,0)

Limit(f,0)=1

g(x):=If(x<1,1)

Limit(g,0)=? 3

I agree with Lauri. Students want to write it like

f(x) =If(x<-1,x²,-1<=x<=1,1,-x²+2)

Limit commands dont work with that.

M 1

Continuing on the same subject one could ask is this even a function that is shown in the algebra-window?

f( -2 )=-2 or -1 ?

When you can't calculate with a piecewise function that has double inequalities in the condition it forces me to use different notation in GeoGebra than it is normal in mathematics for piecewise functions in three parts. I think this is a problem and it should be addressed. Br, Lauri 1

Try this

f(x)=If(x < -3, 4x + 13, x < 2, x² + 2x - 2, x ≥ 2, 5x + 1)

g(x)=If(x < ∞, f(x))

Files: temp.ggb 1

We've made some improvements for next release (v507). It still won't work for functions with undefined/infinite regions.

This will be fine:

`g2(x):=If(x<-3,4x+13, -3<=x<2,x^2+2x-2,x>=2,5x+1)` 1

Try this:

Limit(x/sqrt(-abs(x)), 0) 