Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: Functions for numerical integration and differentiation #54

Closed
6 tasks done
rajutkarsh07 opened this issue Mar 23, 2024 · 3 comments
Closed
6 tasks done
Labels
2024 2024 GSoC proposal. rfc Project proposal.

Comments

@rajutkarsh07
Copy link

rajutkarsh07 commented Mar 23, 2024

Full name

Utkarsh Raj

University status

Yes

University name

IIIT Jabalpur

University program

Computer Science and Engineering

Expected graduation

31-05-2025

Short biography

Hey there, I'm Utkarsh Raj, a third-year student pursuing a Bachelor's degree in Computer Science and Engineering at IIIT Jabalpur. I'm passionate about full-stack development, and I've got hands-on experience with a variety of technologies. During my internship, I dove into Fullstack development, honing my skills in JavaScript, TypeScript, Node.js, C, and C++. Beyond that, I've also dabbled in DevOps and Docker, expanding my toolkit to encompass all aspects of the development process.

My diverse skill set allows me to tackle problems from multiple angles, whether it's building web applications, crafting command-line interfaces, or diving deep into algorithmic challenges. I've poured my passion for development into numerous projects, each one showcasing my dedication to the craft.

In addition to practical experience, I've delved into theoretical foundations through coursework covering Data Structures and Algorithms, Probability and Statistics, Advanced Mathematics, and more. Mathematics holds a special place in my heart, which is why I've taken on project Functions for Numerical Integration and Differentiation to further explore its applications in programming

Timezone

India Standard Time

Contact details

email: [email protected], [email protected] , [email protected] Phone number: +91 9693501629 Linkedin: https://www.linkedin.com/in/utkarshraj1306/ Github: https://github.com/rajutkarsh07

Platform

Linux

Editor

Visual Studio Code (VS Code) stands as my preferred code editor, because it seamlessly integrated with Ubuntu's ecosystem, offering extensive features and plugins for efficient software development. Its intuitive interface, robust debugging capabilities, and built-in support for various programming languages, particularly JavaScript, C and C++ streamline my workflow, ensuring high-quality code and efficient collaboration via Git integration. Operating within Ubuntu, VS Code serves as a versatile tool for web development, allowing seamless navigation between files, folders, and projects, while its mature environment and extensive extension library enhance developer experience. Whether for work or personal projects, VS Code remains my go-to editor, providing everything needed in one place for productive coding and version control.

Programming experience

I've been passionate about programming since high school, and over the years, I've honed my skills in a variety of languages including JavaScript, C, C++, TypeScript, Node.js, and Python. My journey includes reaching a maximum rating of 1536 on Codeforces and successfully solving over 1000 problems across platforms like Codeforces, LeetCode, and GeeksforGeeks. I've actively participated in numerous hackathons, bringing my problem-solving abilities to the forefront. Moreover, I've contributed as a full-stack developer at e-Pocket, Australia, gaining practical experience in developing real-world applications. Additionally, I've been selected as a contributor in LFX Mentorship, further solidifying my commitment to open-source contributions.
I have made several full-stack projects and CLI projects also

  • flagrush-server flagrush-client
    • This platform provides cybersecurity researchers with a collaborative environment to practice bug-solving, engage in discussions, and execute various social interactions like sending friend requests.
  • CLI project Cli Template Maker
    • I have made a template maker that enables users to effortlessly store and generate templates via commands.

I also have a good performance in hackathons

  • Amazon Hackon : My team *Delta was selected in the top 50 among 50k+ teams.

I've showcased my proficiency in working with web APIs, real-time data within a JavaScript environment. These experiences have equipped me with the skills necessary to excel in projects like this.

JavaScript experience

Over the past three years, I've delved deep into JavaScript, acquiring a comprehensive understanding of its syntax, features, and underlying mechanics. I've dedicated myself to mastering its intricacies, from comprehending its event loop mechanisms to seamlessly navigating between synchronous and asynchronous operations. This journey has seen me engage in a diverse range of projects, from dynamic web development ventures to crafting robust command-line interfaces using Node.js.

One of the standout features of JavaScript, in my opinion, is its asynchronous programming paradigm, exemplified by the elegant syntax of async/await. This powerful combination enables developers to craft code that is not only clean and concise but also highly efficient, effectively managing asynchronous operations with ease.

In addition to mastering the fundamentals of JavaScript, I've extensively explored various libraries and frameworks that enrich its ecosystem. My repertoire includes React, Angular, Vue, Node.js, and Express, among others. Despite the flexibility offered by JavaScript's dynamic nature, I've encountered challenges in maintaining code organization and ensuring seamless functionality, especially in large-scale projects. However, I remain steadfast in my pursuit of innovative solutions, continuously pushing the boundaries of what can be achieved with JavaScript.

Node.js experience

My experience with Node.js spans across a wide spectrum of projects, showcasing my proficiency in backend development and CLI application creation. I've developed numerous backend APIs using Node.js, employing its powerful features to build robust and scalable solutions. Moreover, I've leveraged Node.js in crafting CLI applications, harnessing its versatility to deliver efficient command-line tools.

In addition to these endeavors, I've spearheaded the development of several full-stack web applications, where Node.js served as the backbone of the backend infrastructure. My role as a full-stack developer provided me with invaluable opportunities to further hone my skills in utilizing Node.js to create seamless and feature-rich web experiences.

C/Fortran experience

I began my journey with C and C++ during my first year of college when these languages were introduced as part of my coursework. I learned data structures and algorithms using C and C++, and I also engaged in competitive programming in C++, mastering its syntax and leveraging its features to solve algorithmic challenges effectively. Additionally, my academic pursuits led me to explore advanced numerical mathematics, where I undertook assignments involving the implementation of mathematical algorithms.

While I haven't used Fortran as extensively as JavaScript or C/C++, I do understand its importance in scientific computing. Fortran's specialized features for handling numerical operations and arrays make it ideal for tasks such as linear algebra and simulations. It serves as a valuable tool in the field of computational mathematics. but I am assured of my capacity to swiftly adapt and grasp new languages and technologies, drawing upon my existing programming knowledge and experience.

Interest in stdlib

The Stdlib library seamlessly merges my passion for mathematics with my expertise in web development, offering a comprehensive toolkit within the Node.js ecosystem. Its extensive range of utility functions and modules, spanning mathematical computations to file system operations, empowers developers of varying skill levels to efficiently address diverse project requirements. Stdlib's commitment to excellence, performance optimization, and adherence to industry standards fosters trust and widespread adoption within the Node.js community. Particularly noteworthy is Stdlib's support for advanced numerical computations, including robust random number generation capabilities, which fill a significant gap in JavaScript's native capabilities. This comprehensive support not only enhances JavaScript's utility for web development but also positions it as a practical toolkit for scientific and technical computing tasks, fostering a vibrant community around scientific computing in JavaScript.

Version control

Yes

Contributions to stdlib

So far in stdlib I have merged 3 pull requests and have 3 open pull request and 2 closed pull request:

Merged PRs:

Open PRs;

Closed PRs:

Goals

My goal with this project is to implement Functions for numerical integration, ODE and differentiation, providing developers like myself with robust tools for solving mathematical and scientific problems. Implement functions for numerical integration and differentiation using the composite Simpson's rule and the composite trapezoidal rule. Implement mathematical functions that are not currently available in the stdlib-js and will be required in implemention of these functions,

Implementation

Integration Functions

Composite Simpson's Rule Integration

This module provides a function to integrate a given array y(x) using samples along the given axis and the composite Simpson's rule.

reference scipy/simpson

Usage

Function Signature

integrate_simpson(y, (x = None), (dx = 1.0), (axis = -1), (even = None));

Simpson

/**
 * Integrate `y(x)` using samples along the given axis and the composite Simpson's rule.
 *
 * @param {Array<number>} y - Array to be integrated.
 * @param {Array<number> | null} [x=null] - If given, the points at which `y` is sampled.
 * @param {number} [dx=1.0] - Spacing of integration points along the axis of `x`. Only used when `x` is null. Default is 1.0.
 * @param {number} [axis=-1] - Axis along which to integrate. Default is the last axis.
 * @param {string | null} [even=null] - Determines how to handle integration when there are an even number of samples. Options are 'simpson', 'avg', 'first', 'last', or null. Default is null.
 * @returns {number} - The estimated integral computed with the composite Simpson's rule.
 * @throws {Error} - If the shapes of `x` and `y` do not align.
 */
