Hello I'm pretty new to maple. I used it 6 years ago, but, well I'm a little rusty
Essentially I'm trying to plot a multivariable differential equation (Izhikevich model) but first I want to get my head around the 'proc' command
so I set up the below proc command which is essentially f:=x->x^2
parabola:=proc(x)
x^2;
end;
I call
plot(parabola,-10..10)
and it works like a charm
now if I do the following it should have absolutely no affect on the graph, but it raises holy hell
y=1234;
parabola:=proc(x)
global y;
y:=y+5678
x^2;
end;
this time when I call
plot(parabola,-10..10)
the graph looks all wierd, as if the assignment to y is returning a value which is interfereing with the x^2
Does anyone know what the problem is
thanx
That's strange, it worked for me as well, to a certain degree
But there is some strange behaviour associated with 'proc'. For example if you type in the following
>y:=2;
>parabola:=proc(x)
global y;
print("x is",x);
x^y;
end;
>plot(parabola,-5..5);
I'm expecting something like
x is -5
x is -4
x is -3
...
but instead I get much more than the 11 calls to the function, and it's in the form of
x is -4.972378378373...
x is -4.596886676334...
x is-4.3234324234323...
This is a problem if the procedure has any side effects, like if a global variable is being updated.
I think what's happening is that the plot function keeps calling the procedure to increase the accuracy of the graph, but with sheer disregard for side effects.
Hey, I'll try that solution, but I already tried a similar approach, namely using "if type(x,integer) then..." but what happened was that if I called it like so
plot(parabola,-5..5)
then the output would be
x is -5
x is 5
it would completely ignore the intermediate values
I changed it such that I ran a for loop which updates an array of points, then I print the points.
To its defense, I don't think maple would be able to draw such perfect graphs if it were restricted to only using integers, furthermore, for reasons of performance and memory management, I doubt maple could get away with running a program, then removing all of its side effects
I guess we can add Maple to the long line of programming languages which de facto require you to understand all of their intracicies.
So I tried the solution you gave me, but it suffers from the same problem as previously, namely that plot doesn't just deal with integers.
I think plot expects a function with zero side effects, such that it is free to sample any parameters it wishes.
The function I'm trying to implement, the Izhikevich model, inherently codes for millisecond precision. So the xaxis is time in milliseconds, however, the function must be called every millisecond, on the millisecond. And I just don't think plot is capable of dealing with such a function.