Why wont my graphs plot? - math

f [x_] := (x + ln (x) - 3)
Plot[f[x], {x, 0, 5}]
This is my first time using wolfram and I don't see why my graph always comes out empty with no plots. What am I doing wrong?

Related

Line of Intersection between 2 Planes

I watched and tried to understand bunch of sites and videos about this, and I came into a weird conclusions and some questions. I need some help to explain which one of the method is right, or even both of them are right (but I got different result from each methods).
I'm sorry that I'm bad at explaining things, the first method is solve the equations normally. But, here the link for the video I tried to learn from
https://www.youtube.com/watch?v=o7CfCDkRwfY
Second method is to do cross product for the direction and find the point by set one of the variables as 0. https://www.youtube.com/watch?v=jozabh0lFmo
I tried for this example
x+2y+z−1=0
2x+3y−2z+2=0
and turned out for different answers. Is both of the method are correct, or which one? Thank you.
You have two equations with three unknowns.
You can eliminate one variable and solve for a relationship between the remaining two. Let's eliminate z.
Multiply the first equation by 2:
2x + 4y + 2z = 2
Add this to the second equation:
4x + 7y = 0
You can solve for y as a function of x:
y = -4x/7
Substitute this back into the first equation:
x - 8x/7 + z = 1
Simplify by combining the first and second terms:
-x/7 + z = 1
Solve for z:
z = 1 + x/7
Now you have an equation for the line in 3D space.
-inf <= x <= +inf
y = -4x/7
z = 1 + x/7
Both your equations are satisfied by these two points. Since two points are enough to define a line in Euclidean space I'd say I've got the correct answer.
This line goes through the point (0, 0, 1). It also goes through (7, -4, 2)
Here's a parametric representation of that line for -inf <= t <= +inf:
(x, y, z) = (0, 0, 1) + t*(7, -4, 1)
You can see that when t = 0 (x, y, z) = (0, 0, 1) (first point above) and when t = 1 (x, y, z) = (7, -4, 2) (second point above).
I didn't look at either of your videos. This is how I'd solve it.
This is high school algebra.

Plotting function of 2D space + time using Plot3D in Mathematica

Is there a simple way of plotting a function f(x,y,t) = Exp[t-x-y] by setting the time t? I've tried several variations of
Plot3D[Evaluate[f[t,x,y],t->0],{x,0,1},{y,0,1},PlotRange -> All]
But I can't get it to work. I want to be able to change t and see how the plot changes, but I'm also using the equation f for a differential equation so I'm taking partials and I need t to be symbolic for other parts of the notebook. Or is there a way to make a plot video that updates with time?
Expanding on the comments.
Interactively manipulate the plot
f[x_, y_, t_] := Sin[t x] Sin[t y]
Manipulate[Plot3D[f[x, y, t], {x, -Pi, 2 Pi}, {y, -Pi, Pi}], {t, 0, 3, 1/8}]
Generate a list of plots
plots = Table[Plot3D[f[x, y, t], {x, -Pi, 2 Pi}, {y, -Pi, Pi}], {t, 0, 3, 1/8}];
Export the plots to an animated GIF
Export["plots.gif", plots]

Why does R density function return nonzero values outside the interval [from, to]?

I have entered into the R code of the density function, and I have noticed the following strange lines:
lo <- from - 4 * bw
up <- to + 4 * bw
To my understanding, they mean that the density is estimated on the interval [from - 4*bw, to + 4*bw] instead of [from, to].
To really understand what is going on, I have created a densityfun function, which copy-pastes the code of density, except at the end in order to return a function (you can find the R code on GitHub here). Then I get the following:
set.seed(1)
x <- rbeta(10000, 0.5, 0.5)
f <- densityfun(x, from = 0, to = 1)
f(-0.01) # 1.135904
Surprise: f(-0.01) is nonzero!
It also implies that the integral of f on [0, 1] is not 1:
integrate(f, 0, 1) # 0.8787954
integrate(f, -0.1, 1.1) # 0.997002
So why is the density function written that way (is it a bug?), and what could I do to avoid this behaviour (to have f(-0.01) = 0 in this example) without loosing any mass on f (to have integrate(f, 0, 1) approximately equal to 1 in this example)?
Thanks!
EDIT: I have changed a bit the values used in the example.

Dynamic is not working properly

I'm having some troubles with the Dynamic command in Mathematica, the next code shows an interactive graphic of the function f(x) = 1 - x^2. The graphic's title also shows the current area under the curve (definite integral) which is modified using the slider.
Manipulate[Show[Plot[1 - x^2, {x, 0, 1}, PlotLabel -> Integrate[1 - x^2, {x, 0, Limite - 0.000000000001}]],
Plot[-x^2 + 1, {x, 0, Limite}, PlotRange -> {0, 1}, Filling -> Axis] ], {Limite, 0.000000000001, 1}, LocalizeVariables -> False]
I would like to show the current area using this command:
Integrate[1 - x^2, {x, 0, Dynamic[Limite]}]
but the result is not what i expected. Mathematica evaluates this like
0.529 - (0.529)^3 / 3
which is correct but i don't understand why it displays an expression instead of a single number. The //FullSimplify and//N commands just don't solve the problem.
Is there a better way to obtain the result?
Am I using the Dynamic command correctly?
Thanks!
With your example the Integrate command is performed once with a symbolic upper limit. When the value of that upper limit changes the integral is not recomputed. You will get your desired result if you move the Dynamic[] wrapper from the iterator specification and wrap it around the Integrate command, which will cause the integral to be recomputed whenever Limite changes.
Dynamic[Integrate[1 - x^2, {x, 0, Limite}]]

Graphing the result of NSolve

I'm trying to plot a parametric equation that was partially obtained using NSolve. Here's my attempted code:
VolumeDiff[v_] = 1.7 - v
SolveR[ v_] =
Re[NSolve[16 v^2 - 16 v*(r^3) + 3 (r^2) + 1 == 0, r, Reals]]
EnergyPos[r_] = r/2 (r + Sqrt[r^2 - 1])
EnergyNet[r_] = EnergyPos[SolveR[r]] + EnergyPos[SolveR[VolumeDiff[r]]]
ParametricPlot[{Re[EnergyNet[x]], 1.7 - 2. x}, {x, .1, 1.6}]
Basically, I have a cubic with two variables, I solve for one given the other and try to plot two parametric equations based on that original given variable. This is supposed to be a graph of energy vs. volume difference of two bubbles attached together. However, my axis are blank. I used NSolve to isolate the real root of the cubic equation and I guess Mathematica has a problem graphing with NSolve involved. I looked all over the internet but I couldn't find any answers to this. thanks for any help!
David
Several errors corrected.
You should read about how SetDelayed ( := ) and Solve[] work.
VolumeDiff[v_] := 1.7 - v
SolveR[v_] := NSolve[16 v^2 - 16 v*(r^3) + 3 (r^2) + 1 == 0, r, Reals][[1]]
EnergyPos[r_] := r/2 (r + Sqrt[r^2 - 1])
EnergyNet[r_] := EnergyPos[r /. SolveR[r]]+EnergyPos[r /. SolveR[VolumeDiff[r]]]
ParametricPlot[{EnergyNet[x], 1.7 - 2. x}, {x, .1, 2}]

Resources