function simpson(y, x = null, dx = 1.0, axis = -1, even = null) {
  // Function implementation
}

Trapezoid

/**
 * Integrate along the given axis using the composite trapezoidal rule.
 *
 * @param {Array<number>} y - Input array to integrate.
 * @param {Array<number> | null} [x=null] - The sample points corresponding to the `y` values. If `x` is null, the sample points are assumed to be evenly spaced `dx` apart. The default is null.
 * @param {number} [dx=1.0] - The spacing between sample points when `x` is null. The default is 1.0.
 * @param {number} [axis=-1] - The axis along which to integrate.
 * @returns {number | Array<number>} - Definite integral of `y` as approximated along a single axis by the trapezoidal rule. If `y` is a 1-dimensional array, then the result is a float. If `n` is greater than 1, then the result is an `n`-1 dimensional array.
 */
function trapezoid(y, x = null, dx = 1.0, axis = -1) {
  // Function implementation
}

Explanation

The integrate_simpson function takes an array y(x) and optionally, an array x representing the points at which y is sampled. If x is not provided, the function assumes a uniform spacing of dx along the x-axis. The integration is performed along the specified axis, with the default being the last axis. The parameter even determines how to handle integration when there are an even number of samples. Finally, the function returns the estimated integral computed using the composite Simpson's rule.

Required functions

Differentiation

Reference: scipy/misc/_common.py#L84

Parameters

  • y (Array-like): Array to be integrated.
  • x (Array-like, optional): If given, the points at which y is sampled. Default is None.
  • dx (float, optional): Spacing of integration points along the axis of x. Only used when x is None. Default is 1.0.
  • axis (int, optional): Axis along which to integrate. Default is the last axis.
  • even (str, optional): Determines how to handle integration when there are an even number of samples. Options are 'simpson', 'avg', 'first', 'last', or None. Default is None.

Returns

  • integral (float): The estimated integral computed with the composite Simpson's rule.

Exceptions

  • Error: If the shapes of x and y do not align.

Example

const derivative = require('derivative'); // after successfull implementation of derivatives
function f(x) {
  return Math.pow(x, 3) + Math.pow(x, 2);
}

// Compute the derivative of f at x = 1.0
let result = derivative(f, 1.0);

console.log(result);

ODE (Ordinary Differential Equations)

reference: scipy/integrate/_ode.py#L103

The ODE package contains several solvers for solving Ordinary Differential Equations (ODEs), including:

  • LSODE (Livermore Solver for Ordinary Differential Equations)
  • LSODES
  • LSODA
  • LSODAR
  • LSODI
  • LSOIBT
  • QNG
  • QAG
  • QAGS
  • QAGP
  • QAGI
  • QAWO
  • QAWF
  • QAWS
  • QAWC

Reference

Implementation Plan

To implement the ode class:

  1. Define the right-hand side function f(t, y, *f_args) representing the system of ODEs to solve.
  2. Optionally, define the Jacobian function jac(t, y, *jac_args) if required by the solver.
  3. Initialize an instance of the ode class, passing the f and jac functions (if applicable).
  4. Set additional parameters for the integrator using setIntegrator method.
  5. Set initial conditions for the ODE system using setInitialValue method.
  6. Integrate the ODE system over the desired time span using integrate method.

Example Usage

const { ode } = require('ode'); // after successful implementation of ode

const y0 = [1.0i, 2.0];
const t0 = 0;

function f(t, y, arg1) {
    return [1i * arg1 * y[0] + y[1], -arg1 * y[1] ** 2];
}

function jac(t, y, arg1) {
    return [[1i * arg1, 1], [0, -arg1 * 2 * y[1]]];
}

const r = ode(f, jac).setIntegrator('zvode', { method: 'bdf' });
r.setInitialValue(y0, t0).setParams({ f: [2.0], jac: [2.0] });

