-5

How can I create a graph of acceleration and speed like the one in the picture. Knowing that they are each other's consequence?

enter image description here

\documentclass{article} \usepackage{tikz}

\begin{document}
 \begin{tikzpicture}



           \end{tikzpicture}
\end{document}
  • Do you have the equations? – Alenanno Apr 10 '16 at 12:58
  • @Alenanno No, I don't because they are theoretical graphs –  Apr 10 '16 at 13:03
  • From the picture, If one is allowed to guess that the acceleration is a straight line, then the equations do exist viz a(t) = c - mt, v(t) = v(0) + ct - mt^2/2 etc. Just find by trial and error, good values for c and m so that the picture looks good. If the shape of acceleration is not a straight line, then one would have to do symbolic or numerical integration to make the pictures consistent. – AJN Apr 10 '16 at 13:10
  • @Ilmionome456 In that case, you can use simple curves and paths, although it might require some more trial and error. – Alenanno Apr 10 '16 at 13:16
  • 2
    -1: This exact question has been asked by you before; Graphs of the motions - physical, and you have been on the site long enough to understand how this community works. – sodd Apr 10 '16 at 13:20
  • @cfr This one has an answer the other one doesn't – percusse Apr 10 '16 at 13:32
  • @percusse I am aware that you posted an answer at the same time I closed it as a duplicate. That is precisely why I flagged it. – cfr Apr 10 '16 at 18:35

1 Answers1

6

For simple and very smooth curves you can fake a simple derivative action as in Derivative of a tikz path? However TeX is not the place to do these CAS computations. If you have the closed form curves then you can plug the formulas into pgfplots otherwise it will always fail at some point.

\documentclass[tikz]{standalone}
\pgfdeclaredecoration{approxderiv}{initial}{%
\state{initial}[width=0.01mm,
                persistent postcomputation={%
                    \def\tempa{0}%
                    \pgfmathsetmacro{\plen}{(\pgfdecoratedpathlength-0.01mm)/500}%
                    \def\myderivlist{}%
                },next state=walkthecurve]{}%do nothing
\state{walkthecurve}[width=\plen pt,
               persistent postcomputation={%
                  \pgfmathparse{(sin(\pgfdecoratedangle))}\xdef\tempb{\pgfmathresult}%
                  \pgfmathparse{abs(cos(\pgfdecoratedangle))*\plen}%
                  \expandafter\xdef\expandafter\myderivlist\expandafter{%
                     \myderivlist --++ ({\pgfmathresult pt},{(\tempb-\tempa)*(1cm)})%
                    }%
                  \xdef\tempa{\tempb}%
               }
            ]{}%do nothing
}

\begin{document}
\begin{tikzpicture}
\draw[style=help lines] (0,-7) grid[step=5mm] (6,2.5);
\draw[decoration=approxderiv,postaction={decorate}] (0,0) ..controls (2,2) and (1,1) .. (3,0);
\draw[red,decoration=approxderiv,postaction={decorate}] (0,-3) \myderivlist;
\draw[blue] (0,-6) \myderivlist;
\end{tikzpicture}
\end{document}

enter image description here

percusse
  • 157,807