Explanations On Entering Various Equations Into Mathematica?

  • #1
Ascendant0
152
33
I've had Mathematica for a long time, but up until now, I just used to use the free-form input. I'm trying to learn the language so that I'm able to do more with the software. However, the information I gather from the Wolfram site is worthless for a lot of things, as I don't understand what it's saying.

Say for example VectorPlot: https://reference.wolfram.com/language/ref/VectorPlot.html

The kind of vectors I was used to plotting for ODE would be things like this: ## dy/dx = 2y^3 - x^2 ##

Now, when they have {## v_x, v_y## }, I don't have the slightest clue how to take the ODE above, and enter it into this the way I'm supposed to in order to get the correct plot?

I'm wondering if there is some other resource that gives more thorough explanations on these types of things for starters? There are a LOT of Wolfram functions that I run into this issue with. No one in any of my courses ever touched on any of this, so I'm having to learn on my own, and I can't seem to find a good resource that makes sense of it?
 
Physics news on Phys.org
  • #2
  • Like
Likes Gavran and Ascendant0
  • #3
Ascendant0 said:
The kind of vectors I was used to plotting for ODE would be things like this: dy/dx=2y3−x2
How do you change that into a vector?
 
  • #4
Ascendant0 said:
Now, when they have {## v_x, v_y## }, I don't have the slightest clue how to take the ODE above, and enter it into this the way I'm supposed to in order to get the correct plot?
But in July you said:
Ascendant0 said:
What I don't know is a specific part of the VectorPlot command above, and this is become completely tangential and irrelevant to what I'm trying to learn. I've plotted direction fields multiple times now by hand, just wasn't sure with VectorPlot, but I think I've figured it out between your previous help and testing various equations. I appreciate it.
You thought that you had "figured it out" back then. What's changed about your understanding?
 
  • Like
Likes Vanadium 50 and Ascendant0
  • #5
Dale said:
How do you change that into a vector?
The first step would be to find a general solution, then I'd be able to make the vector field out of that by plotting points and determining the slope at those points.

For this particular problem, I don't have time to solve right now. But, I'm assuming you're asking because the first step before I can have Mathematica plot the vector field, is that I'd need to find the general solution (and I am familiar with the DSolve command, at least somewhat). So to make it simpler, say my general solution to an ODE is:

## y = 2y^2 + 3x^4 -ce^x ##

In that instance, how would I enter that as VectorPlot to get the correct vector field?
 
  • #6
renormalize said:
But in July you said:

You thought that you had "figured it out" back then. What's changed about your understanding?
1) That topic went from utilizing Mathematica, to asking if I knew how to plot a direction field by hand. Doing it by hand was never the issue, that is when it became tangential. I know all the math, I just don't know how to take that math and plug it into Mathematica properly

2) Thank you for pointing that thread out. I'm going to use that to try and refresh myself. I just started college again two weeks ago after an 8yr layoff. In that time, I went through extreme family trauma with my children, moving multiple times, and pretty much a living hell. So, a lot of it fell out of my head over those years. Then, when I finally got things in check to go back to college, I had about six months to brush up on my first two years, but while doing so, had to continue taking care of my kids, working, and life in general. So, I crammed so much stuff in such little time that I haven't retained 100% of it.

So, apologies that I'm bringing something up that I thought I had down then. It's just that the Mathematica site itself doesn't actually explain how to go about entering certain things. It just tells you "here's the command to do x", but with no explanation as to how to go about taking that type of equation and actually entering it into the Mathematica command correctly. To make it worse, a lot of the sites I find that go over the same things lazily cut and paste exactly what Mathematica has on their website, so it does me no good.
 
  • #7
renormalize said:
But in July you said:

You thought that you had "figured it out" back then. What's changed about your understanding?
Ok, so tying into my last reply, this is why I *thought* I had it down, but something is wrong here...

