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

We are working to address an issue with subscription email notifications. In the meantime, be sure to check your favorite boards for new topics.

9-Granite

## Math equation solve issue

I have some questions about Mathcad function. I don’t have any useful idea to solve my issues.

I have one equation, and I can draw the curve of this equation.

And then I try to solve the peak value of curve (fig.1) by using the method in EX2.

Below are my questions.

1.Any method I can solve this equation to get the fn_Y2, please see EX1?

2.How do I use solve function to get the fn_Y2, if I have different inputs Q2 at the same time (please see EX3).  I can do this when I only have one input, please see EX2.

3.If the issue 2 can be solved, and then I would try to input the fn_Y2 to get the peak value . Also I would like to draw the relationship of Q and peak value, please see the fig.2 (this fig is from TI’s datasheet), could you please give me some suggestions.

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:J_power)

Prime is not able to solve your equation symbolically.

But as you had shown yourself it can provide solution(s) if you provide numeric values for the other two variables

You may also use the "assume" modifier to limit the solution to the only positive, real one

But you are just looking for numeric results (depending on Q and L(ambda), so I would suggest that you use Mathcads numeric methods. Either a solve block with "find" or one of the two ways to use the "root" function.

Here is the latter, assuming the solution is within the range from 10^-10 to 10:

You can turn this calculation into a function of lambda and Q

So it can be used to get the result for any of these values

From here its not difficult to plot either the My function for various Q-values and their peaks

or the plot you seem to be looking for

22 REPLIES 22
18-Opal
(To:J_power)

I am not sure why do you want to differentiate with respect to fn_Y2, and not fn_Y.

Its too complicated to solve for fn_Y...also having these 2 as parameters

But you can do something like this:

as you already did in fact here:

Its based on a manual way to do this what you want as you did...

Here...someone will need to find a way on how to choose maximum value as we can see for example at Q4 index is 3 and at Q6 index is 5, so index is changing:

And then how to iterate Q parameter from 0.1, 0.2,...1, then for each Q value to find the maximum, and then to plot, these in a more automatical way...Maybe one could find how to do it...

24-Ruby V
(To:Cornel)

@Cornel wrote:

I am not sure why do you want to differentiate with respect to fn_Y2, and not fn_Y.

Above that expression he already had defined a value for f.n_Y and so Mathcads symbolics would refuse to solve for this variable. So he had chosen a different name to be used for the variable Mathcad should solve for.

24-Ruby V
(To:J_power)

Prime is not able to solve your equation symbolically.

But as you had shown yourself it can provide solution(s) if you provide numeric values for the other two variables

You may also use the "assume" modifier to limit the solution to the only positive, real one

But you are just looking for numeric results (depending on Q and L(ambda), so I would suggest that you use Mathcads numeric methods. Either a solve block with "find" or one of the two ways to use the "root" function.

Here is the latter, assuming the solution is within the range from 10^-10 to 10:

You can turn this calculation into a function of lambda and Q

So it can be used to get the result for any of these values

From here its not difficult to plot either the My function for various Q-values and their peaks

or the plot you seem to be looking for

18-Opal
(To:Werner_E)

I converted your Mathcad 15 file to Prime 10 and...I see this. How to solve?

24-Ruby V
(To:Cornel)

Yes, Prime is not capable to plot family of curves like Mathcad was able to do.

You would have to do it completely different, create vectors(/matrices and use Primes waterfall plot to get a similar picture.

Fortunately @J_power  is using real Mathcad and not Prime 😉

18-Opal
(To:Werner_E)

Hm, if you know how to do this it will be nice. I am interested too on this exercise how can be done using Prime as I am using Prime

24-Ruby V
(To:Cornel)

Look at this thread and the sheet posted there

Solved: Plotting Multivariable Multifunction Summation Fun... - PTC Community

Maybe this can be of help, too

Solved: Add/Remove More plot lines automatically from a ve... - PTC Community

If you want to create a specific waterfall plot of a family of curves in Prime and still experience troubles, I would suggest opening a new thread for it.

18-Opal
(To:Werner_E)

Apart of this with waterfall plot of a family of curves in Prime, I made above a path suggestion on how this exercise can be solved. There I made a manual approach. Do you think that this approach can be automated somehow?

The 2 things needs there:

1. How to choose the maximum value of fn_Y as we can see for example at Q4 index is 3 and at Q6 index is 5, so index is changing of the maximum value.
2. How to iterate Q parameter from 0.1, 0.2,...1, then for each Q value to find the maximum as was made at above point 1, and then to plot My vs Q, these in a more automatical way.

Or in fact what I suggested here is what is done these 2 above posted threads?

24-Ruby V
(To:Cornel)

I consider the problem solved by using the numeric root function as shown in my first reply. No need to fumble around with the symbolic solve, I guess. But lets @J_power  decide if he needs more help or if he really needs to use the symbolics - after all its his question and his thread!

The links to the two threads I provided in my answer to your question cover the problem you experience with the plot in the converted sheet and have otherwise nothing to do with this thread here! If you really want to duplicate the failing plot in Prime you can study and use the methods demonstrated in those threads. This thread here covers the initial question and deals with Mathcad, not Prime!

18-Opal
(To:Werner_E)

Ok, I made this with waterfall plot also in Prime 10 following that first thread you had posted.

But I see a thing here: if I try to plot fn_Y from 0 the error with division by 0 arise. I am wondering how you managed to plot from 0 in Mathcad 15?

Prime 10:

My f vector in Prime:

And we are both using the same :

24-Ruby V
(To:Cornel)

A 2D plot will happily ignore failing function values and still plot the rest. The creation of a vector/matrix fails if just one of the calculation fails. So simply use

when you create the matrix, the plot will ignore the NaN's and work OK.

I this specific case you may also replace the NaN by a zero, because that's the correct limit

That said you may also use

9-Granite
(To:Werner_E)

May I know why you use Vector in M function and F function?

24-Ruby V
(To:J_power)

@J_power wrote:

May I know why you use Vector in M function and F function?

You are talking about the vectorization used when showing the five peak positions?

f.nY and M.Y are functions written to receive single scalar arguments. When you want to feed into those function a vector like Q.3 instead and expect that every single element of this vector should be used as function argument and all results the n collected in a vector, then this is exactly what vectorization is made for. Sometimes (depends how your function is defined) its not necessary to apply explicit vectorization because Mathcad would apply (implicit) vectorization automatically. But i won't rely on it and suggest to always use explicit vectorization in such cases.

Here two simply examples. Both function simply square the argument given. They do the very same when used with a simple scalar argument but return different results when called with a vector as argument.

Reason is that f uses multiplication and this is an operation defined for vectors, too (scalar product). Function g uses squaring and this is an operation NOT defined for vectors and instead of throwing an error Mathcad applies implicit vectorization. So using explicit vectorization is a good idea without having to think if its really necessary or if Mathcad would do it on its own.

BTW, the vectorization of M.Y in the plot was senseless and i shouldn't have used it because here I use your range (! not a vector) Q.2 to plot all five curves in one go (something not working in Prime anymore as Cornel also noticed). Vectorization has no effect if no vectors are involved (but it doesn't do any harm either).

9-Granite
(To:Werner_E)

it is more clear to me, thanks.

24-Ruby V
(To:J_power)

I played around and added a 3D plot with the L (lambda), Q an max My values, showing the curve corresponding to L=6.3 in red

I also added a way to use the symbolics to get the necessary fnY-values, but I won't suggest using it:

9-Granite
(To:Werner_E)

What's the function of this equation?

24-Ruby V
(To:J_power)

@J_power wrote:

What's the function of this equation?

This expression does the very same (or something similar) as the function f.positive in my last reply (posting a worksheet with Lucs approach).

F is the result of calling the function "temp" which uses the symbolics to return a vector with six elements.

In case of your example just one of these six values is real and positive and this is the one to pick. I won't bet that its always the first or always the second one (even this may be the case here).

Furthermore sometimes because of round-off errors even the real solutions are returned with a very tiny imaginary part.

1)  |Im(F)|<^10^.10 returns a 6-element vector with a 1 where F is a real value (Imaginary part 0 or very small) and a zero if F is non.real.

2) F is multiplied b the vector created in the first step, so all non-real values are set to zero

