Can't generate plot in Wolfram Mathematica 8 - wolfram-mathematica

I have this function: Plot[{(sin (x)), (sin^2 x)}, {x, -2*[Pi], 3*[Pi]}]
When i'm trying to execute this function in Mathematica, i've got only this graph:
How can i set to see the lines of the graph in Mathematica? In wolfram alpha it's ok, here not.
Thanks.

You need to use the correct syntax, try
Plot[{Sin[x], Sin[x]^2}, {x, -2 Pi, 2 Pi}]

Related

Solving an equation in terms of unknown constants wolfram mathematica

I want to solve the following equation. I want to get an expression of x in terms of unknown constants alpha and beta. Does anyone know how to solve this in Matlab or Mathematica?
Thanks.
Here's my one line code in wolfram Mathematica.
'Assuming[alpha>beta>0,Solve[Cos(alpha*Cos(x)) + Cos(beta*Cos(x)) -1.96 ==0,x]] '
Since it doesn't appear simple to get an analytic solution, perhaps a graphic showing the behavior might provide some insight about what to do next.
ListPointPlot3D[Reap[Do[
{alpha, beta, x} = RandomReal[{0, 2 Pi}, 3];
If[alpha > beta,
err = Norm[Cos[alpha*Cos[x]]+Cos[beta*Cos[x]]-1.96];
If[err < .01, Sow[{alpha, beta, x}]]
],{10^6}]][[2, 1]], ViewPoint->{0, -2., 0}]
Once that displays on your monitor you can either adjust the numbers inside that Viewpoint or you might be able to place your mouse inside the graphic, press and hold the left mouse button and drag to rotate the image around.
That graphic seems to show that the solutions lie within a fairly well defined region.
Once you have looked at this then you might bump the range of the random numbers up to {0,4Pi} because it looks like there is more interesting behavior for larger values of alpha and beta.

Mathematica won't NIntegrate fairly simple equation, even tho Wolfram Alpha has no issue

Here's my input:
NIntegrate[sqrt[1 + (.00035 x^2)^2], {x, -625, 625}]
The result is:
NIntegrate::inumr: "The integrand sqrt[1+1.225*10^-7\ x^4] has
evaluated to non-numerical values for all sampling points in the
region with boundaries {{-625,0}}."
This links me to a page where I basically am told that I have to define x. Isn't that exactly what the range given as a second argument is doing? What am I not doing here?
I can put the exact same syntax into WolframAlpha and get the right answer:
Mathematica is fussier than Wolfram Alpha about its input syntax. Try
NIntegrate[Sqrt[1 + (.00035 x^2)^2], {x, -625, 625}]

How to export a 3D animation in Mathematica?

I'm trying to visualize molecular vibrations in Mathematica and make some 3D animations using commands something like this:
Animate[Graphics3D[{x[t],y[t],z[t]}],{t,tmin,tmax}]
I couldn't find a way to export it. There are official documents for 3D graphics and 2D animations. I tried most of those filetypes but failed. If it's not possible, then a 2D gif being looked at a certain angle is acceptable. Any suggestion will help.
This just worked.
In[1]:= x[t_]:=Sin[t];y[t_]:=Cos[t];z[t_]:=t;
plots = Table[
ParametricPlot3D[{x[a+t], y[a+t], z[a+t]}, {t,0,2 Pi}], {a,5}]
<<<snip plots>>>
In[4]:= ListAnimate[plots]
<<<snip animation>>>
In[5]:= Export["animate.avi", plots]
Out[5]= "animate.avi"
<<<find your file in your Mathematica folder and run your exported animation>>>
All just mimicking the second example in
http://reference.wolfram.com/mathematica/howto/ImportAndExportAnimations.html

Plotting a step function in Mathematica

I'm trying to plot a couple of UnitStep functions, but for some
reason, Mathematica won't plot the whole function - Just the top (it doesn't look like a step, more like a line).
How do I tell mathematica to plot it all?
An alternative to setting Exclusions -> None is to set ExclusionsStyle -> {style} if you want to draw the line segments connecting the discontinuities in a different style from the rest of the curve. For example
Plot[Round[n], {n, 0, 5}, ExclusionsStyle -> {Dashed}]

Possible to put equation's expression near its graphic representation?

Is it possible that when I Plot a function in Mathematica, it will automatically put near it it's equation(i.e. y = 2x) or even some other text?
At first glance I don't find any option for it, but if there is one I'd like to know.
Thanks
Using Mathematica 6 or higher, I often use Tooltip to help me identify plot curves:
Plot[Tooltip[Sin[x]], {x, 0, 8 Pi}]
Alas, this is only useful when using the graph interactively since you must hover the mouse cursor over the curve. It doesn't work so well on paper or on a static image.
You can use the Epilog option to manually place some text on the plot, as in this example:
Plot[
Sin[x], {x, 0, 8 Pi},
Epilog -> Text["My Text", Offset[{32, 0}, {14, Sin[14]}]]
]
Tweak the arguments of Offset to taste.
This works if you do not mind manual placement. Automatic placement poses some challenges, depending upon the kinds of functions that you wish to plot. But if you know something of the general characteristics of the functions of interest, you could write a function that calculates nice looking values for the Offset arguments. For example, if I knew I was going to plot lots of exponential decline functions, I might define something like the function myPlot in this example:
SetAttributes[myPlot, HoldAll]
myPlot[function_, {var_, min_, max_}] :=
Plot[
function, {var, min, max},
Epilog -> Text[function, Offset[{40, 0}, {var, function} /. var -> min + (max - min)/20]],
PlotRange -> All, AxesOrigin -> {0, 0}
]
... where the arguments to Offset are computed automatically using some arbitrary constants that work reasonably well for these kinds of plots:
Manipulate[
myPlot[1000 E^(-d t), {t, 0, 100}, "My Label"],
{d, 0.01, .2}
]
Since all of these options are programmable, the sky's limit as to how much sophistication you could code up for the label placement. Of course, such programming drifts farther and farther away from the ideal of a built-in option to Plot that just magically drops on some text next to the function. Mathematica 8 or 9 maybe :)
One way to do this, which automatically associates the expression with the style used to plot it, is to use the PlotLegends standard add-on package. The output doesn't look very good by default; I recommend setting the LegendShadow -> None option and using Style on the expressions you stick in the legend to make them look better. Also, loading the package inflicts some funny redefinitions on Plot and related functions which can break some other things if you're not careful.
"Near its equation" is the problem. This isn't an easy problem to solve, and it becomes somewhat impossible when you start getting "busy" graphs with overlapping plots and so on.
I don't have a good example to show, but usually I'll define a "labelling function" that takes the same input as the function being plotted, which places a dot on the graph and writes some text nearby. This has the advantage of being able to easily vary the location of the text but still have it tied to the function.

Resources