2

Here is the problem

enter image description here,

find the condition that must be satisfied by x in order that the expression may be positive for all real values of x.

The result is :

enter image description here

I would like to polt in axis the soultion of the preceding inequality,reaching such an following effect:enter image description here

here is my MWE:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=7, nodes={
   execute at begin node=$,
   execute at end node=$
 }]
\draw[->, thick] (-0.8,0) -- (0.8,0) node[above] {x};
\foreach \x/\xpar/\xtext in {
    -0.5 / \bullet / -5,
    -0.1 / \bullet / -1,
    0    /  \circ / 1,
    0.2  / \bullet  / \frac{3}{2},
    0.3  / \bullet / 2,
    0.6  / \circ / 4
}   \draw[thick] (\x,0pt) node {\xpar}  node[below=5pt] {\xtext};
\node[circle,blue,fill=white,draw,inner sep=2pt] at  (0,0) {};
\end{tikzpicture}
\end{document}

How can i achive this goal?

1

Here are two proposals that approach your drawing without reproducing it precisely.

Both have in common to add a variable in the foreach loop \sol that is equal to 1 if the interval is solution and -1 otherwise (if you can't easily use a boolean).

They both use the curve to operation of the topaths library (see p 748 of manual 3.0.1a).

The first one defines the exit and entry angles of the curve:

to[out=\sol*-60,in=\sol*-120]

The second one uses the controls option:

to [controls=+(-90:1) and +(-90:1)]

First proposal:

first

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[nodes={
   execute at begin node=$,
   execute at end node=$
 }]
\draw[->, thick] (-6,0) -- (5,0) node[above] {x};
\clip(-6,-1)rectangle(4.5,1.5);
\foreach \x/\xpar/\xtext/\sol [remember=\x as \lastx (initially -7)] in {
    -5 / \bullet / -5/1,
    -1 / \bullet / -1/-1,
    0    /  \circ / 1/1,
    1.5  / \bullet  / \frac{3}{2}/1,
    2  / \bullet / 2/-1,
    4  / \circ / 4/1,
    7/\circ/7/-1
}  
{\ifnum \sol=1 
    \draw[thick,pattern=north east lines] (\lastx,0)to[out=\sol*-60,in=\sol*-120](\x,0) node {\xpar}  node[below=5pt] {\xtext};
\else 
    \draw[thick] (\lastx,0)to[out=\sol*-60,in=\sol*-120](\x,0) node {\xpar}  node[below=5pt] {\xtext};
\fi
}
\node[circle,blue,fill=white,draw,inner sep=2pt] at  (0,0) {};
\end{tikzpicture}
\end{document}

Second proposal:

second

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[nodes={
   execute at begin node=$,
   execute at end node=$
 }]
\draw[->, thick] (-6,0) -- (5,0) node[above] {x};
\clip(-6,-1)rectangle(4.5,1.5);
\foreach \x/\xpar/\xtext/\sol [remember=\x as \lastx (initially -7)] in {
    -5 / \bullet / -5/1,
    -1 / \bullet / -1/-1,
    0    /  \circ / 1/1,
    1.5  / \bullet  / \frac{3}{2}/1,
    2  / \bullet / 2/-1,
    4  / \circ / 4/1,
    6/\circ/6/-1
}  
{\ifnum \sol=1 
    \draw[thick,pattern=north east lines] (\lastx,0)to [controls=+(-90:1) and +(-90:1)](\x,0) node {\xpar}  node[below=15pt] {\xtext};
\else 
    \draw[thick] (\lastx,0)to [controls=+(90:1) and +(90:1)](\x,0) node {\xpar}  node[below=15pt] {\xtext};
\fi
}
\node[circle,blue,fill=white,draw,inner sep=2pt] at  (0,0) {};
\end{tikzpicture}
\end{document}

Translated with www.DeepL.com/Translator

1

I take that you want a cartoon, not draw the function (which has poles in this domain).

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[scale=7, nodes={
   execute at begin node=$,
   execute at end node=$
 }]
\draw[->, thick] (-0.8,0) -- (0.8,0) node[above] {x};
\foreach \x/\xpar/\xtext [count=\Z] in {
    -0.5 / \bullet / -5,
    -0.1 / \bullet / -1,
    0    /  \circ / 1,
    0.2  / \bullet  / \frac{3}{2},
    0.3  / \bullet / 2,
    0.6  / \circ / 4
}   \draw[thick] (\x,0pt) coordinate (p-\Z) node {\xpar}  node[below=5pt] {\xtext};
\node[circle,blue,fill=white,draw,inner sep=2pt] at  (0,0) {};
\draw[pattern=north east lines] (-0.8,-0.1) to[out=0,in=-135] (p-1) --(-0.8,0); 
\draw (p-1) to[out=45,in=135] (p-2);
\draw[pattern=north east lines] (p-2) to[out=-45,in=-135,looseness=2] (p-3);
\draw[pattern=north east lines] (p-3) to[out=-45,in=-135,looseness=1.2] (p-4);
\draw (p-4) to[out=45,in=135,looseness=2] (p-5);
\draw[pattern=north east lines] (p-5) to[out=-45,in=-135,looseness=1] (p-6);
\draw (p-6) to[out=45,in=180] ++ (0.2,0.1); 
\end{tikzpicture}
\end{document}

enter image description here

  • There is a little different,not a sine wave rolling up and down – mcmxciv Nov 10 '18 at 15:57
  • @mcmxciv Better now? – user121799 Nov 10 '18 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.