Created
July 31, 2020 12:34
-
-
Save lucainnocenti/96c3d6d78c6cc8b8dc3dabfe72ef9aef to your computer and use it in GitHub Desktop.
linear approximation of function in MMA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xMax = 1.4; | |
numPartitions = 10; dx = xMax/numPartitions; | |
pointsAndLines[pts_] := {Point@pts, Line@pts}; | |
fun[x_] := x^2; | |
Plot[fun@x, {x, 0, xMax}, | |
PlotRange -> All, PlotStyle -> Directive[Thick], Frame -> True, | |
GridLines -> Automatic, | |
FrameStyle -> Directive[Black, Thick, Large], | |
PlotLegends -> "Expressions", | |
ImageSize -> 500 | |
]~Show~Graphics[{ | |
[email protected], | |
pointsAndLines[ | |
Thread@{# dx, Accumulate[dx fun'[(# - 1) dx]]} &@ | |
Table[k, {k, 1, numPartitions}] // Prepend@{0, 0}] | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment