Message Boards Message Boards

0
|
3863 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Solve a simple equation with Reduce[ ]?

Posted 7 years ago

Hi! I have just started trying out Mathematica and I thought I’d try to solve a simple equation but for some reason I get no solution, the computation appears to get stuck or something.

First I define a function like this:

F[omega_, theta_, r_] := -2*omega - 
  2*ArcTan[((r*Sin[omega - theta])) ? ((1 - r*Cos[omega - theta]))] - 
  2*ArcTan[((r*Sin[omega + theta])) ? ((1 - r*Cos[omega + theta]))]

Seems to work fine.

Then I try to set it equal to a constant, and solve for theta given values for r and omega, I also limit theta to a certain range. I also indicate that I am only interested in real values. At least that is what I think I do with the following expression

Reduce[F[Pi/4, theta, .99] == Pi/4  && theta > 0.001*Pi && theta < 0.999*Pi, theta, Reals]

Obviously I am doing something wrong! Does anyone have any hints or suggestions to help a total beginner? Thanks in advance!

POSTED BY: Mattias A
2 Replies
Posted 7 years ago

While the " ? " you have in your expression looks like division, it looks "funny" and not like the usual "/". It is not uncommon for new users to get hit with a special character like that and I sometimes say "You just got fonted."

Next, the forum posting software also seems to sometimes interpret * as an indication to delete the * and switch to italic font. In fact while I was typing this paragraph I saw that it ate my * and I had to go back and insert a \ in front of each of those so that you could see those *. When anyone tries to copy and paste from the forum to a notebook can then sometimes run words together and cause all kinds of problems. I had exactly that problem trying to scrape your code into my notebook and couldn't decide whether you had thought you could run variables together and have it work. Then I noticed the slight italic display of your code. So I just got fonted.

It is possible when posting to scrape with the mouse to highlight a section of code and then tap Ctrl-K on your keyboard. That tells the posting process to display that highlighted section as code and will sometimes do less desktop publishing on it.

So here is my modification of your code when I replaced your " ? " with "/" and inserted "*" and used Ctrl-K.

F[omega_, theta_, r_] := -2*omega - 
  2*ArcTan[((r*Sin[omega - theta]))/((1 - r*Cos[omega - theta]))] - 
  2*ArcTan[((r*Sin[omega + theta]))/((1 - r*Cos[omega + theta]))]

Before using Reduce I often find it useful to peek at the function.

Plot[F[Pi/4, theta, .99], {theta, 0.001*Pi, 0.999*Pi}]

which gives me

enter image description here

You are wanting Reduce to tell you where your function F is equal to Pi/4 and that graph seems to hint that this is going to be difficult to do.

Can you use all this to go back to the problem and see if you can uncover any other problems? Or perhaps you can find where I made a mistake.

POSTED BY: Bill Simpson

Function definitions are ought to be done as follows:

F[omega_, theta_, r_] := ....

Furthermore, Reduce does not 'like' inexact numbers (e.g. 0.99). You can use Rationalize to turn them in to exact fractions:

Reduce[F[Pi/4, theta, 99/100] == Pi/4 && theta > 1/1000 Pi && theta < 999/1000 Pi, theta, Reals]

which evaluates to:

True

So that means that means your expression is False.

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

Group Abstract Group Abstract