GithubHelp home page GithubHelp logo

zentrocdot / gnu-bc-functions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mikepierce/gnu-bc-functions

0.0 0.0 0.0 65 KB

GNU Basic Calculator (bc) Functions

Home Page: https://org.coloradomesa.edu/~mapierce2/bc/

License: GNU General Public License v3.0

gnu-bc-functions's Introduction

GNU Basic Calculator (bc) Functions

My working collection of functions for GNU bc. The functions are split into two files: functions.bc containing simple “pure” functions, and routines.bc containing functions that I’ve found useful in practice as a math instructor.

functions.bc

Here is a list of the functions this file defines:

sgn abs heavyside int ln log logb pow radtodeg degtorad cos sin tan sec csc cot arccos arcsin arctan atan2 arcsec arccsc arccot cosh sinh tanh sech csch coth arcosh arsinh artanh arsech arcsch arcoth factorial pick choose fibonacci newton integrate prime

Alongside the ubiquitous mathematical functions in this list, this file contains implementations of the following:

  • Newton's Method (newton(x)) which approximates a zero of a smooth function f near x. Note that f and its derivative ff must be globally defined.
  • Numerical Integration (integrate(a,b,n)) which numerically computes the value of a definite integral of a function f between a and b using Boole's Rule (boole_) with n subdivisions. Note that f must be globally defined.

routines.bc

Here is a list of the functions this file defines:

  • Pythagorean Triple Generator (pythagtriple(m,n)) which prints the Pythagorean triple generated by two parameters m and n.
  • Newton's Method (newtoniter(x,n)) which iteratively approximates a zero of a smooth function f near x a total of n times, printing each successive approximation. Note that f and its derivative ff must be globally defined.
  • Quadratic Polynomial Solver (quadratic(a,b,c)) which prints the roots and vertex of a degree-two polynomial given its coefficients as input.
  • Rational Approximation (rational(x)) which displays subsequently better rational approximations to x — the convergents of its continued fraction presentation — until finding the first one equal to x up to scale.
  • Different Base Expression (bases(n)) which displays a number n in bases 2, 3, …, 36.
  • Prime Integer Factorization (factor(n)) which displays the prime integer factors of n.

Conventions

  • Function names ending in _ are helper functions, not intended to be called directly.
  • Some functions that return the nth number in a sequence (e.g. fibonacci, prime) create an array of the same name as the function containing all previous terms in the sequence used to compute the nth term.
  • In the file routines.bc if a function changes/defines a variable globally, the function will print that variable assignment explicitly.
  • Since bc doesn't accept functions as parameters to other functions, any functions that morally should be a parameter must be defined globally. Such a function is named f. If there must be two functions, the other will be named g. If a function wants to know the derivative of f, it'll expect that derivative to be named ff (e.g. newton).

Aspirations

  • Add cubic and quartic functions that prints the details of a cubic and quartic polynomial.
  • Address issues withe the numerical integration integrate function: There must be a way to remove the need for the parameter n, Also, I'm concerned this function is inaccurate for large values of |b – a|.
  • Add a function that finds constructable algebraic approximations to real numbers. (see this).
  • Add a numerical derivative function (see this).

Allusions

gnu-bc-functions's People

Contributors

mikepierce avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.