Skip to content

A web-based tool that helps users estimate the value of definite integrals for polynomials with degree up to 2. It allows users to input polynomial coefficients, define integration bounds, and visualize the result with interactive graphs, including a shaded area representing the approximated integral, while displaying the integral expression.

Notifications You must be signed in to change notification settings

GerryS02/Integral-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integral Approximation App

Background

Integral approximation is a method used to estimate the value of a definite integral when an exact solution is difficult or impossible to obtain analytically. In many cases, numerical methods are used to approximate the area under a curve defined by a function over a given interval ([a, b]).

Given a function, the integral can be approximated by dividing the area into small subintervals, calculating the function's value at specific points within each subinterval, and then summing these values with a weighted factor. These methods are especially useful when the function is complex, and an analytical solution is not straightforward.

This project provides a web application where users can input the bounds of a definite integral and approximate the result using one of several numerical methods.


Project Overview

The Integral Approximation App allows users to approximate the value of definite integrals for polynomials of the form:

$$ f(x) = ax^2 + bx + c $$

Users are required to provide the coefficients for the polynomial and the bounds of the integral. The app then uses different numerical methods to approximate the integral within the given bounds.

The user can select from the following approximation methods:

  • Left Endpoint Approximation
  • Right Endpoint Approximation
  • Midpoint Approximation
  • Trapezoidal Approximation
  • Simpson’s Approximation

Key Features:

  • Accepts polynomials with a maximum degree of 2 (i.e., ( ax^2 + bx + c )).
  • The interval ([a, b]) is divided into subintervals of a constant size ( h = 0.5 ).
  • The app calculates the integral based on the selected method and displays the result along with a plot of the function and the area under the curve.

Numerical Approximation Methods

For an integral with bounds ( a ) and ( b ), we can approximate the result by dividing the interval into ( n ) subintervals. The value of ( h ) is given by:

$$ h = \frac{b - a}{n} $$

Where ( n ) is kept constant as 0.5 in this project. The formula for each approximation method is as follows:

Left Endpoint Approximation

The left endpoint approximation uses the function values at the left endpoints of the subintervals:

$$ L_n = h \left[ f(x_0) + f(x_1) + f(x_2) + \dots + f(x_{n-1}) \right] $$

Right Endpoint Approximation

The right endpoint approximation uses the function values at the right endpoints of the subintervals:

$$ R_n = h \left[ f(x_1) + f(x_2) + f(x_3) + \dots + f(x_{n}) \right] $$

Midpoint Approximation

The midpoint approximation uses the function values at the midpoints of the subintervals:

$$ M_n = h \left[ f(c) + f(c + h) + f(c + 2h) + \dots + f(c + (n-1)h) \right] $$

Where ( c ) is the midpoint of the interval.

Trapezoidal Approximation

The trapezoidal approximation calculates the integral using trapezoids between the function values at the endpoints and midpoints:

$$ T_n = \frac{h}{2} \left[ f(x_0) + 2f(x_1) + f(x_2) + 2f(x_3) + \dots + 2f(x_{n-1}) + f(x_n) \right] $$

Simpson’s Approximation

Simpson’s rule approximates the integral using parabolic segments between the function values:

$$ S_n = \frac{h}{3} \left[ f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \dots + 2f(x_{n-2}) + 4f(x_{n-1}) + f(x_n) \right] $$


How to Use

  1. Enter the Polynomial Coefficients:

    • Users enter the values for the polynomial coefficients ( a ), ( b ), and ( c ) corresponding to the terms $$( ax^2 + bx + c ) $$.
  2. Select the Approximation Method:

    • Users can choose from the following methods:
      • Left Endpoint Approximation
      • Right Endpoint Approximation
      • Midpoint Approximation
      • Trapezoidal Approximation
      • Simpson’s Approximation
  3. View the Result:

    • After submitting the form, the app will compute the integral approximation and display:
      • The mathematical expression of the integral using LaTeX.
      • The result of the approximation.
      • A graph showing the polynomial function and the area under the curve (shaded region).

Future Development or Enhancements

While the current implementation works for polynomials with a maximum degree of 2, the app could be significantly enhanced with additional features. Some potential future developments include:

  1. Support for Higher-Degree Polynomials:

    • The app could be extended to handle polynomials of higher degrees (e.g., cubic, quartic) by dynamically adjusting the function expression based on user input.
  2. Support for Other Types of Functions:

    • The app could be extended to support other types of functions such as trigonometric functions, exponential functions, logarithmic functions, or rational functions.
    • Users would be able to input a function as a string, and the app would parse and evaluate it accordingly.
  3. Custom Number of Subintervals:

    • Allow users to input the number of subintervals ( n ) instead of fixing it to a constant. This would provide users with more control over the accuracy of the approximation. The value of ( h ) would then be calculated as:

$$ h = \frac{b - a}{n} $$

  1. Adaptive Methods:

    • Implement adaptive numerical methods that adjust the number of subintervals based on the function’s behavior to improve the accuracy of the approximation without requiring the user to manually input ( n ).
  2. Error Estimation:

    • Introduce error estimation for each approximation method, showing how close the approximation is to the exact solution (if available) or the true value.

These enhancements would make the app more powerful and versatile, allowing users to perform a broader range of integral approximations for different types of functions.


Image

About

A web-based tool that helps users estimate the value of definite integrals for polynomials with degree up to 2. It allows users to input polynomial coefficients, define integration bounds, and visualize the result with interactive graphs, including a shaded area representing the approximated integral, while displaying the integral expression.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published