const t1 = 10;
const dt = 1;
while (r.successful() && r.t < t1) {
    console.log(r.t + dt, r.integrate(r.t + dt));
}

Why this project?

As someone deeply passionate about mathematical concepts and adept at crafting efficient algorithms, the goal of this project speaks directly to my interests. I am excited about the prospect of merging my skills and passions to contribute to the advancement of Stdlib. Introducing functions for numerical integration or differentiation holds immense potential for enhancing Stdlib's capabilities, making it an essential resource for developers tackling intricate mathematical computations. Leveraging my enthusiasm for mathematical concepts and algorithm optimization, I am eager to embark on this journey. Whether by adapting existing open-source libraries or creating implementations from scratch, I am committed to making meaningful contributions to the JavaScript ecosystem. This project perfectly aligns with my expertise and aspirations, driving my enthusiasm to play a pivotal role in its success.

Qualifications

Professional Experience in JavaScript:

  • Worked in a remote Australian startup, contributing to numerous projects primarily using JavaScript.
  • Demonstrated proficiency by creating and managing over 30 repositories on GitHub.

Strong Competence in Algorithms and Data Structures:

  • Accomplished problem-solving skills showcased through extensive participation and success on platforms like Codeforces, LeetCode, and GeeksforGeeks.
  • Solved over 1000 algorithmic questions, exhibiting a deep understanding of problem-solving paradigms and algorithmic complexities.

Technical Proficiency in C++:

  • Proficient in C++, as evidenced by solving numerous complex problems on competitive programming platforms.
  • Mastery in leveraging C++ for efficient algorithmic implementations and software development.

Academic Pursuits in Computer Science:

  • Currently pursuing a degree in Computer Science at IIIT Jabalpur, a reputable institution.
  • Completed coursework in advanced numerical methods, statistics, and probability, enhancing analytical and problem-solving capabilities.

Exceptional Academic Performance:

  • Consistently achieved above the 99th percentile in all JEE Main Maths examinations, reflecting a strong grasp of fundamental concepts and problem-solving abilities.

Mathematical Proficiency:

  • Equipped with advanced knowledge in mathematics, including numerical integration and differentiation, attained through specialized courses at the university level.
  • Comfortable implementing functions for numerical computations, ensuring precision and accuracy in mathematical operations.

Prior art

During my research for this project, I extensively explored various resources and repositories to gather insights and understand existing implementations. Specifically, I reviewed the GitHub repository for scijs/ode45-cash-karp to gain understanding of numerical methods for solving ordinary differential equations. Additionally, I thoroughly examined SciPy, a widely-used scientific computing library, to understand its implementation of numerical integration and differentiation methods.

These resources provided valuable insights and served as a foundation for my project implementation.```

Commitment

1 May - 26 May -> Bonding Period
27 May - 7 July -> 40 hours/week ( 40 * 6 )
8 July - 17 August -> 21 hours/week ( 21 * 6 )
Total = 240 + 126 = 346 hours
Apart from this, I don't have any other commitments during the coding period.

Schedule

Assuming a 12 week schedule,

  • Community Bonding Period:

    • I will engage with the stdlib community and mentors, I will actively participate in discussions, seek guidance, and provide updates on my progress. I will research existing implementations and best practices for efficient iteration in Python libraries like SciPy, adapting relevant techniques to suit the stdlib's requirements. Will learn more about the functions I am going to implement in this projects.
  • Week 1:

    • Research and study existing implementations of numerical integration and differentiation methods.
    • Identify mathematical functions that are currently missing in the standard JavaScript library and prioritize them based on relevance to integration and differentiation algorithms.
  • Week 2:

    • Begin implementation of missing mathematical functions required for integration and differentiation algorithms.
    • Set up the project structure and environment for implementing numerical integration and differentiation functions.
  • Week 3:

    • Continue implementing missing mathematical functions.
    • Start drafting documentation for the implemented functions, including usage examples and parameter descriptions.
  • Week 4:

    • Complete the implementation of missing mathematical functions.
    • Proceed with integrating these functions into the numerical integration and differentiation algorithms.
  • Week 5:

    • Begin implementation of the composite Simpson's rule for numerical integration.
    • Write tests to ensure the correctness and accuracy of the implemented algorithms.
  • Week 6:

    • Continue refining and debugging the implementation of the composite Simpson's rule.
    • Test the algorithm with various input scenarios and edge cases to validate its robustness.
  • Week 7:

    • Start implementing the composite trapezoidal rule for numerical integration.
    • Document the composite Simpson's rule integration function with usage examples and explanations.
  • Week 8:

    • Continue refining and finalizing the implementation of the composite trapezoidal rule.
    • Write comprehensive tests to verify the correctness and accuracy of the implemented algorithm.
  • Week 9:

    • Begin working on the implementation of the Fifth Order Adaptive Cash-Karp method for numerical integration.
    • Document the composite trapezoidal rule integration function with usage examples and explanations.
  • Week 10:

    • Continue refining and debugging the implementation of the Fifth Order Adaptive Cash-Karp method.
    • Test the algorithm rigorously with various ODE systems to ensure its reliability and accuracy.
  • Week 11:

    • Finalize documentation for all implemented functions, ensuring clarity and comprehensiveness.
    • Conduct thorough code reviews to identify and address any potential issues or optimizations.
  • Week 12:

    • Review the entire implementation, documentation, and tests to ensure completeness and quality.
    • Prepare for project delivery, including packaging the functions for distribution and publishing the library.
    • Reflect on the project's achievements and challenges, documenting lessons learned for future reference.

Notes:

  • The community bonding period is a 3 week period built into GSoC to help you get to know the project community and participate in project discussion. This is an opportunity for you to setup your local development environment, learn how the project's source control works, refine your project plan, read any necessary documentation, and otherwise prepare to execute on your project project proposal.
  • Usually, even week 1 deliverables include some code.
  • By week 6, you need enough done at this point for your mentor to evaluate your progress and pass you. Usually, you want to be a bit more than halfway done.
  • By week 11, you may want to "code freeze" and focus on completing any tests and/or documentation.
  • During the final week, you'll be submitting your project.

Related issues

Checklist

  • I have read and understood the Code of Conduct.
  • I have read and understood the application materials found in this repository.
  • I understand that plagiarism will not be tolerated, and I have authored this application in my own words.
  • I have read and understood the patch requirement which is necessary for my application to be considered for acceptance.
  • The issue name begins with [RFC]: and succinctly describes your proposal.
  • I understand that, in order to apply to be a GSoC contributor, I must submit my final application to https://summerofcode.withgoogle.com/ before the submission deadline.
@rajutkarsh07 rajutkarsh07 added 2024 2024 GSoC proposal. rfc Project proposal. labels Mar 23, 2024
@rajutkarsh07
Copy link
Author

rajutkarsh07 commented Mar 27, 2024

@kgryte @Planeshifter @rreusser @Pranavchiku @czgdp1807
Please give suggestions for improvement

@kgryte
Copy link
Member

kgryte commented Mar 31, 2024

@rajutkarsh07 Thank you for sharing a draft of your proposal. A few comments:

  1. While all these APIs would make great additions, I am curious about their feasibility. Namely, do we have all the prerequisite functionality needed to implement these APIs? If we are missing necessary functionality, that could significantly affect the timeline you propose. As such, I strongly recommend doing some R&D, such as by exploring the source code of SciPy, to better understand implementation dependencies, and then cross-referencing back to stdlib to see what's available and what's missing.
  2. Your proposal doesn't provide any concrete API proposals. I suggest providing some example signatures and a discussion of input argument types and necessary options. Will these work on strided arrays? ndarrays? regular arrays? Will they need to support options, such as tolerances, methods, or something else? Again, SciPy may provide a good reference here.

@rajutkarsh07
Copy link
Author

Thank you, @kgryte, for your valuable feedback and insights regarding the proposed project. I've carefully considered your suggestions, and based on further research, I've decided to focus solely on implementing the functions for differentiation, Simpson's rule, and ordinary differential equations (ODEs) during this summer.

I've incorporated the implementation details for these specific functions, along with comprehensive plans, examples, and usages.

@kgryte kgryte closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2024 2024 GSoC proposal. rfc Project proposal.
Projects
None yet
Development

No branches or pull requests

2 participants