Math & Sciencemultido | Endpoint Approximations under Curves

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
mmdailey
Posts: 1
Joined: Wed Nov 09, 2011 9:32 pm

multido | Endpoint Approximations under Curves

Post by mmdailey »

I'm trying to type up examples of right endpoint approximations of area under curves and I would like to be able to use multido to create the rectangles.

What I would love is for the code below to work. It is creating 6 rectangles using right endpoints for f(x) = 2x + 3 on the interval [0,3].

Code: Select all

\psset{xunit=.5cm, yunit=.5cm, algebraic=true, plotpoints=10000}
\begin{pspicture}(-10,-5)(5, 10)
\psgrid[subgriddiv=1,griddots=10,gridlabels=0pt, gridcolor=gray](0,0)(-10,-5)(5, 10)
\multido{\n=0+0.5}{6}{
        \psline(\n,0)(\n, 2*\n +3)
        \psline(\n, 2*\n+3)(\n+0.5, 2*\n +3) 
        \psline(\n+0.5, 0)
        }
\end{pspicture} 
Is there an easy way to do this? Thanks.
Last edited by localghost on Tue Nov 15, 2011 11:39 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply