Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi,
I am very new to Mathcad. I have a solve block for a quadratic equation. So i have 2 roots, and i want it to be automatic select to be one of it.
it somehow said the variable is undefined. Really appreciate if someone can help me out. Thanks.
Solved! Go to Solution.
Hi Werner,
Now i finally get some idea on assigning the solve solution to vTH, but when i try to use the assume method, it said its illegal assume constraint.
The Given and Find method is working just fine, but i don't want to use a guess value, i want it to find the one root that fit within v0<vTH<v1 directly.
The assume method seems great if it can work out.
Attached with my worksheet.
To the left of ln(sigma1/sigma0) put VTH:= (i.e. colon equals) this will assign the result to VTH. You can select the appropriate solution using VTH[0 or VTH[1 as required.
Note: It is better to upload a worksheet rather than just an image (use the advanced editor to do this - top right of edit box)
Alan
Hi Alan,
But once i change the = to := , it's not applicable to use solve-> anymore, I attached my mathcad as below.
Another thing for the selection of vTH, at first i thought like a matrix vector, so i put like vTH0 and vTH1 but it doesn't work like a matrix in solve block.
Thanks.
Look if some of th attched helps. I can't tell as yout sheet won't work withoud the referenced data file.
Hi Werner,
Now i finally get some idea on assigning the solve solution to vTH, but when i try to use the assume method, it said its illegal assume constraint.
The Given and Find method is working just fine, but i don't want to use a guess value, i want it to find the one root that fit within v0<vTH<v1 directly.
The assume method seems great if it can work out.
Attached with my worksheet.
ERIC CHEAM wrote:
... when i try to use the assume method, it said its illegal assume constraint.
Assume is getting confused because of your previous solutions for vTH - see attached.
Alan
Alan already solved the problem.
If its just the guess value which is of concern you could also evaluate the solve block symbolically and do without any guess:
I finally understand how to use the assume with solve block. Thank you so much, guys!
ERIC CHEAM wrote:
Hi Alan,
... once i change the = to := , it's not applicable to use solve-> anymore, I attached my mathcad as below.
I didn't mean change the = sign to the right of the ln, I meant put := to the left of ln with vTH to the left of that, so that the whole expression is, in effect, assigned to vTH.
Alan
To automatically chose the solution fitting your constraint you may try the "assume" command.
But as you are expecting numerical results you may also use a solve block with "Find" where you can put your constraint in a natural way.
For further help - attach your worksheet.
I have a solve block that find the roots of quadratic equation in complex form, And the assume function cannot distinguish which one to select if it's in complex form. I try to use assume for modulus so that i can have an absolute value, but it does not work like that. Is there any other method to tell the solve block to change the answer to an abosolute value automatically without giving me the complex form? Attached with my worksheet.
Which one would you like to select? Complex numbers are not in order, you cannot compare them for size.
I want to select the -0.02185645369468207621+0.00025256616676468628262i as the absolute value of this is within the v0<vth<v1. This is why i try to change the solve block to have roots in absolute value so that it can fit the assume range. The other root -0.9 is out of the range which should be neglected.
So you are interested in the magbitude of the solution only.
For your subsequent calculations, do you need the complex value of vTH or just the magnitude?
Don't think the symbolic solve will do the job here, but a solve block sure works if evaluated numerically.
If the same calculation should be done more often with different values of sigma and vi you may consider turning it into a function (either by symbolic solve or using the solve block).
For my subsequent calculation, i only need the magnitude of the vTH. I am sorry, I am a bit confuse of the symbolic solve and solve block numerically. For my understanding, solve block will always result in symbolic with an arrow ---> . What do you mean solve evaluated numerically, can i use solve block but i only the magnitude of the result come out?
You can have either a symbolic solve block or a numeric one. Each has advantages/disadvantages.
I think we have a confusion about the meaning of solve block.
A solve block is that construct that starts with the statement "Given" followed by equations and constraints and usually end with "Find(..)" (while also minerr, maximize, odesolve,.. are possible).
You can assign the output of Find() to a variable. Typically such a solve block is evaluated numerically - you type something like "Solution:=Find(x)" and Mathcad would use a numerical iteration algorithm to get close to a solution. It needs a guess value for the searched for variable to do so and this is what you didn't like in a prior post.
But you can also evaluate a solveblock symbolically by typing "Solution:=Find(x)-->" Now Mathcad doesn't need a guess and will use "exact" symbolical ways to find the solutions. Unfortunately usually if the symbolical solve command fails a symbolical evaluated solve block will fail too.
I think you thought we mean the symbolical solve command you used in conjunction with assume, etc, when we were talking about a solve block.
Some questions about your problem:
You say that you would just use the magnitude of the solution of the quadratic equation.
1) What if the magnitudes of both solutions are inbetween v0 and v1?
2) If a solution is neagtive we would have to use its absolute value in comparing with v0 and v1 as ist only the magnitude which counts, right?
3) In the first sheet you posted both v0 and v1 were negative! How would you expect the magnitude of any number being inbetween??? Are you sure you will use the magnitude (which is positive or zero) or would you rather use the real part of the solution (which can be negative, too)??
Hi Werner,
You are right. It shouldn't be the magnitude part, it should be the real part. For the 1), the two roots only will have one root in between v0 and v1 as vth is an intersection between 2 gaussion curve with mean v0 and v1.
Thanks for all the help.
Thanks Werner, your function method works fine.