cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Can I define squared variables?

gshockxcc
7-Bedrock

Can I define squared variables?

Hello.  I'm new to Mathcad, and I'm trying out some symbolic variable definitions.  Can I define a variable like this? : 

gshockxcc_0-1668897530611.png

I have tried to mimic the w^2 term, but I am unable to set an assignment statement.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Use the literal subscript.

And if you experience troubles, show and attach your worksheet.

What are you trying to do after you made the assignment?

Werner_E_0-1668898262704.png

If you really try to ASSIGN, you can only use the variable itself, not its squared value.

View solution in original post

4 REPLIES 4

Use the literal subscript.

And if you experience troubles, show and attach your worksheet.

What are you trying to do after you made the assignment?

Werner_E_0-1668898262704.png

If you really try to ASSIGN, you can only use the variable itself, not its squared value.

Being new to Mathcad, I've tried to absorb as much as I can from the tutorials, but sometimes it's as simple as understanding what I can/can't do.  I repeated the logic you showed above, and it seems to work fine.  The reason that I wanted to write the formula in the form that I did is because I may be solving for w_c1, c_c1, or u_c1, depending on the conditions of the problem that I'm solving.  Obviously, I would just edit the "solve" statement to change the variable that I'm solving for.

 

Any thoughts on that approach, or better ways to set this up?

If you need both solutions, you probably have to stick with the symbolic "solve". If a single numeric result suffices, you may also use either a numeric solve block or the "root" command in one of its two flavours.

 

You may assign the result of the symbolic evaluation a variable and access the single values using the vector/matrix index (in the pic a numeric eval as well a symbolic one is shown)

Werner_E_0-1668959120228.png

 

You may as well turn the calculation into a function of the two input values and use it to compare the results for different inputs:

Again you can use this function either with symbolic or with numeric evaluation:

Werner_E_1-1668959241429.png

 

In case only the non-negative result is of interest you may use the "assign" modifier. Primes symbolic is rather weak compared to real symbolic math programs like Maple or Mathematica and so "assign" only works the way you may intend it if you are lucky.

Here you see a rather silly result because Prime should know that the sum of the squares of real numbers can't be negative:

Werner_E_3-1668959531690.png

But, surprise! When we actually use this function we get exactly what we intended - the non-negative solution only.

Werner_E_2-1668959506692.png

 

 

 

 

ttokoro
20-Turquoise
(To:gshockxcc)

Using image.png for variable name, image.pngis also can, but not recommended.

 

image.png

image.png

image.png

image.png

Top Tags