I am confused now. What is parameter and what is function call? Why did we have parameter in the firs place? |
If you define a function like f(x,y):=x^2*sin(y), x and y are (formal) parameters of the function x.
Wehn you call the function to evaluate it like f(a,b)=..., a and b are called the actual parameters an will be replacing x amd y in the function definition and then the expression will be evaluated. That way it is not necessary to name the formal parameters the same as the actual parameters you will use later (something which as it seems you try to do whenever possible).
Your function MNmin() has four parameters, the second one is a value which, when you later call that function, stems from calling function alpha(). So (I guess) you tried to name that parameter alpha(x,x0), which failed, as in defining a function you must have a name here, not a function. Unfortunately you knew about the possibility to insert special characters in variable names via Ctrl-K and created a parameter name which looks like a function call alpha(x,x0). The error was, that on the right side of the function definition you used that parameter three times and two times you still have the real function call here, which take the value of x0 at the time of the definition, not the time of calling the function. This is why i suggested to make x0 a parameter.
Why change to the parameter name? Why not change to function alpha? |
Because as we have seen in this example it can cause quite some confusion to use a parameter name which LOOKS like a function call. What would you like to change at function alpha?
In the worksheet you attached, x0=1000 is still defined after MNmin(). Should it not be moved above MNmin()? |
To be honest its my feeling that it should be a parameter of the odesolve block. That way you wouldn't be forced to retype/copy the solve block just to try and compaer another value for x0.
The worksheet I posted worked, because all I did, was, changing the two function calls (blue in my pic) to the parameter name (red) you created. It would make more sense to change all of them to something like alpha0, though.
To be honest with you, every time I want to add more conditions to the worksheet, I don't know why I add another ODE block! I have to go back to your previous worksheet you kindly organized and try to understand how to add more conditions without increasing the blocks. |
I see. If you are in need for a new ODE block, just think what is changing (lets say x0) an then make this a parameter of the solve block.