Skip to main content
10-Marble
September 2, 2025
Solved

Solving for unknown variable

  • September 2, 2025
  • 2 replies
  • 1164 views

Could anyone suggest how I can setup a function within Mathcad to resolve the attached expression where I am looking to find theta? 

Best answer by terryhendicott

Hi,

Can  you upload the Prime file please?

Cheers

Terry

2 replies

21-Topaz II
September 2, 2025

Hi,

Can  you upload the Prime file please?

Cheers

Terry

21-Topaz II
September 2, 2025
25-Diamond I
September 2, 2025

Its always a good idea to attach the Prime sheet itself and also state which version you are using (especially if you don't use the latest current version).

In the meantime you provided your sheet and also told us that you are using P10.

 

Actually what you did in your sheet worked, even though the result seems to look somewhat strange. The reason for this is that the symbolic engine in Prime unfortunately does not know anything about units and treats units as unknown variables. So it can't simplify the result.

A numeric evaluation (a simple = at the end) can do the job:

Werner_E_0-1756828886795.png

For this numeric evaluation to work you have to activate "Units/Constants in Symbolics" in the Calculation Options and then recalc the worksheet (Ctrl+F5). The symbolics still does not know anything about units but this option should ensure that units and constants (like g) remain labeled as units or constants.

Werner_E_1-1756828985205.png

As we can see returns the symbolics two different solutions and both are correct. Actually your equation has an infinite number of solutions.
The "assume" modifier should be able to select the solutions within a desired range, but this usually does not work as expected and in your case we have the additional problem of the units which the symbolics can't handle.

 

As you are just after a numeric result, I would second Terry's suggestion to use a numeric method like the "root" function. To be able to do so you have to get rid of the red errors (which affect the numeric engine but not the symbolic) by turning the expressions into function of the unknown angle theta as shown by Terry.

Then based on the equation you want to solve define a function f(theta) with the solutions as its zeros.

This function can now be used in the "root" function to get the solution within a desired range. You may be interested in the solution which is greater than zero but smaller than 360°

Werner_E_4-1756830293794.png

 

The "root" can also be used in a second way by providing a guess value:

Werner_E_3-1756830099760.png

As the last example shows there is no guarantee that the solution found will be near the guess, though.

 

Prime 10 sheet attached

 

 

10-Marble
September 2, 2025

Many thanks Werner,

How have you prepared this graph? 

Kind regards, 

Iain 

25-Diamond I
September 2, 2025

@IA_12699372 wrote:

Many thanks Werner,

How have you prepared this graph? 

?? There is nothing hidden and you can see in the sheet how its done.

 

EDIT: Ahh, actually there is something hidden! 😉

I used the so called quickplot feature which allows to use an undefined variable (in this case q) at the abscissa and as function argument.

Normally Prime would choose a range from -10 to +10 for q which is far to less if we use degree for the unit (has to be manually typed in in the appropriate place holder). To get a wider range for q we have to edit the plot. We can edit the first, second and last value on each of the two axis. I used -240, -180 and 400 (Prime automatically extends to 420) and did not change the automatically chosen values on the ordinate axis (but I had chosen MN*m for the unit instead of the default Joule).

 

A suitable (and often preferable) alternative to using the quickplot feature is to provide a range variable for the abscissa. It gives better and more visible control over the range to be plotted. But you can't set the scale step width (60 in the example I posted, the difference between the second and first value) that way.

Werner_E_0-1756833504392.png