I attached a screenshot below of your VectorPlot. As you can see above and to the left of yours, I typed in the same exact VectorPlot literally verbatim, and yet I got a blank graph with nothing on it. This is what I'm not getting, and the type of thing I keep running into. I *think* I understand something and know how to work it, then next thing you know, I type something in like this, and get a blank graph. This has happened for multiple things lately, which has led me to believe there is something I'm missing here.

But, I really don't have the slightest clue why yours worked, meanwhile I typed the same exact thing, and mine didn't give me a vector plot???
Issues.png
 
  • #8
Ascendant0 said:
The first step would be to find a general solution, then I'd be able to make the vector field out of that by plotting points and determining the slope at those points.

For this particular problem, I don't have time to solve right now. But, I'm assuming you're asking because the first step before I can have Mathematica plot the vector field, is that I'd need to find the general solution (and I am familiar with the DSolve command, at least somewhat). So to make it simpler, say my general solution to an ODE is:

## y = 2y^2 + 3x^4 -ce^x ##

In that instance, how would I enter that as VectorPlot to get the correct vector field?
Not exactly. I was asking to get you to think about how you get a vector field. A vector can be written as ##(x,y)##. This isn't a Mathematica thing, it is a math thing. VectorPlot expects to be given a function that returns a vector. So the first step in determining how to plot the correct vector field is to write what you want to plot as a vector.

## y = 2y^2 + 3x^4 -ce^x ## is not a vector.
 
  • Like
Likes jedishrfu
  • #9
Ascendant0 said:
But, I really don't have the slightest clue why yours worked, meanwhile I typed the same exact thing, and mine didn't give me a vector plot???View attachment 351014
Note your input line In[3]. The variables that VectorPlot uses to plot are shown in green ("x" & "y"). Notice that "xy" is in blue, which means it's an undefined variable. You have to write "x y" with a "space" in-between to signify multiplication of x times y. This is very elementary in Mathematica, which makes me ask how much experience you have using that software?
 
  • Like
Likes Ascendant0
  • #10
renormalize said:
Note your input line In[3]. The variables that VectorPlot uses to plot are shown in green ("x" & "y"). Notice that "xy" is in blue, which means it's an undefined variable. You have to write "x y" with a "space" in-between to signify multiplication of x times y. This is very elementary in Mathematica, which makes me ask how much experience you have using that software?
Thank you for that. I never would've figured that out on my own. I compared them multiple times, but missed that.

As far as experience, I'm a newcomer. I think I mentioned it somewhere here, but I've had Mathematica for years, but even when I used it occasionally years back, I only used the free-form input. I never had the free time to learn the language. But, I know I'm going to need to learn either this or Matlab in the future, so trying to ease my way into it now. I just couldn't find a good source to start me from the ground up that explains things like that. One of the links someone else provided here brought me to something I think might be what I need, so I'm going to try to give that a shot as I have time.
 
  • Like
Likes renormalize
  • #11
When I was getting started with Mathematica it sometimes felt like the authors of the online help were bedazzled by their own brilliance. Many of the examples were elegant models of terseness and economy, showcasing the author's virtuosic command over the language. But sadly, not ideal as far as easing the beginner's progress. But with time and practice you learn to handle that. Plus, you can always post here with a specific point of confusion -- but of course you know that.
 
Last edited:
  • #12
Most programming texts make it appear that the language is simple and elegant. However, everyday life is fraught with conditionals, loops, and indirections that can drive one mad.

The conditionals handle the edge cases where one variable has to stay within some range, and the loops handle cases where there's more than one way to do something and the indirections when you realize that you're dealing with a more complicated set of data that may be represented in a table or by itself.

Elegant code is like poetry, whereas practical code is more like plumbing with a patchwork of fixes to make it work correctly. Elegant code is minimal but minimal code is hard to maintain when changes are needed.
 

Similar threads

Replies
9
Views
838
Replies
5
Views
2K
Replies
4
Views
3K
Replies
8
Views
4K
Replies
14
Views
4K
Replies
10
Views
3K
Replies
3
Views
2K
Replies
3
Views
6K
Back
Top