Crosspost: https://tex.stackexchange.com/questions/496897/pgfmath-gnuplot-how-to-use-gnuplot-for-complicated-calculations


Ich habe mich gefragt, ob man gnuplot abgesehen von Graphen auch für schwierige Rechnungen verwenden kann.
Z.B. für \pgfmathsetmacro{\x}{0.02} \pgfmathsetmacro{\y}{2*11000*(1 - 1.40576 - cos(\x) + sqrt(1.40576^2 - sin(\x)^2))}
erhalte ich 'Dimensions to large'.

Wie könnte man hier gnuplot einsetzen?

MWE:

alt text

Code, hier editierbar zum Übersetzen:
% arara: pdflatex: {shell: yes}
\documentclass[margin=5mm, varwidth]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\pgfmathsetmacro{\x}{0.02}
%\pgfmathsetmacro{\y}{2*11000*(1 - 1.40576 - cos(\x) + sqrt(1.40576^2 - sin(\x)^2))}
Geht nicht: % \y
\begin{tikzpicture}
\begin{axis}[title=Geht:]
\addplot[blue,domain = {-0.07:0.07}]plot gnuplot[samples=500,id=eins]{2*11000*(1 - 1.40576 - cos(x) + sqrt(1.40576^2 - sin(x)^2))};
\end{axis}
\end{tikzpicture}
\end{document}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

gefragt 21 Jun '19, 20:16

cis's gravatar image

cis
9.6k103460491
Akzeptiert-Rate: 29%

bearbeitet 22 Jun '19, 10:52


Kurz:

enter image description here

Code, hier editierbar zum Übersetzen:
% arara: pdflatex: {shell: yes}
\documentclass[margin=5mm, varwidth]{standalone}
\usepackage{pgfplots, pgfplotstable}
\pgfplotsset{compat=1.16}
\newsavebox{\mycalc}
% Siehe auch: http://gnuplot.sourceforge.net/docs_4.2/node53.html
\begin{document}
\newcommand\Function[3][fixed,precision=6]{%%%%%%%%%
\sbox{\mycalc}{%%
\begin{tikzpicture}[]
\begin{axis}[]
\addplot[blue,domain = {#3:#3+0.1}] plot gnuplot[id=mycalc]{#2};
%\addplot[blue,domain = {pi:2*pi}] plot gnuplot[id=mycalc]{5};
\end{axis}
\end{tikzpicture}
}%%%
%\usebox{\mycalc}
%
\pgfplotstableread[header=false]{\jobname.mycalc.table}\tempdata%
%\pgfplotstabletypeset[string type]{\tempdata}
%
\pgfplotstablegetelem{0}{1}\of\tempdata
\pgfmathsetmacro\y{\pgfplotsretval}
\pgfmathprintnumber[#1]{\y}%
}%%%%%%%%%%%%%%%
\section{Easy}
$\sin(\frac\pi6) = \Function{sin(x)}{pi/6}$
\section{Difficult}
\newcommand\Curve[1]{2*11000*(1 - 1.40576 - cos(#1) + sqrt(1.40576^2 - sin(#1)^2))
}
\newcommand\curve[1]{2\cdot 11000\cdot \left(1 - 1.40576 - \cos(#1) + \sqrt{1.40576^2 - \sin(#1)^2}\right)}
Let $f(x) =\curve{x}$.
\pgfmathsetmacro\x{0.05}
$f(\x) = \Function{\Curve{x}}{\x}$
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Lang:

enter image description here

Code, hier editierbar zum Übersetzen:
% arara: pdflatex: {shell: yes}
\documentclass[margin=5mm, varwidth]{standalone}
\usepackage{pgfplots, pgfplotstable}
\pgfplotsset{compat=1.16}
\newcommand\Curve[1]{2*11000*(1 - 1.40576 - cos(#1) + sqrt(1.40576^2 - sin(#1)^2))
}
\newcommand\curve[1]{2\cdot 11000\cdot \left(1 - 1.40576 - \cos(#1) + \sqrt{1.40576^2 - \sin(#1)^2}\right)}
\begin{document}
Let $f(x) =\curve{x}$.
\pgfmathsetmacro\x{0.05}
We need $f(\x)$
\newsavebox{\mycalc}
\sbox{\mycalc}{%%%%%%%%%%%%%%%%%
\begin{tikzpicture}[]
\begin{axis}[]
\addplot[blue,domain = {\x:\x+0.1}] plot gnuplot[id=mycalc]{\Curve{x}};
%\addplot[blue,domain = {pi:2*pi}] plot gnuplot[id=mycalc]{5};
\end{axis}
\end{tikzpicture}
}%%%%%%%%%%%%%%%%%%%%%%%
\section{Show graph - for Info}
\usebox{\mycalc}
\section{Show gnuplot-generated table - for Info}
\pgfplotstableread[header=false]{\jobname.mycalc.table}\tempdata
\pgfplotstabletypeset[string type]{\tempdata}
\section{Read out value}
\pgfplotstablegetelem{0}{1}\of\tempdata
%\pgfkeys{/pgf/number format/.cd,sci}
%\pgfkeys{/pgf/number format/.cd,fixed,precision=6}
\pgfmathsetmacro\y{\pgfplotsretval}
$f(\x) = \pgfmathprintnumber[fixed,precision=6]{\y}$
$f(\x) = \pgfmathprintnumber[sci,precision=6]{\y}$
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Permanenter link

beantwortet 30 Jun '19, 18:23

cis's gravatar image

cis
9.6k103460491
Akzeptiert-Rate: 29%

bearbeitet 30 Jun '19, 19:45

Deine Antwort
[Vorschau ausblenden]

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Frage-Themen:

×298
×11

gestellte Frage: 21 Jun '19, 20:16

Frage wurde gesehen: 6,204 Mal

zuletzt geändert: 30 Jun '19, 19:45

Willkommen, erstes Mal hier? Schau mal unter FAQ!

×