Skip to content

alfiovinci/TangentArt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

TangentArt

A simple Python program which creates artistic pictures. It is originally inspired by this Tweet.

Requirements

Tested on Python 3.9.7 (previous versions should work as fine).
Additional libraries needed: numpy, matplotlib.

How to use

Run the .py script using a terminal by specifying the following parameters: the desired boundaries of the independent variable; the desired function to plot using the notation accepted by the numpy library; the number of points where the function and the tangents are evaluated.
Each parameter must be enclosed by quotation marks. As an example, to represent a sine and its tangents in the interval from -20 and +20 using 500 points, one must run:
python3 tangentart.py '-20' '20' 'np.sin(x)' '500'.
A figure will pop-up showing the generated picture. The chosen function is represented as a red soline line, whereas the tangents are shown as thin black lines.
Note that: 1) the independent variable is always called x; 2) the function is defined using the rules set by the numpy library.

Output examples

A few examples are embedded in the following.

Example 1: python3 tangentart.py '-20' '20' 'np.sin(x)' '500'
Picture of a sine plotted in the interval -20 < x < +20 and evaluated in 500 points. Screenshot_20220314_202826

Example 2: python3 tangentart.py '-20' '20' 'x*np.sin(x)' '500'
Picture of the function x*sin(x) plotted in the interval -20 < x < +20 and evaluated in 500 points. Screenshot_20220314_203129

Example 3: python3 tangentart.py '-20' '20' 'x*np.tan(x)' '500'
Picture of tan(x) plotted in the interval -20 < x < +20 and evaluated in 500 points. Screenshot_20220314_203314

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages