2

I'm trying to have the a silimiar plot to the one Wolfram Alpha provides me here to the equation

$24.6347 \left(246.347 x + \sqrt{(246.347 x + 20)^2 + 1} + 20\right)^{-a} =\ 30.2879 \left(-33.6532 x + \sqrt{x (1132.54 x - 20191.9) + 90001} + 300\right)^{-a}$

for $a>0$. This equation however has no closed form solution for x in terms of a so I don't know how to achieve such a plot.

Minimal "Working" Example:

\documentclass[11pt,a4paper]{scrartcl}
\usepackage{pgfplots}
 \pgfplotsset{compat=newest}
 \begin{document}
 \begin{tikzpicture}


\begin{axis}[xlabel=a ,
    ylabel = x,
     xmin=0, xmax=10,
    ymin=0,ymax=1]
  \addplot [
    domain=0:10, 
    samples=500, 
    color=blue,
    ]
    {24.6347*(246.347*x+sqrt((246.347*x+20)^2+1)+20)^(-a)=30.2879*(-33.6532*x+ sqrt(x*(1132.54*x-20191.9)+90001)+300)^(-a)}; 
%switched the variables because gnuplot requires the variable x as input as far as i know
\end{axis}
\end{tikzpicture}
\end{document}
4

AFAIK you cannot really produce implicit plots but you can produce contour plots, which have the same information. So instead of plotting the solutions of A=B one plots the contours of A-B=0. You need to run with -shell-escape since this needs gnuplot (which your above example didn't need).

\documentclass[11pt,a4paper]{scrartcl}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={0}{90},ylabel=$a$,
    xlabel=$x$,xmin=0, xmax=1,ymin=0,ymax=1]
    \addplot3 [contour gnuplot={levels=0,labels=false},
        domain=0:1,domain y=0:1] 
        {24.6347*(246.347*x+sqrt((246.347*x+20)^2+1)+20)^(-y)
    -30.2879*(-33.6532*x+ sqrt(x*(1132.54*x-20191.9)+90001)+300)^(-y)}; 
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

In order to reproduce the Wolfram alpha plot you need to switch x and y back, and adjust the domains.

  • This is not working for me. I get the error message ..._contourtmp0.table could not be opened. Normal gnuplots are working fine though. – Paul Ostmann Jul 9 '19 at 15:02
  • Your example is now working (no idea what fixed it). How would I go about adding a straight line at a=0.8 in your example? – Paul Ostmann Jul 9 '19 at 16:02
  • @PaulOstmann I do not know what caused your problems but the straight line is as easy as saying \draw (0,0.8) -- (1,0.8); inside the axis environment. (It is a bit of a cheat since these are technically 3d coordinates but works.) – user121799 Jul 9 '19 at 17:01
  • I found another solution myself: I simply added another contour plot {y-1}(I initially said 0.8 because your solution has the standard domain with y<=1) but now im stuck on trying to add a third plot: the difference of the 2 functions by which I mean 1 - the function in my post. It's supposed to look like this: imgur link – Paul Ostmann Jul 9 '19 at 17:08
  • @PaulOstmann With your function you mean the difference the contour plot is using? And yes, \addplot also works. Does ` \addplot3 [contour gnuplot={levels=0,labels=false}, domain=0:1,domain y=0:1] {1-24.6347*(246.347*x+sqrt((246.347*x+20)^2+1)+20)^(-y) +30.2879*(-33.6532*x+ sqrt(x*(1132.54*x-20191.9)+90001)+300)^(-y)};` work for you? – user121799 Jul 9 '19 at 17:14
3

Actually, it does have a closed form solution, at least for a as a function of x.

latex equations

  • Honestly I'd prefer your solution. This is just a closed-form plot. – polkovnikov.ph Jul 9 '19 at 22:36
2

run with xelatex:

\documentclass{article}
\usepackage{pst-func}
\begin{document}

\psset{xunit=0.75}
\begin{pspicture}(-2,-1)(20,6)
\psaxes[Dx=2]{->}(0,0)(-2,-0.5)(18,5)[$a$,0][$x$,90]
\rput[lb](0,0){%
  \pspicture*(0.1,0.1)(16,6)
  \psplotImp[algebraic,linecolor=red,linewidth=1.5pt](0.05,0.05)(20,6){
    24.6347*(246.347*y + sqrt((246.347*y + 20)^2 + 1) + 20)^(-x)- 
    30.2879*(-33.6532*y + sqrt(y*(1132.54*y - 20191.9) + 90001) + 300)^(-x)}
  \endpspicture}
\end{pspicture}

\end{document}

enter image description here

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.