I have this code, which works just fine outside of the function but when I enclose it inside the function it fails at the eval() command with the following hard to decipher message. I have looked at other similar problems but I do not understand how to fix this one. Any help will be appreciated. Cheers
MethodError: no method matching (::var"#87#88")(::Float64)
The applicable method may be too new: running in world age 33916, while current world is 33917.
Closest candidates are:
(::var"#87#88")(::Any) (method too new to be called from this world context.)
@ Main C:\Users\PWC.julia\packages\SymbolicUtils\ssQsQ\src\code.jl:373
function testing(time)
@variables t
D = Differential(t)
c = 0.06 * pi # Used to make the mathematical code clearer only.
C = 0.3 # Capacitance in Farad.
L = 1.7 # Inducatance in Henry.
R = 1.4 # Resistance in Ohms.
# This the function as given in the assignment question.
v_equ = (exp(-c*t) * sin(2*t - pi))
# This calculates the 1st derivative
dv_equ = D(v_equ)
# This calcultes the 2nd derivative
dv2_equ = D(dv_equ)
# This is the full function for di/dt as a function of t only
di_equ = expand_derivatives(C * dv2_equ + 1/R * dv_equ + v_equ/L)
f_i=build_function(integrate(di_equ, symbolic=true, detailed=false),t)
f_i=eval(f_i)
current=f_i.(time)-f_i.(zeros(size(time)))
return(time,current)
end
time,current=testing(time)
plot(time,current,label="Integrated")
plot!(Runga_time,Runga_current, label="Runga")
plot!(Euler_time,Euler_current,label="Euler")