What does invalid input mean for the diff function?

355 Views Asked by At

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?
1

There are 1 best solutions below

0
On BEST ANSWER

Look at the error message coming from the call to diff.

It indicates that the second argument being passed to diff is actually (1/8)*l^2*q and not actually just the name T.

It appears that the name T evaluates 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 assign that will assign a value to T using the prior equation returned by solve.

It's unclear what is your intention. (You didn't show us whether M2 contains the plain name T or something involving that value that seems assigned to it.)

You could run the code in a fresh session, or after restart, or after unassigning T, ie.,

T := 'T':

M1 := 1/2*q*x*(l - x);

            1            
      M1 := - q x (l - x)
            2            

M2 := -T + T*x/l;

                 T x
      M2 := -T + ---
                  l 

Ec := int((M1 + M2)^2/(2*EI), x = 0 .. l):
Ec := simplify(Ec);

        / 4  2         2         2\
      l \l  q  - 10 T l  q + 40 T /
Ec := -----------------------------
                 240 EI            

eq1 := diff(Ec, T) = 0;

            /     2         \    
          l \-10 l  q + 80 T/    
   eq1 := ------------------- = 0
                 240 EI           

sol := solve(eq1, T);

                   1    2
           sol := - q l 
                   8     

Note that your don't have to assign the result from solve in order to utilize that value as a replacement for T later on. For example, after the above code, your can use the eval command to substitute that value for T into arbitrary formulas:

soleq := solve(eq1, {T});

                /    1    2\ 
      soleq := { T = - q l  }
                \    8     / 

eval( T^2 + T, soleq );

         1   4  2   1    2
         -- l  q  + - q l 
         64         8     

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).