Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected behavior of atan2 #449

Open
nicogallice opened this issue Dec 5, 2022 · 0 comments
Open

unexpected behavior of atan2 #449

nicogallice opened this issue Dec 5, 2022 · 0 comments

Comments

@nicogallice
Copy link

Hi I'd like to draw some Bode-like plots,
the atan2() function seems to not work correctly at some combination of values.
I managed to re-create the minimal working code to show the problem:

I am using atan2() function with a non trivial dependence on x and some parameters defined as declare function=

  • \addplot[red, domain=1e1:1e10, samples=1000] {-atan2(x/wo,(1 - x*x/wo/wo))}; gives an expected behavior up to some point (red curve);
  • \addplot[domain=1e1:1e7, samples=1000] {-atan2(x/wo/Q,(1 - x*x/wo/wo))}; does not seem reliable (black);
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
	\begin{tikzpicture}[
		declare function={
			d=0.9;
			Rl=100e3;
			L=200e-6;
			C=400e-9;
			wo= (1-d)/sqrt(L*C);
			Q=wo*Rl*C;
		}
	]
		\begin{axis}[xmode=log]
            \addplot[domain=1e1:1e7, samples=1000] {-atan2(x/wo/Q,(1 - x*x/wo/wo))};
            \addplot[red, domain=1e1:1e10, samples=1000] {-atan2(x/wo,(1 - x*x/wo/wo))};
		\end{axis}
	\end{tikzpicture}

\end{document}

The following plot is informative of the problem:
prova_pages-to-jpg-0001

I am compiling with pdflatex (plot produced on overleaf but reproducible on my PC).

@nicogallice nicogallice changed the title unexpected behavior of atan2 for high values unexpected behavior of atan2 Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant