using Roots
using Plots
J=f(x)=x^2+10sin(x)
g(x)=f(x)-1000
find_zeros(g,0,10000)
plot(J)
The above works fine, but I want to plot a horizontal line at 1000, and plot J, so that x goes from 0 to 100. I’m not sure from the documentation, how to assign 0 values
I thought I dod for plots, but it looks like you assign values for plots. I like the graph, but the big thing is to show that since f(x) is continuous, there is value for every point, even irrationals, like sqrt(1000)
Package LaTeXStrings allows for a modifier (L) placed in front of strings ("..."), e.g., L"...", which inserts some \LaTeX code and makes it simpler to construct strings with math. So I can write L"f(\cdot)" which the LaTeXStrings package changes to the appropriate string of \LaTeX code.
To appreciate LaTeXStrings, you need to find a book on \LaTeX/\TeX math, and study the documentation of LaTeXStrings.
LaTeXStrings is not perfect, essentially because \LaTeX uses symbol $ to bracket math, while $ is simultaneously used in Julia as “interpolator” in text strings. I don’t have any perfect solution to this, though.
You want the function nameof giving the name of a function
julia> function g(x)
x + 1
end
g (generic function with 1 method)
julia> function myplot(fun, x)
plot(fun.(x), label = string(nameof(fun)))
end
myplot (generic function with 1 method)
julia> x = [1, 2, 3];
julia> myplot(g, x)