Code Monkey home page Code Monkey logo

grapher's Introduction

Grapher

I love Desmos and use it all the time, but I was disappointed when I found out they didn't support slope and vector fields. So I decided to take on the challenge and code my own graphing calc with the desired functionality. After a lot of hard work and some intense mathematics 🙂, I'm proud to present the result, Grapher!

Features

  • Graph functions, slope fields, vector fields, polar, and parametric
  • Zoom in and out (with animations 🥳)
  • Beautiful rendering on Javascript canvas
  • Powerful and intuitive syntax
  • Set custom domain for polar and parametric graphs

Guide + Demos

Functions: Enter a function f(x) by writing any expression with the x variable. Separate multiple graphs with semicolons.

For this demo, I've graphed the parabola x^2, the sine curve sin(x) - 2, the line -3(x + 4), and the function 1/x.

Function Demo

I'm using the wonderful math.js library for evaluating math expressions. Here are a few useful functions and constants you can use in Grapher.

  • Trig functions: sin(x), cos(x), tan(x), sec(x), asin(x) (inverse sine), ...
  • Square root: sqrt(x)
  • Natural logarithm (base e): log(x)
  • Constants: pi, e

Slope Fields: Start off with the prefix s: and enter an expression in terms of x and y.

For this demo, I'm graphing the family of sine curves sin(x) + C and the slope field of cos(x). I've also included a hyperbola x^2 - y^2 = 1 and the slope field x/y.

Sines Hyperbola
Sines Slope Field Demo Hyperbola Slope Field Demo

Vector Fields: Use the prefix v: and enter an expression in the form of v: (f(x, y), g(x, y)). The 2 functions of x and y inside the paranetheses are the x- and y-components of the vector.

For this demo, I've graphed a dipole vector field, which represents the electric field lines between a positive and negative charge in physics.

Vector Field Demo

Polar: Use the prefix r = and enter an expression in the form of r = f(t).

For this demo, I've graphed 4 polar curves:

  1. Rose curve: r = sin(4t) (8 petals)
  2. Archimedes spiral: r = t [0, 16pi] (setting custom t-domain, default is [0, 2pi])
  3. Limaçons: r = 1 + sin(t) (cardioid), r = 1 + 2sin(t) (inner loop), and r = 3 + 2sin(t) (dimpled)
  4. Circles: r = 0; r = -5sin(t); r = 4cos(t); r = -3cos(t) (using r = 0 as dummy graph to get nice colors 😎)
Rose and Limacons Spiral and Circles

Parametric: Use prefix p: and enter in form of p: x = f(t), y = g(t).

For this demo, I've graphed the beautiful butterfly curve. Because this curve is so intricate, I upped the numbers of intervals from 1,000 (default) to 10,000.

Function Demo

Bonus: Gamma function, the continuation of the factorial function to decimal and complex numbers (graphed with 10,000 intervals).

Vector Field Demo

And that's it! Thanks for checking out my project and use Grapher to visualize whatever your heart desires!

grapher's People

Contributors

rohanphanse avatar

Stargazers

Atticus Kuhn avatar  avatar

Watchers

 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.