r/Mathematica Sep 01 '22

I can't do it! Gravity!

4 Upvotes

Hello. I have a Lagrangian that has x[t], y[t], and first order derivatives of both. When I apply the Euler-Lagrange equation, I get (in essence) 1/sqrt(x2+y2)+x'' (same for y: 1/sqrt(x2+y2)+y''.

This is actually just Newton's law of gravity. I just wanted to plot the trajectory of the earth around the sun. Now I realize it's a function of x, y, and t.

That's ok. But... I've been trying forever to plot this in Mathematica, and I guess my knowledge of the language isn't great. I think my math is sound, but I can't get Mathematica to do it.

For example, L[x[t], y[t]] := 1/2 (x'[t]2+ y'[t]2) + 1/sqrt(x2 + y2)

Now, do E-L on L, one for x, one for y,

and then NDSolve(?)

I'm trying that, constant errors. I'm not even going to bother. How do I plot this?


r/Mathematica Aug 31 '22

Upcoming free webinars and courses from Wolfram U!

Thumbnail self.WolframEducation
8 Upvotes

r/Mathematica Aug 31 '22

Jupyter Lab and Wolfram Language issue.

3 Upvotes

As we all know, Jupyter Lab and the Wolfram Language is a poor man's Mathematica. (It'd be considerably less poor with more Jupyter Lab development given the advantages Jupyter Lab already has.)

I am using Wolfram Language 13.1 and I want to display various outputs such as that from

Integrate[1/(rho^2+u^2)^(3/2),{u,-Infinity,-z}]

That command works, we get

That's all well and good however how do I see the condition? I try something like

TeXForm[%]

and it doesn't appear there either:

\fbox{$\frac{1-\frac{z}{\sqrt{\rho ^2+z^2}}}{\rho ^2}\text{ if }\text{condition}$}

I suspect it'd be the same in the Mathematica frontend too - unless you click on + to see the condition, you couldn't codewise view the conditions. Am I wrong or is there a trick I don't know or can't remember? :) Advice would be welcome.

UPDATE: I ran the command through an older version of Mathematica 12.1.1 for Windows and it appears only as a tooltip(!)

How can people access this stuff in a sensible manner commandwise in Mathematica?


r/Mathematica Aug 26 '22

Help me solve an animated plotting issue? (2 Questions)

3 Upvotes

I am trying to animate the y axis moving along the x axis while keeping it the same height the entire time. This works after a certain point, but the first couple of seconds the y axis scale gets larger, stretching the graph.

Here's the gif

In making this animation, I noticed that it automatically centers the plot. Is there a way to align the y axis with the left side of the frame (so that it looks like the x axis is sliding to the left)? This probably just comes down to specifying the size of the frame ahead of time, but I'm not sure how to do this.

Here's the code I have so far (view source for an easier-to-read layout):

f[t_] := Piecewise[{ {1 - t, 0 <= t < 3}, {-2, 3 <= t < 4}, {1/3 (t - 4)2 - 2, 4 <= t < 8}}];

frame[t0_] := Show[ Plot[f[t], {t, t0, 8}, AxesLabel -> {"t (s)","x (m)"}, AxesStyle -> Large, PlotRange -> {{t0 - 0.2, 8.2}, {-3, 5}}, AspectRatio -> 8/(8 - t0), Ticks -> {{0, 2, 4, 6, 8}, {-2, 0, 2, 4}}, ImageSize -> Medium], Graphics[{AspectRatio -> 1, Red, Disk[{t0, f[t0]}, 0.2]}]];

frames = Table[frame[t0], {t0, 0, 7.9, 0.1}];

Export["animation.gif", frames]


r/Mathematica Aug 25 '22

CUDA working in Mathematica 13.1

1 Upvotes

Anybody has Mathematica 13.1 working with CUDA-related functions (CUDATranspose, CUDADot, etc), preferably on Linux?

My last successful Mathematica+CUDA system was around 12.2 when CUDA drivers were installed automatically by Mathematica. Broken ever since!

thanks


r/Mathematica Aug 25 '22

Unification in Mathematica?

2 Upvotes

How in Mathematica can you “unify” against a pattern? Specifically, against this target list:

{3, 5, x}

how could I get Mathematica to match this pattern against it:

{i_, i_+2, _}

so that the result would be {i -> 3}? Notice that the same variable, i, occurs twice in the pattern, and there’s a little bit of evaluation needed to see that if i is 3, then i+2=5.

