 Share your knowledge at the LQ Wiki. LinuxQuestions.org Quick and dirty plotting with Haskell: Supplement

Notices

Concerning free software, programming, and whatever else I find interesting. Also the blog for my Web site, frigidcode.com.
Rate this Entry

Quick and dirty plotting with Haskell: Supplement

Posted 01-14-2013 at 11:54 PM by hydraMax

I just wanted to add a brief note to my previous post: It is also quite simple to do a plot with multiple functions. The following code gives the graph seen in the attached PNG:

Code:
```h> import Graphics.Gnuplot.Simple
h> let f x = 3 - 2*x + 4*x**2
h> let g x = 8*x - 2
h> let h a x = g a * (x - a) + f a
h> plotFuncs [] (linearScale 1000 (-10,10)) [f, g, h (-5)]```
f(x) is a function, g(x) is the derivative of f(x), and h(x) is the tangent line for f(x) at -5.
Attached Images plotFuncs.png (49.5 KB, 4 views)
Posted in Uncategorized
 My LQ Syndicate Latest Threads LQ News Twitter: @linuxquestions Facebook: linuxquestions Google+: linuxquestions