Menu

#4 derivative & anti-derivative

open
nobody
None
5
2003-10-13
2003-10-13
Anonymous
No

need feature to display derivative and anti-derivative as
a function

i know this is gonna be really hard, cuz i can't even do it
w/ a brain, and some functions can't be integrated(or
find its anti-derivative), so... gonna need lots work from
the devels

thx

Discussion

  • Mike Arrison

    Mike Arrison - 2003-10-14

    Logged In: YES
    user_id=668541

    Can't go wrong with more calculus. These are both good
    ideas, and you're right it will be extremely complicated.
    The linux version that is in development is using the ginac
    http://www.ginac.de system. This should allow algebraic
    computation of much of that sort of thing. Stay tuned to a
    alpha version of GraphCalc on Linux in the coming months.
    What? You say "I don't use Linux". Well, give it a try...
    it's free. My favorite distribution at the moment is Gentoo
    www.gentoo.org.

     
  • Nobody/Anonymous

    Actually, this wouldn't be too hard. This is how it'd work:

    For the derivative graph, graphCalc need only plot a point for each visible pixel and its corresponding dy/dx, which is already implemented.

    Pseudocode follows:
    // xMax = the maximum window range for x values.
    // xMin = the minimum window range for x values.
    // pixelsAcross = the number of pixels across in the 2D graph window.

    double resX = (xMax - xMin) / pixelsAcross;

    for (int i = xMin; i < pixelsAcross; i + resX){
    // plot point at (i, (dy/dx)(i))
    }

    for integrals:

    // lastY = the last y-coordinate based off of the function. This represents the C in the antiderivative.
    double lastY = 0;
    for (int i = xMin; i < pixelsAcross; i + resX){
    // plot point at (i, lastY + f(i))
    lastY += f(i);
    }

     
  • Nobody/Anonymous

    A correction to my last post:

    for integrals, the user will have to specify an x coordinate where the antiderivative should intersect the x-axis, even though it may not, as in the case of the antiderivative of tan(x). However, since this may account for a C value, this may not be entirely problematic.

    First, a prompt should appear asking the user for an x value.

    Then,

    double xAnchor = // the value entered by the user
    double lastY = 0 // this value is 0 at the x anchor and is subsequently added to and subtracted from as the antiderivative is plotted.
    double currentX = xAnchor;
    // plot values to the right of the anchor
    while (currentX < xMax){
    // Check to see if the current area appears at all within the view window, if not, don't draw it.
    if (f(currentX - rexX)>= yMin && f(currentX - rexX)<= yMax && lastY >= yMin && lastY <= yMax){
    drawLine (currentX, lastY, currentX + resX, f(currentX + resX));
    // This pseudomethod assumes parameters of (bottomLeftX,bottomLeftY,topRightX,topRightY)
    }
    lastY += f(currentX + resX);
    currentX += resX;
    }
    // plot values to the left of the anchor
    currentX = xAnchor
    while (currentX > xMin){
    if (f(currentX - rexX)>= yMin && f(currentX - rexX)<= yMax && lastY >= yMin && lastY <= yMax){
    drawLine (currentX - resX, f(currentX - resX), currentX, lastY)
    }
    lastY -= f(currentX - resX);
    currentX -= resX;
    // Note: I am not 100% sure of this last bit. Testing will determine whether or not the signs are wrong. Also, any errors resulting from an x value being undefined should be handled
    }

    Also, a slight modification to my loop for the dy/dx line:
    for (int i = xMin; i < pixelsAcross; i + resX){
    // plot point at (i, (dy/dx)(i))
    }
    should be:

    currentX = xMin;
    while (currentX < xMax){
    if (dyDx(f(currentX))>= yMin && dyDx(f(currentX))<= yMax){
    drawLine (currentX, dyDx(f(currentX)),currentX + resX, dyDx(f(currentX + resX)));
    }
    currentX += resX;
    }
    At any rate, these should provide a cursory glance at the behaviors of the derivatives and antiderivatives of functions.

     
  • Nobody/Anonymous

    Oh, in the last post, the method should read:

    drawLine (currentX, lastY, currentX + resX, lastY + f(currentX +
    resX));

    Forgot the lastY part to add to the line

     

Log in to post a comment.