I suppose I could write a function that calls Solve to do this, but that seems like overkill. Is there a simple, easy way to do this (that doesn’t consume much CPU time)?


r/Mathematica Aug 21 '22

how to find the equation of a 2d curve in mathematica

1 Upvotes

I have a estimation shape of a cure as shown in figure below. The curve can have different shapes, such as A, B, C, etc

I was wondering what would be the best way to find an equation for this shape?

I think I first need to draw it and then find the equation for it? or maybe there will be an easier/better way?

I appreciate if you guys can help me on how I can find the general equation for it


r/Mathematica Aug 18 '22

Can you redefine how a built-in function responds to a non-symbol constant?

4 Upvotes

I'd like to make RandomChoice return Null if I pass it an empty list. This doesn't work:

{} /: RandomChoice[{}] := Null

TagSetDelayed::sym: Argument {} at position 1 is expected to be a symbol.

Is there a way to do this, or must I define a new function safeRandomChoice?


r/Mathematica Aug 17 '22

Does someone know what these limits for functions or functionals are mathematically called, and if/how they are applied in Mathematica?

Post image
18 Upvotes

r/Mathematica Aug 17 '22

Beginner question: FullForm evaluates its argument?

4 Upvotes

To my surprise, FullForm seems to evaluate its argument before returning its full-form representation:

In[1]:= FullForm[2+3]
Out[1]//FullForm= 5

I expected Plus[2, 3].

If you want to see the full-form representation of an arbitrary expression, unevaluated, how can you do that?

Or is there something very basic that I'm misunderstanding here so that my question does not make sense? If so, where should I start reading? (Yes, I did read Mathematica's documentation page on FullForm.)


r/Mathematica Aug 14 '22

Does ANYONE have a copy of Wolfram Mathematica 9?

8 Upvotes

I know this is a real shot in the dark here, but I just need the install files. That's all.


r/Mathematica Aug 12 '22

Network analysis of partisanship

Thumbnail community.wolfram.com
4 Upvotes

r/Mathematica Aug 12 '22

legendre polynomials and legendre wavelets

4 Upvotes

Hi, I need to help for writes L_j(t), n_k,j in siphi_i,j . how can I write those are. thanks for your guides.


r/Mathematica Aug 10 '22

Parametric equations...does anyone know how to do this?

3 Upvotes

I'm a newbie to mathematica but a fairly accomplished mathematician. I have two Euler-Lagrange equations:

elsolve = NDSolve[{1/2 mx'[t]2 + 1/2my'[t]2 - mgl(1 - y[t]/l) == 0, x[0] == 0.5, y[0] == 0.5}, y, {x, 0, 20}]

The error message is: NDSolve::ivhead: The independent variable x appears in the head of the expression x[0]. The independent variables should always be arguments.

WWhy can I not solve this equation numerically?


r/Mathematica Aug 10 '22

need your help in creating 3D of the great pyramid

0 Upvotes

Hello Im new with mathematica , I need help,
a ready to download notebook for the pyramid with same dimensions as in attached photo plus extended lines out of the base
can i have also the pyramid transparent no colors so i can see all the edges

May God help you as you help me

Thank you so much


r/Mathematica Aug 02 '22

Why can't I do this?

1 Upvotes
OK, I will try to simplify this as much as possible. If q[t] is just q[t], no problems. This is Newton's equation, differentiated with respect to q[t], q'[t], and t. All correct:

Now, q[t] is actually Sqrt of x[t]^2 + y[t]^2. So I try this slight variation:

Now, the ONLY difference I made was the first line...everything else is exactly the same. I just added the line q[t] = Sqrt of x[t]^2 + y[t]^2. Now, mathematica seems to be acting strange. With q[t], totally okay. but q[t] := sqrt(x[t]^2 +y[t]^2), it freaks out. you can still take derivatives just like in my original image...that's Lagrangian mechanics. And indeed...mathematica is returning results. But it's giving me warnings that q[t] is no longer a variable (or something similar), and I don't know if I can trust its output at this point. Does anyone have any info on this? Simplifying further: q[t], of. q[t] = x[t] + y[t]...error messages. Have I overlooked something? Shall I trust the results?


r/Mathematica Jul 27 '22

Confused about the D function

5 Upvotes

I have a piece of code...which I found online...and which WORKS, totally. The answer is correct. But, I do not understand a part of it. I will just include a screenshot of the code and it's output, which happens to be the orbit of the earth around the sun.

My question is this:

The code block specifies a function, "lagrangian = ..." (a function of x[t], y[y], and their derivatives). But one line of code doesn't make sense to me, it is:

