I'm trying to create a periodic function but I get:
MethodError: no method matching
## Defining the drift function
function drift_a(x)
if 0<=x<2/3
return 2/7-x-2/7*(1-3*x)*sqrt(abs(1-3*x))
end
if 2/3<=x<=1
return -2/7+2/7*x
end
end
function drift_b(x)
return 12*(drift_a(x-floor(x))+0.05)
end
print(drift_b(0.5))
print(drift_b(10.5-floor(10.5)))
print(drift_b(10.5))
I'm new to Julia so I don't understand why it throws an error. I have tried creating a placeholder variable y = x-floor(x)
and using the function on y
instead, but it gives the same error.
function drift_a(x)
y
is never referred to indrift_a
– Oscar Smith