Intersection library and Differential approximations












2















Hi everyone I am looking for a smoother program using the intersection library to calculate where the tangent line intersects the vertical line of the x-coordinate of the second coordinate. I have so far:



documentclass{article}
usepackage{tikz}
usepackage{geometry}
usetikzlibrary{decorations.pathreplacing}
usetikzlibrary{intersections}

begin{document}

newcommand*{DeltaX}{0.01}
newcommand*{DrawTangentLabel}[5]{%
% #1 = draw options
% #2 = name of curve
% #3 = ymin
% #4 = ymax
% #5 = x value at which tangent is to be drawn

path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

path [name intersections={of=Vertical Line Left and #2}];
coordinate (X0) at (intersection-1);
path [name intersections={of=Vertical Line Right and #2}];
coordinate (X1) at (intersection-1);

draw [shorten <= -3cm, shorten >= -3cm, #1] (X0) -- (X1) node {$$};
}%

begin{center}
begin{tikzpicture}[scale=1.75,cap=round]
tikzset{axes/.style={}}
%draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
% The graphic
begin{scope}[style=axes]
draw[->] (-.5,0) -- (4.5,0) node[below] {$x$};
draw[->] (0,-.5)-- (0,3) node[left] {$y$};
foreach x/xtext in {2.25/x}
draw[xshift=x cm] (0pt,2pt) -- (0pt,-2pt)
node[below,fill=white,font=normalsize]
{$xtext$};
%%%
draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick]
plot ({x},{.5*(x-1.5)*(x-1.5)+1});
DrawTangentLabel[red,thick,<->]{curve}{-1}{3}{2.25}
draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick] plot ({x},{.5*(x-1.5)*(x-1.5)+1});
%%%
filldraw[black] (2.25,1.28125) circle (1pt) node {$$};
filldraw[black] (3,1.28125) circle (1pt) node {$$};
filldraw[black] (3,2.125) circle (1pt) node {$$};
filldraw[black] (3,1.775) circle (1pt) node {$$};%%Found by slope formula then trial and error
%%%
draw[dashed] (2.25,1.28125)--(3,1.28125);
draw[dashed] (3,2.125)--(3,1.28125);
draw[dashed] (2.9,1.28125)--(2.9,1.38125)--(3,1.38125);
%%%
draw[decoration={brace,raise=5pt},decorate,thick]
(4,2.125) -- node[right=6pt] {textcolor{blue}{$Delta y$}} (4,1.28125);
draw[dashed] (4,2.125)--(3,2.125);
draw[dashed] (4,1.28125)--(3,1.28125);
draw[decoration={brace,mirror,raise=5pt},decorate,thick]
(2.25,1.28125) -- node[below=6pt] {textcolor{blue}{$Delta x$}}
(3,1.28125);
draw[dashed] (2.25,1.28125)--(2.25,0);
node at (.75,1.75) {$y=f(x)$};
%%%
filldraw[black] (3,2.125) circle (1pt) node[left] {};
end{scope}
end{tikzpicture}
end{center}

end{document}


This outputs:



enter image description here



I would like tikz to calculate the point rather than an estimate.










share|improve this question





























    2















    Hi everyone I am looking for a smoother program using the intersection library to calculate where the tangent line intersects the vertical line of the x-coordinate of the second coordinate. I have so far:



    documentclass{article}
    usepackage{tikz}
    usepackage{geometry}
    usetikzlibrary{decorations.pathreplacing}
    usetikzlibrary{intersections}

    begin{document}

    newcommand*{DeltaX}{0.01}
    newcommand*{DrawTangentLabel}[5]{%
    % #1 = draw options
    % #2 = name of curve
    % #3 = ymin
    % #4 = ymax
    % #5 = x value at which tangent is to be drawn

    path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
    path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

    path [name intersections={of=Vertical Line Left and #2}];
    coordinate (X0) at (intersection-1);
    path [name intersections={of=Vertical Line Right and #2}];
    coordinate (X1) at (intersection-1);

    draw [shorten <= -3cm, shorten >= -3cm, #1] (X0) -- (X1) node {$$};
    }%

    begin{center}
    begin{tikzpicture}[scale=1.75,cap=round]
    tikzset{axes/.style={}}
    %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
    % The graphic
    begin{scope}[style=axes]
    draw[->] (-.5,0) -- (4.5,0) node[below] {$x$};
    draw[->] (0,-.5)-- (0,3) node[left] {$y$};
    foreach x/xtext in {2.25/x}
    draw[xshift=x cm] (0pt,2pt) -- (0pt,-2pt)
    node[below,fill=white,font=normalsize]
    {$xtext$};
    %%%
    draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick]
    plot ({x},{.5*(x-1.5)*(x-1.5)+1});
    DrawTangentLabel[red,thick,<->]{curve}{-1}{3}{2.25}
    draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick] plot ({x},{.5*(x-1.5)*(x-1.5)+1});
    %%%
    filldraw[black] (2.25,1.28125) circle (1pt) node {$$};
    filldraw[black] (3,1.28125) circle (1pt) node {$$};
    filldraw[black] (3,2.125) circle (1pt) node {$$};
    filldraw[black] (3,1.775) circle (1pt) node {$$};%%Found by slope formula then trial and error
    %%%
    draw[dashed] (2.25,1.28125)--(3,1.28125);
    draw[dashed] (3,2.125)--(3,1.28125);
    draw[dashed] (2.9,1.28125)--(2.9,1.38125)--(3,1.38125);
    %%%
    draw[decoration={brace,raise=5pt},decorate,thick]
    (4,2.125) -- node[right=6pt] {textcolor{blue}{$Delta y$}} (4,1.28125);
    draw[dashed] (4,2.125)--(3,2.125);
    draw[dashed] (4,1.28125)--(3,1.28125);
    draw[decoration={brace,mirror,raise=5pt},decorate,thick]
    (2.25,1.28125) -- node[below=6pt] {textcolor{blue}{$Delta x$}}
    (3,1.28125);
    draw[dashed] (2.25,1.28125)--(2.25,0);
    node at (.75,1.75) {$y=f(x)$};
    %%%
    filldraw[black] (3,2.125) circle (1pt) node[left] {};
    end{scope}
    end{tikzpicture}
    end{center}

    end{document}


    This outputs:



    enter image description here



    I would like tikz to calculate the point rather than an estimate.










    share|improve this question



























      2












      2








      2








      Hi everyone I am looking for a smoother program using the intersection library to calculate where the tangent line intersects the vertical line of the x-coordinate of the second coordinate. I have so far:



      documentclass{article}
      usepackage{tikz}
      usepackage{geometry}
      usetikzlibrary{decorations.pathreplacing}
      usetikzlibrary{intersections}

      begin{document}

      newcommand*{DeltaX}{0.01}
      newcommand*{DrawTangentLabel}[5]{%
      % #1 = draw options
      % #2 = name of curve
      % #3 = ymin
      % #4 = ymax
      % #5 = x value at which tangent is to be drawn

      path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
      path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

      path [name intersections={of=Vertical Line Left and #2}];
      coordinate (X0) at (intersection-1);
      path [name intersections={of=Vertical Line Right and #2}];
      coordinate (X1) at (intersection-1);

      draw [shorten <= -3cm, shorten >= -3cm, #1] (X0) -- (X1) node {$$};
      }%

      begin{center}
      begin{tikzpicture}[scale=1.75,cap=round]
      tikzset{axes/.style={}}
      %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
      % The graphic
      begin{scope}[style=axes]
      draw[->] (-.5,0) -- (4.5,0) node[below] {$x$};
      draw[->] (0,-.5)-- (0,3) node[left] {$y$};
      foreach x/xtext in {2.25/x}
      draw[xshift=x cm] (0pt,2pt) -- (0pt,-2pt)
      node[below,fill=white,font=normalsize]
      {$xtext$};
      %%%
      draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick]
      plot ({x},{.5*(x-1.5)*(x-1.5)+1});
      DrawTangentLabel[red,thick,<->]{curve}{-1}{3}{2.25}
      draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick] plot ({x},{.5*(x-1.5)*(x-1.5)+1});
      %%%
      filldraw[black] (2.25,1.28125) circle (1pt) node {$$};
      filldraw[black] (3,1.28125) circle (1pt) node {$$};
      filldraw[black] (3,2.125) circle (1pt) node {$$};
      filldraw[black] (3,1.775) circle (1pt) node {$$};%%Found by slope formula then trial and error
      %%%
      draw[dashed] (2.25,1.28125)--(3,1.28125);
      draw[dashed] (3,2.125)--(3,1.28125);
      draw[dashed] (2.9,1.28125)--(2.9,1.38125)--(3,1.38125);
      %%%
      draw[decoration={brace,raise=5pt},decorate,thick]
      (4,2.125) -- node[right=6pt] {textcolor{blue}{$Delta y$}} (4,1.28125);
      draw[dashed] (4,2.125)--(3,2.125);
      draw[dashed] (4,1.28125)--(3,1.28125);
      draw[decoration={brace,mirror,raise=5pt},decorate,thick]
      (2.25,1.28125) -- node[below=6pt] {textcolor{blue}{$Delta x$}}
      (3,1.28125);
      draw[dashed] (2.25,1.28125)--(2.25,0);
      node at (.75,1.75) {$y=f(x)$};
      %%%
      filldraw[black] (3,2.125) circle (1pt) node[left] {};
      end{scope}
      end{tikzpicture}
      end{center}

      end{document}


      This outputs:



      enter image description here



      I would like tikz to calculate the point rather than an estimate.










      share|improve this question
















      Hi everyone I am looking for a smoother program using the intersection library to calculate where the tangent line intersects the vertical line of the x-coordinate of the second coordinate. I have so far:



      documentclass{article}
      usepackage{tikz}
      usepackage{geometry}
      usetikzlibrary{decorations.pathreplacing}
      usetikzlibrary{intersections}

      begin{document}

      newcommand*{DeltaX}{0.01}
      newcommand*{DrawTangentLabel}[5]{%
      % #1 = draw options
      % #2 = name of curve
      % #3 = ymin
      % #4 = ymax
      % #5 = x value at which tangent is to be drawn

      path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
      path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

      path [name intersections={of=Vertical Line Left and #2}];
      coordinate (X0) at (intersection-1);
      path [name intersections={of=Vertical Line Right and #2}];
      coordinate (X1) at (intersection-1);

      draw [shorten <= -3cm, shorten >= -3cm, #1] (X0) -- (X1) node {$$};
      }%

      begin{center}
      begin{tikzpicture}[scale=1.75,cap=round]
      tikzset{axes/.style={}}
      %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
      % The graphic
      begin{scope}[style=axes]
      draw[->] (-.5,0) -- (4.5,0) node[below] {$x$};
      draw[->] (0,-.5)-- (0,3) node[left] {$y$};
      foreach x/xtext in {2.25/x}
      draw[xshift=x cm] (0pt,2pt) -- (0pt,-2pt)
      node[below,fill=white,font=normalsize]
      {$xtext$};
      %%%
      draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick]
      plot ({x},{.5*(x-1.5)*(x-1.5)+1});
      DrawTangentLabel[red,thick,<->]{curve}{-1}{3}{2.25}
      draw[name path=curve, domain=.5:3.25,smooth,variable=x,black,<->,thick] plot ({x},{.5*(x-1.5)*(x-1.5)+1});
      %%%
      filldraw[black] (2.25,1.28125) circle (1pt) node {$$};
      filldraw[black] (3,1.28125) circle (1pt) node {$$};
      filldraw[black] (3,2.125) circle (1pt) node {$$};
      filldraw[black] (3,1.775) circle (1pt) node {$$};%%Found by slope formula then trial and error
      %%%
      draw[dashed] (2.25,1.28125)--(3,1.28125);
      draw[dashed] (3,2.125)--(3,1.28125);
      draw[dashed] (2.9,1.28125)--(2.9,1.38125)--(3,1.38125);
      %%%
      draw[decoration={brace,raise=5pt},decorate,thick]
      (4,2.125) -- node[right=6pt] {textcolor{blue}{$Delta y$}} (4,1.28125);
      draw[dashed] (4,2.125)--(3,2.125);
      draw[dashed] (4,1.28125)--(3,1.28125);
      draw[decoration={brace,mirror,raise=5pt},decorate,thick]
      (2.25,1.28125) -- node[below=6pt] {textcolor{blue}{$Delta x$}}
      (3,1.28125);
      draw[dashed] (2.25,1.28125)--(2.25,0);
      node at (.75,1.75) {$y=f(x)$};
      %%%
      filldraw[black] (3,2.125) circle (1pt) node[left] {};
      end{scope}
      end{tikzpicture}
      end{center}

      end{document}


      This outputs:



      enter image description here



      I would like tikz to calculate the point rather than an estimate.







      tikz-pgf intersections






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago







      MathScholar

















      asked 3 hours ago









      MathScholarMathScholar

      68818




      68818






















          1 Answer
          1






          active

          oldest

          votes


















          4














          If you instead of shorten use the syntax of the calc library to draw the tangent line, you can use the intersections library to find the intersection.



          enter image description here



          documentclass{article}
          usepackage{tikz}
          usetikzlibrary{decorations.pathreplacing}
          usetikzlibrary{calc} % <-- added
          usetikzlibrary{intersections}

          begin{document}

          newcommand*{DeltaX}{0.01}
          newcommand*{DrawTangentLabel}[5]{%
          % #1 = draw options
          % #2 = name of curve
          % #3 = ymin
          % #4 = ymax
          % #5 = x value at which tangent is to be drawn

          path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
          path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

          path [name intersections={of=Vertical Line Left and #2}];
          coordinate (X0) at (intersection-1);
          path [name intersections={of=Vertical Line Right and #2}];
          coordinate (X1) at (intersection-1);

          draw [#1] ($(X0)!-2cm!(X1)$) -- ($(X1)!-2cm!(X0)$); % <-- modified
          }%

          begin{center}
          begin{tikzpicture}[
          scale=1.75,
          cap=round,
          axes/.style={->},
          declare function={f(x)=.5*(x-1.5)*(x-1.5)+1;} % <-- added
          ]
          %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
          % The graphic

          draw[axes] (-.5,0) -- (4.5,0) node[below] {$x$};
          draw[axes] (0,-.5)-- (0,3) node[left] {$y$};

          foreach x/xtext in {2.25/x}
          draw (x,2pt) -- (x,-2pt) node[below,fill=white,font=normalsize] {$xtext$};


          draw[name path=curve, domain=.5:3.25,smooth,<->,thick] plot ({x},{f(x)});

          DrawTangentLabel[red,thick,<->, name path=tangent]{curve}{-1}{3}{2.25}

          foreach [count=i] x in {2.25,3}
          filldraw (x,{f(x)}) circle[radius=1pt] coordinate(ni);

          draw [dashed,name path=dash] (n1) -| coordinate (n3) (n2);
          filldraw (n3) circle[radius=1pt];

          fill[name intersections={of=dash and tangent}] (intersection-1) circle[radius=1pt];


          draw[decoration={brace,raise=5pt},decorate,thick] (n2 -| 4,0) -- node[right=6pt,blue] {$Delta y$} (n3 -| 4,0);
          draw[decoration={brace,mirror,raise=5pt},decorate,thick] (n1) -- node[below=6pt,blue] {$Delta x$} (n3);

          draw[dashed] (n1) -- (n1 |- 0,0)
          (n2) -- (n2 -| 4,0)
          (n3) -- (n3 -| 4,0);

          node [above]at (.5,{f(.5)}) {$y=f(x)$};
          %%%

          end{tikzpicture}
          end{center}

          end{document}





          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471557%2fintersection-library-and-differential-approximations%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            If you instead of shorten use the syntax of the calc library to draw the tangent line, you can use the intersections library to find the intersection.



            enter image description here



            documentclass{article}
            usepackage{tikz}
            usetikzlibrary{decorations.pathreplacing}
            usetikzlibrary{calc} % <-- added
            usetikzlibrary{intersections}

            begin{document}

            newcommand*{DeltaX}{0.01}
            newcommand*{DrawTangentLabel}[5]{%
            % #1 = draw options
            % #2 = name of curve
            % #3 = ymin
            % #4 = ymax
            % #5 = x value at which tangent is to be drawn

            path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
            path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

            path [name intersections={of=Vertical Line Left and #2}];
            coordinate (X0) at (intersection-1);
            path [name intersections={of=Vertical Line Right and #2}];
            coordinate (X1) at (intersection-1);

            draw [#1] ($(X0)!-2cm!(X1)$) -- ($(X1)!-2cm!(X0)$); % <-- modified
            }%

            begin{center}
            begin{tikzpicture}[
            scale=1.75,
            cap=round,
            axes/.style={->},
            declare function={f(x)=.5*(x-1.5)*(x-1.5)+1;} % <-- added
            ]
            %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
            % The graphic

            draw[axes] (-.5,0) -- (4.5,0) node[below] {$x$};
            draw[axes] (0,-.5)-- (0,3) node[left] {$y$};

            foreach x/xtext in {2.25/x}
            draw (x,2pt) -- (x,-2pt) node[below,fill=white,font=normalsize] {$xtext$};


            draw[name path=curve, domain=.5:3.25,smooth,<->,thick] plot ({x},{f(x)});

            DrawTangentLabel[red,thick,<->, name path=tangent]{curve}{-1}{3}{2.25}

            foreach [count=i] x in {2.25,3}
            filldraw (x,{f(x)}) circle[radius=1pt] coordinate(ni);

            draw [dashed,name path=dash] (n1) -| coordinate (n3) (n2);
            filldraw (n3) circle[radius=1pt];

            fill[name intersections={of=dash and tangent}] (intersection-1) circle[radius=1pt];


            draw[decoration={brace,raise=5pt},decorate,thick] (n2 -| 4,0) -- node[right=6pt,blue] {$Delta y$} (n3 -| 4,0);
            draw[decoration={brace,mirror,raise=5pt},decorate,thick] (n1) -- node[below=6pt,blue] {$Delta x$} (n3);

            draw[dashed] (n1) -- (n1 |- 0,0)
            (n2) -- (n2 -| 4,0)
            (n3) -- (n3 -| 4,0);

            node [above]at (.5,{f(.5)}) {$y=f(x)$};
            %%%

            end{tikzpicture}
            end{center}

            end{document}





            share|improve this answer






























              4














              If you instead of shorten use the syntax of the calc library to draw the tangent line, you can use the intersections library to find the intersection.



              enter image description here



              documentclass{article}
              usepackage{tikz}
              usetikzlibrary{decorations.pathreplacing}
              usetikzlibrary{calc} % <-- added
              usetikzlibrary{intersections}

              begin{document}

              newcommand*{DeltaX}{0.01}
              newcommand*{DrawTangentLabel}[5]{%
              % #1 = draw options
              % #2 = name of curve
              % #3 = ymin
              % #4 = ymax
              % #5 = x value at which tangent is to be drawn

              path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
              path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

              path [name intersections={of=Vertical Line Left and #2}];
              coordinate (X0) at (intersection-1);
              path [name intersections={of=Vertical Line Right and #2}];
              coordinate (X1) at (intersection-1);

              draw [#1] ($(X0)!-2cm!(X1)$) -- ($(X1)!-2cm!(X0)$); % <-- modified
              }%

              begin{center}
              begin{tikzpicture}[
              scale=1.75,
              cap=round,
              axes/.style={->},
              declare function={f(x)=.5*(x-1.5)*(x-1.5)+1;} % <-- added
              ]
              %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
              % The graphic

              draw[axes] (-.5,0) -- (4.5,0) node[below] {$x$};
              draw[axes] (0,-.5)-- (0,3) node[left] {$y$};

              foreach x/xtext in {2.25/x}
              draw (x,2pt) -- (x,-2pt) node[below,fill=white,font=normalsize] {$xtext$};


              draw[name path=curve, domain=.5:3.25,smooth,<->,thick] plot ({x},{f(x)});

              DrawTangentLabel[red,thick,<->, name path=tangent]{curve}{-1}{3}{2.25}

              foreach [count=i] x in {2.25,3}
              filldraw (x,{f(x)}) circle[radius=1pt] coordinate(ni);

              draw [dashed,name path=dash] (n1) -| coordinate (n3) (n2);
              filldraw (n3) circle[radius=1pt];

              fill[name intersections={of=dash and tangent}] (intersection-1) circle[radius=1pt];


              draw[decoration={brace,raise=5pt},decorate,thick] (n2 -| 4,0) -- node[right=6pt,blue] {$Delta y$} (n3 -| 4,0);
              draw[decoration={brace,mirror,raise=5pt},decorate,thick] (n1) -- node[below=6pt,blue] {$Delta x$} (n3);

              draw[dashed] (n1) -- (n1 |- 0,0)
              (n2) -- (n2 -| 4,0)
              (n3) -- (n3 -| 4,0);

              node [above]at (.5,{f(.5)}) {$y=f(x)$};
              %%%

              end{tikzpicture}
              end{center}

              end{document}





              share|improve this answer




























                4












                4








                4







                If you instead of shorten use the syntax of the calc library to draw the tangent line, you can use the intersections library to find the intersection.



                enter image description here



                documentclass{article}
                usepackage{tikz}
                usetikzlibrary{decorations.pathreplacing}
                usetikzlibrary{calc} % <-- added
                usetikzlibrary{intersections}

                begin{document}

                newcommand*{DeltaX}{0.01}
                newcommand*{DrawTangentLabel}[5]{%
                % #1 = draw options
                % #2 = name of curve
                % #3 = ymin
                % #4 = ymax
                % #5 = x value at which tangent is to be drawn

                path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
                path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

                path [name intersections={of=Vertical Line Left and #2}];
                coordinate (X0) at (intersection-1);
                path [name intersections={of=Vertical Line Right and #2}];
                coordinate (X1) at (intersection-1);

                draw [#1] ($(X0)!-2cm!(X1)$) -- ($(X1)!-2cm!(X0)$); % <-- modified
                }%

                begin{center}
                begin{tikzpicture}[
                scale=1.75,
                cap=round,
                axes/.style={->},
                declare function={f(x)=.5*(x-1.5)*(x-1.5)+1;} % <-- added
                ]
                %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
                % The graphic

                draw[axes] (-.5,0) -- (4.5,0) node[below] {$x$};
                draw[axes] (0,-.5)-- (0,3) node[left] {$y$};

                foreach x/xtext in {2.25/x}
                draw (x,2pt) -- (x,-2pt) node[below,fill=white,font=normalsize] {$xtext$};


                draw[name path=curve, domain=.5:3.25,smooth,<->,thick] plot ({x},{f(x)});

                DrawTangentLabel[red,thick,<->, name path=tangent]{curve}{-1}{3}{2.25}

                foreach [count=i] x in {2.25,3}
                filldraw (x,{f(x)}) circle[radius=1pt] coordinate(ni);

                draw [dashed,name path=dash] (n1) -| coordinate (n3) (n2);
                filldraw (n3) circle[radius=1pt];

                fill[name intersections={of=dash and tangent}] (intersection-1) circle[radius=1pt];


                draw[decoration={brace,raise=5pt},decorate,thick] (n2 -| 4,0) -- node[right=6pt,blue] {$Delta y$} (n3 -| 4,0);
                draw[decoration={brace,mirror,raise=5pt},decorate,thick] (n1) -- node[below=6pt,blue] {$Delta x$} (n3);

                draw[dashed] (n1) -- (n1 |- 0,0)
                (n2) -- (n2 -| 4,0)
                (n3) -- (n3 -| 4,0);

                node [above]at (.5,{f(.5)}) {$y=f(x)$};
                %%%

                end{tikzpicture}
                end{center}

                end{document}





                share|improve this answer















                If you instead of shorten use the syntax of the calc library to draw the tangent line, you can use the intersections library to find the intersection.



                enter image description here



                documentclass{article}
                usepackage{tikz}
                usetikzlibrary{decorations.pathreplacing}
                usetikzlibrary{calc} % <-- added
                usetikzlibrary{intersections}

                begin{document}

                newcommand*{DeltaX}{0.01}
                newcommand*{DrawTangentLabel}[5]{%
                % #1 = draw options
                % #2 = name of curve
                % #3 = ymin
                % #4 = ymax
                % #5 = x value at which tangent is to be drawn

                path[name path=Vertical Line Left] (#5-DeltaX,#3) -- (#5-DeltaX,#4);
                path[name path=Vertical Line Right] (#5+DeltaX,#3) -- (#5+DeltaX,#4);

                path [name intersections={of=Vertical Line Left and #2}];
                coordinate (X0) at (intersection-1);
                path [name intersections={of=Vertical Line Right and #2}];
                coordinate (X1) at (intersection-1);

                draw [#1] ($(X0)!-2cm!(X1)$) -- ($(X1)!-2cm!(X0)$); % <-- modified
                }%

                begin{center}
                begin{tikzpicture}[
                scale=1.75,
                cap=round,
                axes/.style={->},
                declare function={f(x)=.5*(x-1.5)*(x-1.5)+1;} % <-- added
                ]
                %draw[style=help lines,step=1cm, dotted] (-5.25,-5.25) grid (5.25,5.25);
                % The graphic

                draw[axes] (-.5,0) -- (4.5,0) node[below] {$x$};
                draw[axes] (0,-.5)-- (0,3) node[left] {$y$};

                foreach x/xtext in {2.25/x}
                draw (x,2pt) -- (x,-2pt) node[below,fill=white,font=normalsize] {$xtext$};


                draw[name path=curve, domain=.5:3.25,smooth,<->,thick] plot ({x},{f(x)});

                DrawTangentLabel[red,thick,<->, name path=tangent]{curve}{-1}{3}{2.25}

                foreach [count=i] x in {2.25,3}
                filldraw (x,{f(x)}) circle[radius=1pt] coordinate(ni);

                draw [dashed,name path=dash] (n1) -| coordinate (n3) (n2);
                filldraw (n3) circle[radius=1pt];

                fill[name intersections={of=dash and tangent}] (intersection-1) circle[radius=1pt];


                draw[decoration={brace,raise=5pt},decorate,thick] (n2 -| 4,0) -- node[right=6pt,blue] {$Delta y$} (n3 -| 4,0);
                draw[decoration={brace,mirror,raise=5pt},decorate,thick] (n1) -- node[below=6pt,blue] {$Delta x$} (n3);

                draw[dashed] (n1) -- (n1 |- 0,0)
                (n2) -- (n2 -| 4,0)
                (n3) -- (n3 -| 4,0);

                node [above]at (.5,{f(.5)}) {$y=f(x)$};
                %%%

                end{tikzpicture}
                end{center}

                end{document}






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 2 hours ago

























                answered 2 hours ago









                Torbjørn T.Torbjørn T.

                156k13251438




                156k13251438






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471557%2fintersection-library-and-differential-approximations%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    الفوسفات في المغرب

                    Four equal circles intersect: What is the area of the small shaded portion and its height

                    بطل الاتحاد السوفيتي