Group Abstract Group Abstract

Message Boards Message Boards

How do I find all the zero's in a Conditional Expression for the given exp?

Posted 12 years ago

Hi all,

I am doing an assignment for school and I need to find the minima's and maxima's of 4 different functions. This is the case when their derivatives are equal to 0. The problem is that mathematica finds it very hard to find these zero's with the Solve function.

I also need to implement this in a machine so it has to be programmable. This means that I need a expression that gives the zero's for p = ... with all the constants in a ConditionalExpression. I can't give values to the constants yet since they are different for every segment/part. One of the formulas looks like this:

Xlinedp[p_] := dx -djep (-(1/4) Sqrt[3] dq ( 1 - Cos[a0 + da p]) Cos[dq p + q0] + 1/2 da Cos[a0 + da p] Cos[dq p + q0] - 1/4 Sqrt[3] da Sin[a0 + da p] Sin[dq p + q0] - 1/2 dq Sin[a0 + da p] Sin[dq p + q0])

p is the only variable since the rest of the constants are given for each part/segment. [0 > p <= 1] Is there anyway to solve this? Or is this formula just too hard for mathematica? I added the file I am working with, the constants are disabled and just implemented to test from time to time.

I hope anyone can help me or tell me I am working on an impossible solution

Cheers,

Wayne

Attachments:
POSTED BY: Wayne Roest
4 Replies
Posted 12 years ago
POSTED BY: Bill Simpson
Posted 12 years ago
POSTED BY: Wayne Roest
Posted 12 years ago

New users see the word "Solve" and assume this will find the answer to any problem. Human understanding of the definitions of words would make you think that. Solve is perhaps a poor choice of a name for that function. If it had been named "ThisDoesAGoodJobWhenYouAreAskingItToSolvePolynomialProblemsButProbablyNotTrigOrExponentialOrMoreComplicated" then there might be less confusion and waiting for answers that will never come. Or, behind the scenes Solve could peek at the problem, see it isn't a polynomial problem and likely never to "solve" and hand the problem off to other functions better able to find an answer. Reduce can sometimes find an answer that Solve cannot, but Reduce has other expectations and issues.

Is this closer to what your problem really is, with all the variables except p having exact known values with no decimal points anywhere?

In[1]:= a0 = -135*(Pi/180);
a1 = 135*(Pi/180);
da = a1 - a0;
djep = 450;
o0 = 0*(Pi/180);
o1 = 90*(Pi/180);
do = o1 - o0;
q0 = -360*(Pi/180);
q1 = 360*(Pi/180);
dq = q1 - q0;
r = 200;
x0 = 0;
x1 = 1000;
dx = x1 - x0;

In[15]:= Plot[dx - djep (-(1/4) Sqrt[3] dq (1 - Cos[a0 + da p]) Cos[dq p + q0] + 
     1/2 da Cos[a0 + da p] Cos[dq p + q0] - 1/4 Sqrt[3] da Sin[a0 + da p] Sin[dq p + q0] - 
     1/2 dq Sin[a0 + da p] Sin[dq p + q0]), {p, 0, 2 Pi}]

Out[15]= ...PlotSnipped...

In[17]:=N[Reduce[dx - djep (-(1/4) Sqrt[3] dq (1 - Cos[a0 + da p]) Cos[dq p + q0] + 
         1/2 da Cos[a0 + da p] Cos[dq p + q0] - 1/4 Sqrt[3] da Sin[a0 + da p] Sin[dq p + q0] - 
         1/2 dq Sin[a0 + da p] Sin[dq p + q0]) == 0 && 0 <= p < 2 Pi, p]]

Out[17]= p == 2.20997 || p == 6.20997 || p == 2.38766 || 
 p == 2.61234 || p == 2.79003 || p == 3.02473 || p == 3.11558 || 
 p == 3.30052 || p == 3.44698 || p == 3.67619 || p == 3.85618 || 
 p == 0.0820155 || p == 4.08202 || p == 0.251802 || p == 4.2518 || 
 p == 0.486734 || p == 4.48673 || p == 0.513266 || p == 4.51327 || 
 p == 0.748198 || p == 4.7482 || p == 0.917984 || p == 4.91798 || 
 p == 1.14382 || p == 5.14382 || p == 1.32381 || p == 5.32381 || 
 p == 1.55302 || p == 5.55302 || p == 1.69948 || p == 5.69948 || 
 p == 1.88442 || p == 5.88442 || p == 1.97527 || p == 5.97527

If I've misunderstood then perhaps you could explain what is known, what is unknown, and what the problem really is.

After you have evaluated the above code, but before doing anything else, you can compare the result from

NSolve[dx - djep (-(1/4) Sqrt[3] dq (1 - Cos[a0 + da p]) Cos[dq p + q0] + 
       1/2 da Cos[a0 + da p] Cos[dq p + q0] - 1/4 Sqrt[3] da Sin[a0 + da p] Sin[dq p + q0] - 
       1/2 dq Sin[a0 + da p] Sin[dq p + q0]) == 0 && 0 <= p < 2 Pi, p]

and the result from

Solve[dx - djep (-(1/4) Sqrt[3] dq (1 - Cos[a0 + da p]) Cos[dq p + q0] + 
       1/2 da Cos[a0 + da p] Cos[dq p + q0] - 1/4 Sqrt[3] da Sin[a0 + da p] Sin[dq p + q0] - 
       1/2 dq Sin[a0 + da p] Sin[dq p + q0]) == 0 && 0 <= p < 2 Pi, p]

where NSolve is sort of like an old calculator that just deals with digits and approximate answers, while Solve, and Reduce, want to give you trig functions and inverse trig functions and polynomials and... When I did N[Reduce[yourproblem]] above Reduce created a huge solution and then N turned into decimal approximations and made it dozens of times smaller and perhaps easier to understand and use.

To be honest, I'm surprised Solve was able to find an answer, I never expected that to work. I had tried Solve and Reduce, without telling it the values of all your other variables and waited long enough that I guessed it would never finish. Then I tried Reduce after telling it all the variable values and was happy to see an answer. As an afterthought I tried NSolve and Solve and got answers, but that only happened because I had already told it the values of all your other variables. That just shows that even if you think you know a lot about how Mathematica works, it can still do surprising things you didn't expect.

One tip, be really careful about using decimal points anywhere in a problem in Mathematica. If you insert a decimal point almost any place in a calculation the whole problem can turn into an approximate result. You may or may not want that. Experiment and see what happens.

POSTED BY: Bill Simpson
Posted 12 years ago

I am using mathematica 8.0.4 by the way.

POSTED BY: Wayne Roest
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard