How can I color area between 2 graphs

yabi100 shared this question 6 years ago
Answered

I have two graphs drawn.

f1(x)=sin(x)

f2(x)=cos(x)


I want to color the area between these two graphs in one period.

How can I apply color to an area between two graphs?


To generalize the question, if a graph is periodic like f(x)=tan(x), I want to color one period of the graph. How can I do that?

Comments (9)

photo
1

Have you tried:

oIntegralBetween

IntegralBetween[ <Function>, <Function>, <Number>, <Number> ]

IntegralBetween[ <Function>, <Function>, <Variable>, <Number>, <Number> ]


Tony

https://ggbm.at/1447665

photo
1

Have you tried:

oIntegralBetween

IntegralBetween[ <Function>, <Function>, <Number>, <Number> ]

IntegralBetween[ <Function>, <Function>, <Variable>, <Number>, <Number> ]


Tony


No I haven't

Let me try and tell the results

photo
1

You can click on show thumbnails an see it quickly, but nothing beats trying it yourself.


Tony

photo
1

Have you tried:

oIntegralBetween

IntegralBetween[ <Function>, <Function>, <Number>, <Number> ]

IntegralBetween[ <Function>, <Function>, <Variable>, <Number>, <Number> ]


Tony


Dear acron

Your example is straight forward. I understand it.

I tried following

IntegralBetween[tan(x), cot(x), 0, 2]

But it says: undefined number


I am wondering if the graph is not bounded (goes to infinity) does this function works?

photo
1

hello

IntegralBetween[tan(x), cot(x), 0.0001, 1.57079] is not good enough for you?


saludos

photo
1

Tangent and cotangent functions have discontinuities at pi/2 and 0/pi respectively...Hence, the need to follow mathmagic's numbers. Click on thumbnails to see code and graph.

    IntegralBetween[f, g, 0/ π +0.00001, π /2-0.00001]

Tony

https://ggbm.at/1447667

photo
1

If you only want to color the area between f and g you may also use

    IntegralBetween[f, g, 0, π /2,false]

https://ggbm.at/1447671

photo
1

Dear Folks


Thanks your replies are informative. I am able to integral the tan(x) -cot(x)


Combination of two graphs has two parts. The equation all of you provided, gives the limited part of the answer (like tow symmetric triangles)

Is there a way to color the hyperbola part in the above equation from y=1 to above?


I assume integral equation calculates the are between two graph exactly same as integrating. Although results could be used for coloring but I think there might be other command in geogebra to do coloring exactly for an area I want to focus. This area might not always coincide with the integration.

photo
1

A workaround for the parabola would to have a line out of the field of view so you can use IntegralBetween. see attached.


There may be a better command.


Tony

https://ggbm.at/1447677

© 2022 International GeoGebra Institute