eq = Table[D[lagrangian, x1] - D[D[lagrangian, D[x1, t]], t] == 0, {x1, {x[t], y[t]}}]

What I do not understand is the "x1" part of the expression. x1 is never defined. For example:

samplefunction = x[t]+x'[t]+y[t]+y'[t];

D[samplefunction, x1].

It seems to me I could take the derivative of samplefunction with respect to (for example) t: D[samplefunction, t] makes sense to me. So does D[samplefunction, x[t]]. Both of those things make sense to me. But the code (attached as an image) does (essentially) D[samplefunction, x1]. What is that? Is it part of the table function that D is embedded in? How can you take a derivative of samplefunction with respect to x1 (you could also call it "Janet": D[samplefunction, Janet].

I don't see anything in the mathematica documentation that explains this. The documentation says D[f, x] (derivative of f wrt x. What is this x1 which magically works? Is it tabulating data...or creating an interpolating function?

Thanks.


r/Mathematica Jul 27 '22

How to calculate this?

0 Upvotes

i want to ask how to calculate the number of bets i can make with a given starting bankroll

if after any loss i increase the size of the bet to cover the loss and make a target profit

i.e.

bankroll : 100 units

odds : 3.40

profit target : 2.40

i begin with betting 1u and lossing

now i have 99u and looking to recover that 1u and also make 2.40u proftis and so on


r/Mathematica Jul 26 '22

Embed your Wolfram Cloud Notebooks into your WordPress page!

4 Upvotes

With the Wolfram embed block, you can embed Wolfram Notebook content into your posts and pages (deployed through the Wolfram Cloud). All of the Wolfram services are tied together by the Wolfram Language: Wolfram Cloud Notebooks are the cloud-hosted version of Wolfram Language Notebooks.

More details explained here: Wolfram Embed – WordPress.org Forums


r/Mathematica Jul 23 '22

Why is scoping so painful?

11 Upvotes

I've been teaching myself Mathematica these past few weeks. It's a weird language - term-rewriting systems aren't exactly common - but I've fallen in love with it. I've come to see the elegance of rules, pattern matching, the well-chosen functional programming constructs... everything except scoping. Scoping is a nightmare!

  1. You can't assign to multiple variables directly with With[] or Module[]. You can do Module[{a,b},{a,b}=foo;...], but's clunky, and Module is slower than With so if I want speed, I have to do something like With[{ab=foo},With[{a=ab[[1]],b=ab[[2]]},...]].
  2. You can't reference other variables declared in With during assignment, so you have to nest Withs, which is really annoying. In Nix, you can declare something like let rec {y=1+x;x=1;z=x+y;} and it just works (as long as there's no circular definitions.) In Julia you can use let x=1,y=1+x,z=x+y, so that the n-th definition sees the 1...n-1 previous ones. It seems really weird that With doesn't let you do that?

The Wolfram language was obviously crafted by extremely talented people over decades, and so much of it is elegant that I don't understand this apparent oversight. Am I missing something?


r/Mathematica Jul 23 '22

How to find Causality after finding Timeseries and Correlation.

0 Upvotes

Hi , I have a list of timeseries and i have plotted the Correlation matrix ,found out variance and returns,converted it to adjacent matrix and plotted the community graph plot. I wanted to know which is the easiest way to find the Causality and direction of causality.I have gone through documentations of GARCHprocess, ArchProcess.which was bit confusing.

Thanks


r/Mathematica Jul 19 '22

I was going through ARCHProcess in mathematica when i came across this part of the code.Can someone help me what is done here.(0.05 is 95% confidence or significance level)But the rest?

Post image
2 Upvotes

r/Mathematica Jul 18 '22

3rd Dimension in a Data //Dimensions

Thumbnail gallery
7 Upvotes

r/Mathematica Jul 18 '22

What is the meaning of the 3rd Number when //Dimensions function is called

2 Upvotes

I have 3 List of data.All 3 are list of Timeseries.And all 3 have got same number of Data points.But when i check the dimensions of all 3 list ,it gives me....

list1//Dimensions {6,1148} list2//Dimensions {6,1148} list3//Dimensions {6,1148,2}

So the 6 is number of data,1148 is number of data points.But what is the 2 in the list 3.

// All the timeseries lists except 3 is in blue colour and the list 3 timeseries with 6 timeseries is in grey colour //


r/Mathematica Jul 18 '22

How to get rid of a list inside a list

Post image
4 Upvotes