FindMaximum Mathematica: Get Numerical Value from Cos[t]

  • Mathematica
  • Thread starter Nusc
  • Start date
  • Tags
    Mathematica
In summary, the conversation discusses the use of the Evaluate function in Mathematica to output a numerical value for Cos[t]. The NMaximize function is suggested as an alternative to FindMaximum, which may not always give the greatest maximum. The importance of consulting the help files is also mentioned.
  • #1
Nusc
760
2

Homework Statement



Do[
If[..,
Print[Plot[N[Cos[t]] == 0, {t, 0, 10}], ","
"Time to reach 1=", t /. Last[FindMaximum[N[Cos[t]], {t, 5}]], ","
Cos[t]

]

]
,{c,0,10},{b,0,100}]




I need Cos[t] to output a numerical value as obtained from FindMaximum, how do I do this?

Homework Equations





The Attempt at a Solution



Evaluate won't work.
 
Physics news on Phys.org
  • #2


Please post a complete code example or attach your .nb file (click the paper clip in the reply window)

That said, it looks like you're missing commas at the end of your third and fourth lines. You may also need to look into using the Evaluate[] function in your fourth line.
 
  • #3


That piece should suffice. Does anyone else know what I'm talking about? You don't even need to put this in a loop.
If I put this command in Mathematica
"Time to reach 1=", t /. Last[FindMaximum[N[Cos[t]], {t, 5}]], ","
How can I make Mathematica evaluate
Cos[t]

numerically using the command that found t above?
 
  • #4


Also how do you insert a linebreak to prevent Mathematica from writing output all across the page? I'm in math type and cannot use text.

I got my expression to evaluate so don't worry about the above post.
 
Last edited:
  • #5


Actually wait, I take that back

For each x there is a corresponding density function. Most are aperiodic and so will attain a maximum at a different time than the others. Unfortunately I did not take this into consideration and only used the following command.

"Time to reach 1=", den21 /. Last[FindMaximum[N[den21], {t, 2}]], ","

The interval 0-2 is short and some attain a maximum at t = 10, how do I implement this into the script?
 
  • #6


Unfortunately, Maximize[] doesn't give you the greatest maximum but only the first maximum.
 
  • #7


Code:
If[..,
is not working code. Obviously.

Try the NMaximize[] function. Like all numerical functions, it is not without error and will find incorrect solutions occasionally, but those cases are rare (I've only seen one).

The help files are really your friend when looking for a specific Mathematica function. You can get to them with the "F1" key, or get quick help by placing a ? mark in front of the command you want:
Code:
?NMaximize

Glad you figured out how to use the Evaluate function ... :rolleyes:
 

1. How do I use the FindMaximum function in Mathematica?

To use the FindMaximum function in Mathematica, you need to provide the function you want to maximize and the variable you want to maximize it with respect to. For example, if you want to find the maximum value of the cosine function with respect to t, you would use the following syntax: FindMaximum[Cos[t], t].

2. How do I get the numerical value from the FindMaximum function in Mathematica?

To get the numerical value from the FindMaximum function in Mathematica, you can use the N function. For example, if you want to get the numerical value of the maximum of the cosine function with respect to t, you would use the following syntax: N[FindMaximum[Cos[t], t]]. This will return a decimal approximation of the maximum value.

3. Can I specify a range for the variable in the FindMaximum function in Mathematica?

Yes, you can specify a range for the variable in the FindMaximum function in Mathematica by adding a third argument to the function. For example, if you want to find the maximum value of the cosine function with respect to t in the range of 0 to 2π, you would use the following syntax: FindMaximum[Cos[t], {t, 0, 2π}].

4. Can I use other functions instead of Cos in the FindMaximum function in Mathematica?

Yes, you can use other functions instead of Cos in the FindMaximum function in Mathematica. You can use any function that takes a numerical input and returns a numerical output. Some examples include Sin, Exp, Log, and Sqrt.

5. Is there a way to visualize the result of the FindMaximum function in Mathematica?

Yes, you can use the Plot function to visualize the result of the FindMaximum function in Mathematica. For example, if you want to plot the maximum value of the cosine function with respect to t in the range of 0 to 2π, you would use the following syntax: Plot[FindMaximum[Cos[t], {t, 0, 2π}], {t, 0, 2π}]. This will plot the maximum value as a point on the graph.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
255
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
216
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top