The PTC Community is on temporary read only status in preparation for moving our community to a new platform. Learn more here
I often struggle to get Mathcad Prime to return symbolic solutions. I suspect I’m missing something in the way I set up or call the symbolic engine, so if anyone can point me to a good tutorial or explanation of best practices, I’d really appreciate it.
I’ve attached a worksheet with the equations. My goal is to obtain a single expression for γ as a function of h, α, and β.
At the moment I either get red evaluation errors or no result from the solver.
Any guidance on what I should change in my setup would be very helpful.
Thanks,
David
To avoid the red errors in the definitions (they stem from the numeric engine) you can use functions instead.
Of course this does not change the symbolics inability to solve the equation.
I am not sure if this means that there simply exists no general solution valid for any input value or if Prime's symbolics is too weak to find it.
If you have access to a more capable symbolic engine like Mathematica or Maple you may give your equation a try with them. Or you may use the Mathematica engine on Wolfram Alpha's website.
Thanks for the quick reply. I meanwhile noticed that I missed on the sign of y1 and the h can indeed be left out but that doesn't really change anything.
I was able to get a solution when using the solver block and inputs for alpha and beta, which proves that there is definitely a solution. However, when I change the guess value for gamma I get different results.
Checked with the 3D CAD model and for the example below the result should be 66.955°. Unfortunately I don't have access to another symbolics solver.
So only the sign in y1 was wrong?
There is an error in your solve block because the assignments you make there are always using the guess value of gamma and not the one you are trying to solve for!!
You may consider to parametrize the solve block so you can use it for any input values of alpha and beta.
Here is one possible way to get the correct answer:
In the meantime i also found a way to make the symbolic solve work. It seems to be choking on the square root.
So if we remove the square root on the right hand side and square the expression on the left hand side, Prime is willing to solve the equation and gives as two solutions for gamma.
I am not sure how to automatically decide for which input values we should use which of the two solutions. One of them seems to be always near zero.
If I chose always the first one, trap the "division by zero' error if tan(alpha)=0 and also copy with the tiny non-real values we sometimes get, we can create a 3D plot. But I fear that the areas where the function value is shown to be zero mainly stems from using the wrong of the two solutions?
I get more sensible(??) results using the solve block function, but it takes much more time to finish the calculations
If you are just looking for numeric results, I would strongly recommend to avoid using the symbolics but rather use a numeric method.
Either a solve block with "find", as you did, or the "root" function in one of its two flavours:
Prime 11 sheet attached
P.S.: According not having access to another symbolic solver - even if it may not be that comfortable, you always can try to use Wolfram Alpha in its (limited) free mode -> Wolfram|Alpha: Computational Intelligence
Ok, I was able to derive the formula the old school way on a piece of paper. If anyone knows how to get Mathcad to do that for me in the future, please do share. I added the simplified and corrected input for reference.
You did not restrict the values where alpha and beta should be chosen from when you asked here.
Now it looks like you assumed both angles to be within 0 and 90° so that all trig functions are positive reals. That way you can use sqrt(x2)=x rather than sqrt(x2)=|x|, correct?
Unfortunately Prime isn't good in respecting the "assume" modifier and so it seems not to be capable enough to come up with a simpler solution.
You test data 25 deg/60 deg shows the correct result this time if you compare it with the three different ways to calculate it shown in my answer above.
