Skip to main content
1-Visitor
August 7, 2018
Solved

Using minimize for a function which depends on parameters

  • August 7, 2018
  • 3 replies
  • 3870 views

Dear helpers,

 

I am quite new to Mathcad and have the following question using the minimize optimization in Mathcad15.

 

I would like to calculate the maximum of deformation of a loaded plate (=minumum of plate equation). Therefor I use a plate equation w(x,y) with several parameters (force and force location (x and y)) for several time steps by adding an Excel component. (Each time step has a set of these three parameters.)

 

I was able to calculate the minimum for each of these steps seperate but my goal is to use the minimize optimization for w(x,y) dependent on the parameters so that the solution is a vector consisting of the several minimums for each parameter set. 

 

I appreciate any kind of help.

Thank you!

Best answer by Werner_E

I am sorry, but I have to tell you, that the results you get for a single set of values is wrong.

You ran into a common trap when dealing with vectors.

Short explanation what went wrong: you define a function w(x,y) which uses a couple of vectors (the forces).

You calculate sin(..vector) and this is a vector, as it should be. You do it a second time and the you multiply the two sines. That means, thats you multiply two vectors and Mathcad does as commanded and if you multiply two vectors, Mathcad uses the dot product and the result is a scalar. Not what you intended. The whole double sum simplifies to a single scalar value which is then multiplied by the result of the expression in front of the sums and this is a vector, so the whole result is a vector and it looks like all was done as you expected - it wasn't.

A way out could be to use a Mathcad feature called vectorization (the arrow over an expression). If you multiply two vectors and use vectorization, the vectors are multiplied element wise. If mathcad encounters an operation which is not defined for vectors (like sin(vector) or vector^3) it switches automatically to vectorization (otherwise it would have to throw an error because of an invalid operation).

 

The main reason for falling in the trap is a wrong approach to the problem by defining the input vectors first and applying them to all calculations (this should work OK if you use vectorization, but its not tge best way to do it). Most of times its better to set up the calc sheet by defining functions which depend on all variables you later wish to change. After calculations are turned into functions you can define your input vectors and call the function(s) with them (but of course you would vectorize that call!).

So you always can test your calc functions with single values and different vectors at will side by side.

B.png

3 replies

Werner_E25-Diamond IAnswer
25-Diamond I
August 7, 2018

I am sorry, but I have to tell you, that the results you get for a single set of values is wrong.

You ran into a common trap when dealing with vectors.

Short explanation what went wrong: you define a function w(x,y) which uses a couple of vectors (the forces).

You calculate sin(..vector) and this is a vector, as it should be. You do it a second time and the you multiply the two sines. That means, thats you multiply two vectors and Mathcad does as commanded and if you multiply two vectors, Mathcad uses the dot product and the result is a scalar. Not what you intended. The whole double sum simplifies to a single scalar value which is then multiplied by the result of the expression in front of the sums and this is a vector, so the whole result is a vector and it looks like all was done as you expected - it wasn't.

A way out could be to use a Mathcad feature called vectorization (the arrow over an expression). If you multiply two vectors and use vectorization, the vectors are multiplied element wise. If mathcad encounters an operation which is not defined for vectors (like sin(vector) or vector^3) it switches automatically to vectorization (otherwise it would have to throw an error because of an invalid operation).

 

The main reason for falling in the trap is a wrong approach to the problem by defining the input vectors first and applying them to all calculations (this should work OK if you use vectorization, but its not tge best way to do it). Most of times its better to set up the calc sheet by defining functions which depend on all variables you later wish to change. After calculations are turned into functions you can define your input vectors and call the function(s) with them (but of course you would vectorize that call!).

So you always can test your calc functions with single values and different vectors at will side by side.

B.png

25-Diamond I
August 7, 2018

Here is a small animation - simply used linear interpolation of your vectors of forces.

 ani1.gif

I attach the avi-file, too, as its usually more convenient and embedded videos often fail here.

EDIT: As the embedded video still does not work, I replaced it by an animated GIF.

 

21-Topaz II
August 7, 2018

Hi,

 

So you can test your answers here is another approach for a simply supported plate.

 

Cheers

 

 

23-Emerald I
August 7, 2018

Once again, Werner is right and faster.