3) this new vector is sorted using the "sort" function. That way the largest (positive ?) value comes last in the vector returned

4) "reverse" changes the order of the vector elements so that that positive value is the first element

5) This first element is now chosen using the matrix index ORIGIN

And, no, this sure is not the most elegant or intuitive way to achieve this task 😉

After all I think its best to avoid the symbolics altogether and just use Mathcads numeric facilities.

23-Emerald III
(To:J_power)

The question is to find the peak values in:

an example of which is:

That means solving:

Which gives a huge result. You can just select the one result, that is real and positive:

And use it to calculate the peak value with:

Which you can plot over values of lambda and Q:

And of course you can pick the Peak value for any set of lambda and Q values:

Success!
Luc

9-Granite
(To:LucMeekes)

Hi,

May I know how to use positive in the equation.

I try to do the same thing as you, but Mathcad can't be shown.

23-Emerald III
(To:J_power)

Sure. I see from Werner's results that Mathcad 15 provides the positive as second element of the result array. So, define

positive := ORIGIN+1

and use that to index the f() function.

Success!

Luc

24-Ruby V
(To:LucMeekes)

@LucMeekes wrote:

Sure. I see from Werner's results that Mathcad 15 provides the positive as second element of the result array. So, define

positive := ORIGIN+1

and use that to index the f() function.

Success!

Luc

Seems to apply only to the symbolic solution using numeric values as in my sheet.

When using the pure symbolic approach, the solution yielding positive values is the first one as in your MC11.

BTW, it seems not to be necessary here, but to be on the safe side we could use a small utility function to be sure to get the positive value:

Lucs method using the symbolic "solve" with all the variables undefined only works because Mathcad is capable enough to find all solution for f and so we can later pick the one we are interested in. Depending on the equation provided is easily possible that the symbolic solve would fail (more likely in MC15 than in MC11).