# Example of every problem that i ever met

``````

In [1]:

# create parameterized function for DifferentialEquations.jl
using DifferentialEquations
using ParameterizedFunctions
using Plots

lorenz = function(t,u,p,du)
du[1] = p[1](u[2] - u[1])
du[2] = u[1] * (p[2] - u[3]) - u[2]
du[3] = u[1]*u[2] - p[3]*u[3]
end
pf = ParameterizedFunction(lorenz,[10.0,28.0,8/3])
# now pf can be used in Differentialequations.jl

prob = ODEProblem(pf,[1.0;0.0;0.0],(0.0,1.0))
sol = solve(prob)

plotly()
plot(sol)

``````
``````

MethodError: objects of type Float64 are not callable

in (::##1#2)(::Float64, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}) at ./In[1]:7
in ode_determine_initdt(::Array{Float64,1}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::OrdinaryDiffEq.#ODE_DEFAULT_NORM, ::DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,ParameterizedFunctions.ParameterizedFunction{true,##1#2,Array{Float64,1}}}, ::Int64) at /Users/user/.julia/v0.5/OrdinaryDiffEq/src/initdt.jl:7
in #init#46(::Bool, ::Int64, ::Bool, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Bool, ::Float64, ::Bool, ::Rational{Int64}, ::Rational{Int64}, ::Rational{Int64}, ::Int64, ::Rational{Int64}, ::Rational{Int64}, ::Bool, ::Rational{Int64}, ::Rational{Int64}, ::Int64, ::Float64, ::Float64, ::OrdinaryDiffEq.#ODE_DEFAULT_NORM, ::OrdinaryDiffEq.#ODE_DEFAULT_ISOUTOFDOMAIN, ::OrdinaryDiffEq.#ODE_DEFAULT_UNSTABLE_CHECK, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::OrdinaryDiffEq.#ODE_DEFAULT_PROG_MESSAGE, ::Void, ::DiffEqBase.CallbackSet{Tuple{},Tuple{}}, ::Bool, ::Bool, ::Array{Any,1}, ::DiffEqBase.#init, ::DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,ParameterizedFunctions.ParameterizedFunction{true,##1#2,Array{Float64,1}}}, ::OrdinaryDiffEq.Tsit5, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at /Users/user/.julia/v0.5/OrdinaryDiffEq/src/solve.jl:86
in (::DiffEqBase.#kw##init)(::Array{Any,1}, ::DiffEqBase.#init, ::DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,ParameterizedFunctions.ParameterizedFunction{true,##1#2,Array{Float64,1}}}, ::OrdinaryDiffEq.Tsit5, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at ./<missing>:0
in #solve#45(::Array{Any,1}, ::Function, ::DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,ParameterizedFunctions.ParameterizedFunction{true,##1#2,Array{Float64,1}}}, ::OrdinaryDiffEq.Tsit5, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at /Users/user/.julia/v0.5/OrdinaryDiffEq/src/solve.jl:6
in (::DiffEqBase.#kw##solve)(::Array{Any,1}, ::DiffEqBase.#solve, ::DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,ParameterizedFunctions.ParameterizedFunction{true,##1#2,Array{Float64,1}}}, ::OrdinaryDiffEq.Tsit5, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}, ::Type{Val{true}}) at ./<missing>:0 (repeats 2 times)
in #solve#7(::Bool, ::Array{Any,1}, ::Function, ::DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,ParameterizedFunctions.ParameterizedFunction{true,##1#2,Array{Float64,1}}}) at /Users/user/.julia/v0.5/DifferentialEquations/src/DifferentialEquations.jl:45
in solve(::DiffEqBase.ODEProblem{Array{Float64,1},Float64,true,ParameterizedFunctions.ParameterizedFunction{true,##1#2,Array{Float64,1}}}) at /Users/user/.julia/v0.5/DifferentialEquations/src/DifferentialEquations.jl:38

``````
``````

In [2]:

x = 0.0
y = 1.0
# core funtions
typemax(Int64)
typemin(Int64)
sizeof(ans)
# bitary represantation
bits(0.0)
# next or prev represantable floating-point number
prevfloat(x),nextfloat(x)

BigInt(typemax(Int64)) + 2
isinf(x)
isnan(x)
isfinite(x)
isequal(x,x)

# chaning
(x > y) ? "greater" : (isequal(x,y)) ? "equal" : "less"

``````
``````

Out[2]:

"less"

``````
``````

In [3]:

x = 5.0; y = -2.0;
div(x,y)  # round to 0
fld(x,y)  # round to -Inf
cld(x,y)  #       to +Inf
rem(x,y)  # x == div(x,y)*y + rem(x,y), rem(x,y) = sign(x) # ans = 1.0
mod(x,y)  # x == fld(x,y)*y + mod(x,y), mog(x,y) = sign(y) # ans =-1.0
mod2pi(x) # 0 <= mod2pi < 2pi
divrem(x,y) # tuple
fldmod(x,y) # tuple
#gcd(x,y...) # greates common devider
lcm(x,y...) # least positive common multiple

``````
``````

MethodError: no method matching lcm(::Float64, ::Float64)
Closest candidates are:
lcm(::Union{SymEngine.Basic,SymEngine.BasicType{T}}, ::Number) at /Users/user/.julia/v0.5/SymEngine/src/mathfuns.jl:14

``````
``````

In [4]:

b = 3
log(b,x)  # lnx/lnb log base b of x
expm1(x)  # exp(x) - 1
hypot(x,y)
log1p(x)  # log(1+x)
sinpi(x)  # sin(πx)

``````
``````

Out[4]:

0.0

``````
``````

In [5]:

map(x -> x^2 -2x + 4, (1:0.1:6))
[cos(x)*sin(y) + z for x=1:5, y=1:5, z=1:5]

``````
``````

Out[5]:

5×5×5 Array{Float64,3}:
[:, :, 1] =
1.45465   1.4913     1.07625   0.591098  0.481891
0.649825  0.621599   0.941273  1.31494   1.39905
0.16695   0.0998024  0.860292  1.74923   1.94933
0.449978  0.405644   0.907758  1.49468   1.62679
1.23869   1.25793    1.04003   0.785324  0.727989

[:, :, 2] =
2.45465  2.4913   2.07625  1.5911   1.48189
1.64982  1.6216   1.94127  2.31494  2.39905
1.16695  1.0998   1.86029  2.74923  2.94933
1.44998  1.40564  1.90776  2.49468  2.62679
2.23869  2.25793  2.04003  1.78532  1.72799

[:, :, 3] =
3.45465  3.4913   3.07625  2.5911   2.48189
2.64982  2.6216   2.94127  3.31494  3.39905
2.16695  2.0998   2.86029  3.74923  3.94933
2.44998  2.40564  2.90776  3.49468  3.62679
3.23869  3.25793  3.04003  2.78532  2.72799

[:, :, 4] =
4.45465  4.4913   4.07625  3.5911   3.48189
3.64982  3.6216   3.94127  4.31494  4.39905
3.16695  3.0998   3.86029  4.74923  4.94933
3.44998  3.40564  3.90776  4.49468  4.62679
4.23869  4.25793  4.04003  3.78532  3.72799

[:, :, 5] =
5.45465  5.4913   5.07625  4.5911   4.48189
4.64982  4.6216   4.94127  5.31494  5.39905
4.16695  4.0998   4.86029  5.74923  5.94933
4.44998  4.40564  4.90776  5.49468  5.62679
5.23869  5.25793  5.04003  4.78532  4.72799

``````
``````

In [14]:

using Plots
using ForwardDiff
pyplot()
function hat(x)
(abs(x) < 4) ? exp(- 4^2/(4^2-x^2)) : 0.0
end

δhat = x -> ForwardDiff.derivative(hat, x)
δ2hat = x -> ForwardDiff.derivative(δhat, x)
p = map(hat, (-5.:0.01:5))
pd= map(δhat, (-5.:0.01:5))
pdd= map(δ2hat, (-5.:0.01:5))
plot(p)
plot!(pd)
plot!(pdd)

``````
``````

WARNING: Method definition hat(Any) in module Main at In[13]:5 overwritten at In[14]:5.

Out[14]:

``````
``````

In [ ]:

``````