1

Is it possible to draw different curves in different quadrants using TikZ? For example:

$|x|^p+|y|^p=1$ in first and third quadrant and $|x|^q+|y|^q=1$ in second and fourth quadrant, for any fixed real number $p$ and $q$.

2
  • Welcome again!! I suppose that you second curve is $|x|^q+|y|^q=1$, and I took the liberty of edit you question. Please, revert it if I am wrong. Commented Dec 2, 2021 at 11:04
  • Absolutely okkay!Thank you@JuanCastaño
    – pmun
    Commented Dec 2, 2021 at 11:17

1 Answer 1

4

Welcome to TeX.SE!!!

Yes it's possible. You can draw each 'piece' in a different plot as in my example, defining the functions (I did it with only one that takes two variables) and the domains.

Something like this:

\documentclass[border=2mm,tikz]{standalone}

\begin{document}
\begin{tikzpicture}[samples=201,line cap=round]
  \def\func(#1,#2){(1-abs(#1)^#2)^(1/#2)}
  \def\p{2.5}
  \def\q{0.5}
  \draw[->] (-2, 0) -- (2, 0) node[right] {$x$};
  \draw[->] (0, -2) -- (0, 2) node[above] {$y$};
  \draw[domain= 1: 0,blue] plot ( \x,{ \func(\x,\p)});
  \draw[domain=-1: 0,blue] plot ( \x,{-\func(\x,\p)});
  \draw[domain= 0: 1,red]  plot (-\x,{ \func(\x,\q)});
  \draw[domain= 0:-1,red]  plot (-\x,{-\func(\x,\q)});
  \node[blue] at  (1.5,1.5) {$p=\p$};
  \node[red]  at (-1.5,1.5) {$q=\q$};
\end{tikzpicture}
\end{document}

will produce: enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .