# The problem with command If

Roman Chijner shared this question 2 years ago

Hi,

Is it possible the next construction or Bug ?

x∈[a,b]; f(x)=x^2; g- is Polyline on the interval [a,b]

If[condition,f,g]

ggB result-->f(x)/undefined 1

what type of object must be for you h=If[condition,f,g]? is h a function? 1

`Both objects must be of the same type.` 1

OK,

I understand, thanks you for the replies  1

perhaps the tool attached can be usefull 1

@Mathmagik

You replaced polyline with linear functions-a useful tool! thanks

A am interested her possibility to include in the "If" these two different objects!... 1

very nice mathmagic. 1

@Roman

If your polyline is a piecewise given function (you can use mathmagic's tool to get it) then you have, as the name sayed, two functions and the if-command should work, because they are of the same type (functions).

But if your polyline is not a function more details or informations may help to find a solution.

Kind regards

mire2 1

@mire

On a certain interval, depending on the conditions, it is required to specify various piecewise function. I often use the Polyline command. But it is not a function-list of segments!

The Intersect command finds the intersection points of Polyline and Functions! I thought that the If command works with them too... The suggested Mathmagic tool is also convenient as a Polyline command! 1

@Mathmagic

In the inequality F:...

If (x (Element (m, k)) ≤ x ≤ x (Element (m, k + 1)) must be ->

If (x (Element (m, k)) ≤ x <x (Element ( m, k + 1)),

otherwise at the joints points the function is added twice . 1

if(3<=x<=4,x,4<=x<=5,x+3) is equal to if(3<=x<=4,x,4<x<=5,x+3) but different to if(3<=x<4,x,4<=x<=5,x+3)

more if(3<=x<=4,x,4<=x<=5,x+3) is equal to if(3<=x<=4,x,3<=x<=5,x+3)

type the three functions and try f(4),g(4),(h(4))

you can change the tool if you like 1

@Mathmagic

my example in the attached file 1

excuse. I though I had made a nested if function. So you must to edit the tool.

the single strange points of tool1(list) are not visible, this confused me 1

Thank you very much for the work you are doing! I think that such a tool can be among the Geogebra commands!!! 1

I forgot it. really the command was in GG. see datafunction(). but it is not dynamic

it needs an update script

Files: foro.ggb 1

!!!!!!!!!!!!! super, but is not dynamic to use......  