Currently I'm learning about maple. I'm studying structural mechanics and we need to use maple to evaluate expressions. The following code is for an exercise to use castigliano's second theorem to evalute the moment T. This is probably carelessness/inexperience from my side, but due to Covid the university is closed and I can't get help from instructors. If somebody could give me feedback, that would be great!
M1 := 1/2*q*x*(l - x);
M2 := -T + T*x/l;
Ec := int((M1 + M2)^2/(2*EI), x = 0 .. l);
eq1 := diff(Ec, T) = 0;
Error, invalid input: diff received (1/8)*l^2*q, which is not valid for its 2nd argument
sol := solve(eq1, T);
assign(sol);
Warning, solving for expressions other than names or functions is not recommended.
Error, invalid left hand side in assignment
evalf(T);
Although it throws errors and warnings, it still evaluates the correct answer. But these warnings are bothering me.
Question:
- What did I do incorrect to cause these warnings/errors?
- How can I avoid errors/warnings?
Look at the error message coming from the call to
diff.It indicates that the second argument being passed to
diffis actually(1/8)*l^2*qand not actually just the nameT.It appears that the name
Tevaluates to(1/8)*l^2*q, ie. T has a previously assigned value.My guess is that you attempted to run your code twice, but forgot that the final command is a call to
assignthat will assign a value toTusing the prior equation returned bysolve.It's unclear what is your intention. (You didn't show us whether
M2contains the plain nameTor something involving that value that seems assigned to it.)You could run the code in a fresh session, or after
restart, or after unassigningT, ie.,Note that your don't have to
assignthe result fromsolvein order to utilize that value as a replacement forTlater on. For example, after the above code, your can use theevalcommand to substitute that value forTinto arbitrary formulas:My tip is: read the error messages and try to understand their meaning.
By the way, this Question is off-topic in this forum because it about Maple programming rather than mathematics per se. More appropriate would be either stackoverflow.com or www.mapleprimes.com (Maplesoft user forum).