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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Symbolic solution as system of real equations

BartB
1-Visitor

Symbolic solution as system of real equations

Hello,

I have a system of two equations with 2 unknown variables to solve symbolically. Numerically I get 9 solutions:7 real and 2 complex. I need equations only for those 7 real solutions. Always only one of them gives me answer in allowed range. I need solution as equations to find correct values of vairables in allowed range for chosen parameters (T,M). I tried to assign results of Find to a variable and matrix but none of it worked. I always get error that the variable is undefined. Can anyone help me, please?

9 REPLIES 9
Werner_E
25-Diamond I
(To:BartB)

Do you really need a symbolic solution in T and M or would a function of T and M which gives you the x and y values be sufficent.

How would you get a numeric solution (as you wrote)? For which values of T and M? Can we assume T and M as reals? Can we assume anything else abou T and M?

Mathcads symbolics says the result is to big to display. So it finds a "solution", but in contrary to what Mathcad says we cannot use it for later calculations as we are not allowed to assign it a variable. This means that the solution consists of some case distinctions (ifs and otherwise statements) which may not really helpful anyway. If you have Prime you may try to convert the sheet, as Prime will show you the long expression, I think. But I guess it will not be any helpful at all.

BartB
1-Visitor
(To:Werner_E)

Werner Exinger wrote:

Do you really need a symbolic solution in T and M or would a function of T and M which gives you the x and y values be sufficent.

How would you get a numeric solution (as you wrote)?

If I can implement this function without mathcad it would be sufficient. I already wrote Matlab function that gives me correct values for given T and M but it only work there.

For which values of T and M? Can we assume T and M as reals? Can we assume anything else abou T and M?

T and M are real and form determined small range not bigger than 10 (for example 10-19)

This means that the solution consists of some case distinctions (ifs and otherwise statements) which may not really helpful anyway. If you have Prime you may try to convert the sheet, as Prime will show you the long expression, I think. But I guess it will not be any helpful at all.

Can somehow get a solution in that form? I have only Mathcad 15.0. I want to implement solutions in an embedded device to calculate x and y with determined T an M, so it might be acutally helpful.

AlanStevens
17-Peridot
(To:BartB)

Attached is a worksheet that uses the symbolic solver to get all the (numerical) solutions (given values for T and M) and then selects the pairs of real solutions.

I've made up values of T and M that happen to give 7 real and 2 complex solutions, biut obviously, you will need to change these to the values you need.

Alan

Werner_E
25-Diamond I
(To:BartB)

I was also playing around with just numeric solution. See attached for a function dependent on T and M. It will give you just one solution, though, which is dependent on the guess values.

So if this is something a value to you, it would be more helpful to turn Alan's calculations into a function of T and M as it will give you all solutions without having to mess around with suitable guess values.

Concerning Prime - unfortunately no succeess. First in Prime we are not allowed at all to evaluate a solve block symbolically. But even when we use the symbolic solve (see at the end of the attached sheet) we get the same message in Prime3 as in Mathcad15 - "expression too long to display; ....". So not useful either.

I understand that you want to implement the calculation in an embedded system and so you would have no use for all those numeric solutions. As it seems Mathcad won't give us a useable symbolic expression.

So as it looks to me your options are:

  • look if another program would give you something symbolic you can use
  • implement a decent numeric solver yourself 😞
  • as T and M are take from a rather small range you may also consider to use a lookup in a table of precalculated values

Werner Exinger wrote:

... it would be more helpful to turn Alan's calculations into a function of T and M

It didn't seem to work when I tried this!

Alan

Werner_E
25-Diamond I
(To:AlanStevens)

Using symbolics in programs can be very tricky and for me its always a matter of trial and error as I still don't understand whats going on exactly.

I remember an older thread where someone asked if it would be possible to give a function, which is only defined for symbolics, kind of a wrapper to make it useable numerically, too (and to be able to plot it). I thought I had found a solution but it turns out that it wasn't as the newly created function just looked like it would be evaluable numerically but in effect it wasn't. As far as I remember Richard jumped in and a solution was found which would only work in MC11 (the version the poster had used). Something similar happened here. The function I created looks like it would yield numeric results (we can use the numeric 😃 but the result isn't pure numerics - not sure what we should call it.

Anyway look yourself, see attached.

EDIT: Found that thread /thought it was older): http://communities.ptc.com/message/197737#197737

Werner Exinger wrote:

Using symbolics in programs can be very tricky and for me its always a matter of trial and error as I still don't understand whats going on exactly.

Nor me! But I think your suggestion works ok.

Alan

Werner_E
25-Diamond I
(To:AlanStevens)

But I think your suggestion works ok.

It works for single values only (which may suffice here) but it seems not to be possible to write a function which yield true numeric values. So if we woul be intereseted in a plot, say we want to plot the x value (of the first solution which is in a given range) for a constant T over a range of M values. This seems not to be possible as plotting of those non-numeric values would be refused.

See some helpless attempts at the end of the attached file.

BartB
1-Visitor
(To:BartB)

Thank you Alan and Werner for your effort. I hoped there would be a chance to get exact symbolic solution in MathCad. But having two much more experienced MathCad engeneers than me working on the problem and couldn't find a way to get those results I looked for another way and yesterday I came up with an idea to get an approximated equation.

As I said, I already had a Matlab function that generated numeric results and found a one pair x y that is in the specified range (for each combination of T and M always only one pair was correct). So I generated two matrices of x and y results for each T and M combination - a look up table as Waren suggested. But implementing it to the embedded device wouldn't work, as it would be always a discreate set of results (I'll have to aproximate if T or M would not be in it) and looking through it would be too time consuming (when table would have the resolution of possible T and M values it would be huge). So for each matrix [x T M] and [y T M] I fited a polominal that aproximates the results and in that way I got the symbolic equation for the set of the results that are from the allowed range. The error of this aproximation do not exceed 1% and for most cases its less than 0.3%, almost half is aproximately 0. Ithnk, for now I don't have a better way to get the equations I need with smaller error.

Announcements

Top Tags