How do programs draw function graphs?

In summary, programs draw function graphs by first defining the mathematical function to be represented. They then create a coordinate system, typically using a grid of axes. The program calculates values of the function at various points within a specified range, generating pairs of x and y coordinates. These points are plotted on the graph. Finally, the program connects the plotted points with lines or curves to visually represent the function, often allowing for customization of colors and styles for better clarity.
  • #1
Trysse
53
10
Hi there,

I was wondering how computer programs such as geogebra or more advanced packages such as mathlab or wolfram plot graphs for functions.

Do they calculate values and interpolate? Do they take derivates to determine maxima and turning points? Do they have any other way to somehow construct the curve?

Are there different approaches depending on the type of function?
 
Technology news on Phys.org
  • #2
Basically, they evaluate the value of the function, over a specified range of the argument. That gives a list of points(x,y), that can be linearly interpolated.
They do not need to identify turning points, or the gradient of the line, as that will be done by the interpolator when it plots the function.
 
  • #3
Trysse said:
Hi there,

I was wondering how computer programs such as geogebra or more advanced packages such as mathlab or wolfram plot graphs for functions.

Do they calculate values and interpolate? Do they take derivates to determine maxima and turning points? Do they have any other way to somehow construct the curve?

Are there different approaches depending on the type of function?
General-purpose plotting routines will not do anything that assumes something about the source of the data (like whether it comes from a function that has a derivative). They need to be able to plot data of all sorts. On the other hand, they may allow the user to specify how the data will be interpolated (linear, spline, etc.)
 
  • #4
Ok. Thanks for the quick responses.

That means calculate and interpolate. Right?

Are there ways to construct graphs for arbitrary functions (on a computer or on apiece of paper)?

I know of some functions such as $$f(x)=ax+b$$ or $$f(x)=\sqrt{1-x^2}$$ that I can construct with ruler or a compass but what about arbitrary functions?

Can I construct or must I calculate and plot.

What constraints must a function satisfy so I can construct? Do these functions belong to some group or category of functions that has a name?
 
  • #5
Conics?
 
  • #6
Trysse said:
Are there ways to construct graphs for arbitrary functions (on a computer or on apiece of paper)?
There may well be ways, but you must first specify your arbitrary function.

Obviously, no computer is going to construct a function geometrically, when it can evaluate it and plot it numerically.
 
  • #7
Trysse said:
Ok. Thanks for the quick responses.

That means calculate and interpolate. Right?

Are there ways to construct graphs for arbitrary functions (on a computer or on apiece of paper)?

I know of some functions such as $$f(x)=ax+b$$ or $$f(x)=\sqrt{1-x^2}$$ that I can construct with ruler or a compass but what about arbitrary functions?

Can I construct or must I calculate and plot.

What constraints must a function satisfy so I can construct? Do these functions belong to some group or category of functions that has a name?
On a computer, you can always make a large table of evaluated points.
Manually, it is good to find the zeros, poles, inflection points, maximums, minimums, asymptotic values, etc. And if they are compositions of functions that you can graph, then you can make a series of graphs following the composition.
 
  • #8
Baluncore said:
but you must first specify your arbitrary function.
how about say $$f(x)=x^2$$ or $$f(x)=\frac{1}{\sqrt{1-x^2}}$$?

My guess is, that those graphs cannot be constructed. One reason is that they go to infinity. But maybe there is a way to construct the graph within a certain range. I still guess it is not possible. However, this guess is based purely on the fact that I don't know how to do it. And by construct I do not mean "more or less" but exactly.
 
  • #9
Trysse said:
how about say $$f(x)=x^2$$ or $$f(x)=\frac{1}{\sqrt{1-x^2}}$$?

My guess is, that those graphs cannot be constructed. One reason is that they go to infinity. But maybe there is a way to construct the graph within a certain range. I still guess it is not possible. However, this guess is based purely on the fact that I don't know how to do it. And by construct I do not mean "more or less" but exactly.
Obviously a complete graph over the entire real line can't be constructed, but a program can draw a graph ove a finite interval. The graph of the first function is a parabola and that of the second function has a sort of parabolic shape in the interval (-1, 1).
 
  • #10
  • Like
Likes FactChecker
  • #11
Trysse said:
However, this guess is based purely on the fact that I don't know how to do it.
Curve sketching is an important subject in elementary mathematics as it gives one an intuitive insight into important functions, their roots and derivatives. You can learn about it from sites such as https://www.bbc.co.uk/bitesize/guides/zc62srd/revision/7

The topic is summarized on the Wikipedia page https://en.wikipedia.org/wiki/Curve_sketching and this page has references to books with more information. These books were published over a century ago from which you can infer two things:
  • the books are out of copyright and copies can be found by searching the internet; and
  • "advanced curve sketching" as a topic in intself is not something that people have been interested in for a very long time.
Trysse said:
And by construct I do not mean "more or less" but exactly.
What do you mean by 'construct a graph exactly'?
 
  • #12
Trysse said:
Can I construct or must I calculate and plot.

What constraints must a function satisfy so I can construct? Do these functions belong to some group or category of functions that has a name?
Are you asking about constructing a graph using some physical property like:
1) a circle using a protractor,
2) an ellipse using a string with its ends at the foci,
3) a straight line using a ruler,
etc.?
If so, that is a good question.
There might be a lot more that I am not familiar with and I do not know of any general term or categorization for them.
 
  • #13
Trysse said:
My guess is, that those graphs cannot be constructed.
The graph y = x2 can be constructed.
https://en.wikipedia.org/wiki/Parabola#Pin_and_string_construction

The other would be more difficult, as it involves three tricks, but I believe it would be possible using pins, linkages and string. There have been many books written on the subject of the generation of mathematical curves using linkages.

How To Draw A Straight Line; A Lecture On Linkages. A. B. Kempe, (1877).

I. I. Artobolevskii and W. Johnson (Auth.) - Mechanisms for the Generation of Plane Curves - Macmillan (1964).

Kinematics, Dynamics, and the Design of Machinery - K. J. Waldron and G. L. Kinzel - (1944, 2004).

There is no way a computer would use any of those methods to draw a graph today. The positions of the points and lines would be computed numerically.
 
  • Like
Likes FactChecker
  • #14
Baluncore said:
The graph y = x2 can be constructed.
https://en.wikipedia.org/wiki/Parabola#Pin_and_string_construction

The other would be more difficult, as it involves three tricks, but I believe it would be possible using pins, linkages and string. There have been many books written on the subject of the generation of mathematical curves using linkages.

How To Draw A Straight Line; A Lecture On Linkages. A. B. Kempe, (1877).

I. I. Artobolevskii and W. Johnson (Auth.) - Mechanisms for the Generation of Plane Curves - Macmillan (1964).

Kinematics, Dynamics, and the Design of Machinery - K. J. Waldron and G. L. Kinzel - (1944, 2004).

There is no way a computer would use any of those methods to draw a graph today. The positions of the points and lines would be computed numerically.
Interesting.
So if there is a good way to do multiplication any polynomial can be constructed.
Then if there is a good way to construct 1/x, any rational function can be constructed.

If there is a construction of ##e^x## all the trigonometric and hyperbolic functions can be constructed.
Finally, the inverse of any constructable graph is easy.
 
  • #15
FactChecker said:
If there is a construction of all the trigonometric and hyperbolic functions can be constructed.
Finally, the inverse of any constructable graph is easy.
Some transcendental functions are easier than a square. For example, sine and cosine are trivial, given a shaft and a crank. Tidal prediction machines sum the Fourier components with one long wire or chain that snakes through the machine.
https://en.wikipedia.org/wiki/Tide-predicting_machine

During WW2, the ballistic calculations on battleships were all done mechanically, including the atmospheric and Coriolis corrections.
https://en.wikipedia.org/wiki/Mark_I_Fire_Control_Computer

Accurate involute gear teeth are "generated" by a rotating straight edged hob.
https://en.wikipedia.org/wiki/Hobbing
 
  • Like
Likes FactChecker

Similar threads

Back
Top