/r/Mathematica

For information and tips about Mathematica features.

related reddits:

/r/Mathematica

0

Why am I getting self loops with this simple code when the main diagonal is all zeros?

ku = {{0, 40, 0}, {1, 0, 1}, {0, 15, 0}}

WeightedAdjacencyGraph[ku, EdgeLabels -> "EdgeWeight"]

3 Comments

2024/06/26

20:02 UTC

20:02 UTC

3

Hi guys.

Can someone help me undestand why the WignerD function is not satisfying the orthogonality relation for (j,m1,m2) = (1/2, 1/2, 1/2) and (j', m1', m2') = (1, 0, 0)?

7 Comments

2024/06/21

20:03 UTC

20:03 UTC

1

Is 28% off a good discount for the Home Premium Plus plan? Looking to get a good discount can wait for black friday or whatever.

0 Comments

2024/06/21

13:51 UTC

13:51 UTC

1

But at the same time, InputForm[3.1^10] gets me 81962.82869808013, a 16 digit machine number. So doesn't this show that $MachinePrecision should be 16 instead?

4 Comments

2024/06/19

17:03 UTC

17:03 UTC

0

0 Comments

2024/06/17

11:55 UTC

11:55 UTC

0

Explain the meaning of linear Programming? what is a linear Programming problem? Give the formulation of the general linear Programming problem? Explain with an example? Define feasible region, Objective function, Decision variables?

9 Comments

2024/06/15

08:07 UTC

08:07 UTC

5

https://youtube.com/shorts/wenBdDRpD4g?si=yO4OZHk6XnfjBwJj

We deeply integrate an AI assistant to our notebook interface. It is free. It can evaluate, edit, comment on cells and write in multiple languages.

The general idea is to utilize OpenAI API functions, we implemented the following functions:

- Get notebook structure (as json)
- Get cellâ€™s attributes (by uid)
- Get cellâ€™s content
- Set cellâ€™s content
- Get current cell (as uid)
- Make a request to Wolfram Alpha (knowledge base)
- Create new cell after or before the given one by uid
- Delete cell by uid

Combining it with ~3000 tokens initial system prompt giving the details of the notebook environment, used languages and libraries it works quite well as a sort of copilot.

Our project is open-source and free.

See more WLJS Notebook Github: https://github.com/JerryI/wolfram-js-frontend Docs: https://jerryi.github.io/wljs-docs/

7 Comments

2024/06/14

05:30 UTC

05:30 UTC

1

i am trying to create simple solar system simulation mine code for planets looks like this :

w7 = PolarPlot[puran/(

1 + \[Epsilon]uran*Cos[t + urak]), {t, 0, 2 \[Pi]},

Epilog -> {Green, PointSize[Large],

Point[{auran (1 - \[Epsilon]uran*

Cos[ResourceFunction["KeplerE"][\[Epsilon]uran, (2 \[Pi])/

Puran*(czas - tpuran)]])*

Cos[2*ArcTan[

Sqrt[(1 + \[Epsilon]uran)/(1 - \[Epsilon]uran)]*

Tan[ResourceFunction["KeplerE"][\[Epsilon]uran, (

2 \[Pi])/Puran*(czas - tpuran)]/2]] - urak],

auran (1 - \[Epsilon]uran*

Cos[ResourceFunction["KeplerE"][\[Epsilon]uran, (2 \[Pi])/

Puran*(czas - tpuran)]])*

Sin[2*ArcTan[

Sqrt[(1 + \[Epsilon]uran)/(1 - \[Epsilon]uran)]*

Tan[ResourceFunction["KeplerE"][\[Epsilon]uran, (

2 \[Pi])/Puran*(czas - tpuran)]/2]] - urak]}]}];

Where Polarplot creates an orbit outlier and rest is responsible for planet the variable connecting every plot is (czas) also when i use Animate function for one code everything works i just need to combine them in comments ill add picture of one plot. other variables are predetermined number or are correlated with current time to determine actual position.

3 Comments

2024/06/11

17:34 UTC

17:34 UTC

2

Hello,

how can I calculate the NullSpace of a row vector e.g (4, 2, 6) in mathematica.

A basis of the NullSpace would be a*(1/2, -1, 0) + b*(3/2, 0, -1).

When I try NullSpace[{4,2,6}] or Transpose[{4,2,6}] it doesn't work and it says

"Argument {4,2,6} at position 1 is not a non-empty rectangular matrix"

2 Comments

2024/06/09

19:10 UTC

19:10 UTC

2

Very new to Mathematica so I apologize if this is a stupid question.

I am trying to maximize the following function:

`(e - s)^\alpha - \frac{e^\beta}{s}`

Where:

`0 <= e <= 1 AND 0 <= s <= e`

Obviously the maximum value will depend on the parameters \alpha and \beta and that is exactly what I want i.e. I want a function of \alpha and \beta.

Is there a way to compute this is Mathematica? I have so far tried using the Maximize function but keep getting errors or non-sensical answers. Would appreciate any help.

Edit: I am using the following code:

`Maximize[{(e - s)^(a) - (e^(b))/s, 0. <= e <= 1 && 0. <= s <= e}, {e, s}]`

The output just returns the command.

3 Comments

2024/06/06

20:48 UTC

20:48 UTC

2

I just changed from Mathematica 12 to 14 and everything is so much larger. When I change the magnification from 100% to 75%, it only reduces the size of the text inside the input and output cells. The icons of the toolbar and text (and bar size) of the suggestion bar remains unaffected.

I have also found this to be peculiar, since my monitors are both 1920x1080 monitors (I have two).

Is there is anyway to make the everything (toolbar icons, suggestion bar font, suggestion bar size) smaller?

1 Comment

2024/06/05

07:32 UTC

07:32 UTC

2

This the thing that i'm trying to calculate.

Ne = ConditionalExpression[-((

2 f^2 (-Log[Sin[phik/(2 f)]] +

Log[Sin[1/

2 (ArcCos[-(f^2/(f^2 + mpl^2))] +

2 \[Pi] ConditionalExpression[1, \[Placeholder]])]]))/

mpl^2), And[

Element[

C[1], Integers], Cos[Rational[1, 2] f^(-1) phif] >= 0,

Cos[Rational[1, 2] f^(-1) phik] >= 0,

Tan[Rational[1, 2] f^(-1) phif] >= 0,

Tan[Rational[1, 2] f^(-1) phik] >= 0]];

Solve[Ne == 50, phik]

3 Comments

2024/06/05

01:05 UTC

01:05 UTC

2

I have a 3 component parametric function with randomly generated parameters:

```
function = {Sqrt[(0. + 0.0878006 t - 0.996037 Sin[2.97945 t])^2 + (0. +
0.31493 t + 0.0142161 Sin[2.97945 t])^2],
ArcTan[0. + 0.0878006 t - 0.996037 Sin[2.97945 t],
0. + 0.31493 t + 0.0142161 Sin[2.97945 t]],
0. - 0.945045 t - 0.0878006 Sin[2.97945 t]}
```

I want to find where the first component is equal to any of the values from the following list:`List = {3.10, 5.05, 8.85, 12.25}~Join~{29.9, 37.1, 44.3, 51.4}`

I know that there could be multiple solutions for t for each value in the list, so to find all the solutions I make a table of tables of solutions with FindRoot (with the intention of deleting duplicate solutions later), where I increment both the starting guess for t = t0, and the value from List.

```
NumTimesteps = 15
timeStep = 1
IntersectionTimes =
Table[Table[FindRoot[function[[1]] - List[[i]], {t, timeStep j, 0, Infinity}], {i, 1,Length[list]}], {j, 0, NumTimesteps}];
IntersectionPoints = Table[function /. IntersectionTimes[[i]], {i, 1,
Length[IntersectionTimes]}];
UniqueIntersectionPoints = DeleteDuplicates[SetPrecision[IntersectionPoints, 5]] // MatrixForm
```

This code finds a list of t values using FindRoot that satisfies:

` function[[1]] - List[[i]] ==0`

And to the best of my knowledge, if we plug those t values back into our function, then the first component of every 3 component vector function(t) should give a value in the List. However this is not the case. MOST of the first components are in the list, but notice in the output there is a first component of function(t) of 2.7361, which is NOT in the list. Further, the last line does not seem to delete duplicates. Anyone know what is going on here??

4 Comments

2024/06/03

18:20 UTC

18:20 UTC

1

I have this:

v = {1, 2, 5, 3};

var = {1, 2, x3, x4};

FindInstance[Intersection[var, v] == v, {x3, x4}, Integers]

Im expecting having this result:

solutions = {

{x3 -> 3, x4 -> 5},

{x3 -> 5, x4 -> 3}

}

However is giving me {}

What im doing wrong?. How i can fix it?

2 Comments

2024/06/03

09:44 UTC

09:44 UTC

1

as per title, thanks!

9 Comments

2024/06/02

18:15 UTC

18:15 UTC

12

This is a realtime animation made in WLJS Notebook with a simple FindShortestTour function.

Check the full story on medium if you are interested in implementation

1 Comment

2024/06/02

11:30 UTC

11:30 UTC

3

```
In[101]:= Limit[Gamma[x]/x^33, x -> Infinity]
Out[101]= Infinity
In[102]:= Limit[Gamma[x]/x^34, x -> Infinity]
Out[102]= 0
```

In reality, I believe `Gamma[x]/x^n`

for any large n has a limit of Infinity eventually

```
In[103]:= IntegerQ[Log[64]/Log[2]]
Out[103]= False
In[104]:= IntegerQ[Simplify[Log[64]/Log[2]]]
Out[104]= False
```

but 6 IS an integer

6 Comments

2024/05/29

14:36 UTC

14:36 UTC

1

Folks, what are some ways/approaches to create mathematical proofs. How could one use Mathematicas built in tools which integrate with OpenAI ChatGPT to solve the problem described ?

2 Comments

2024/05/26

22:34 UTC

22:34 UTC

1

For a presentation I chose to try to present the link between crochet and maths and I wanted to create a mathematical serie for a simple sphere pattern but I canâ€™t figure it out. If anyone could help me it would be with great pleasure !

0 Comments

2024/05/21

19:21 UTC

19:21 UTC

5

My daughter just graduated HS and will be majoring in applied math this fall. I use Mathematica once in a while as an EE and have it at work, but not heavily.

Is it worth me getting her the student version so she can take one of the online intro classes over the summer? Or should she just stick with pencil and paper? I figure it would be usefull for plotting, etc. she does know basic Python.

14 Comments

2024/05/21

16:37 UTC

16:37 UTC

1

I'm trying to tell Mathematica to make some replacements and I'm running into some problems.

The first one is the following:

1/f A.B.C /. B->(f D)

gives me

1/f A.(f D).C .

How do I tell Mathematica that f is a scalar?

The second one is probably related:

A.D.C f /. D f->C

doesn't change anything. I gues it's also because Mathematica doesn't know that f is a scalar. So again, how do I tell Mathemafica that f is a scalar?

1 Comment

2024/05/21

13:31 UTC

13:31 UTC

0

3 Comments

2024/05/19

01:56 UTC

01:56 UTC

1

Hi all, I'm struggling to understand why Mathematica spits out "0.0127 is not a valid variable." I assume it has something to do with the format of the BC's, but I couldn't figure out a solution. Here is my code:

```
(*Define parameters*)\[Rho]=8914.309767; (*Density*)
Cp=385.5928; (*Specific heat capacity*)
k=395; (*Thermal conductivity*)
R=0.0127; (*Radius of the cylinder*)
g=9.80665; (*Gravitational acceleration*)
T\[Infinity]=328.15; (*Ambient temperature*)
T0=295.9166667; (*Initial temperature at t=0*)
tmax=200; (*Maximum time for the simulation*)
\[Epsilon]=10^-6; (*Small positive value to approximate r->0*)
(*Solve the PDE using NDSolve*)
solution=NDSolve[{\[Rho] Cp D[T[t,r],t]==k (D[T[t,r],{r,2}]+(1/r) D[T[t,r],r]),T[0,r]==T0,(T^(0,1))[t,\[Epsilon]]==0,(T^(0,1))[t,R]+0.48 (g/(2*R))^(1/4)*((-0.0039142857 ((T\[Infinity]-T[t,R])/2)^2-0.0655238095 ((T\[Infinity]-T[t,R])/2)+1001.1128571429)*(-0.000000051428571 ((T\[Infinity]-T[t,R])/2)^2+0.000011954285714 ((T\[Infinity]-T[t,R])/2)-0.0000108)/(0.000000203583385 ((T\[Infinity]-T[t,R])/2)^2-0.000029440675203 ((T\[Infinity]-T[t,R])/2)+0.001503110306059)/(-2.31713716*10^-12 ((T\[Infinity]-T[t,R])/2)^2+5.5756112918*10^-10 ((T\[Infinity]-T[t,R])/2)+1.3315500052471*10^-7)*(T\[Infinity]-T[t,R]))^(1/4)*(T[t,R]-T\[Infinity])==0},T,{t,0,tmax},{r,\[Epsilon],R}];
(*Extract the temperature at the center of the cylinder (r->0)*)
temperatureAtCenter=T[t,\[Epsilon]]/. solution;
(*Plot the temperature at the center of the cylinder as a function of time*)
Plot[Evaluate[temperatureAtCenter],{t,0,tmax},PlotLabel->"Temperature at Cylinder Center (r -> 0) vs Time",AxesLabel->{"Time (s)","Temperature (K)"},PlotRange->All]
```

5 Comments

2024/05/18

02:52 UTC

02:52 UTC

1

Basically all my question is the one in the title, I got licenses for the version 14.0.0 of both products but I donâ€™t know which is their difference.

5 Comments

2024/05/16

17:18 UTC

17:18 UTC

7

I find myself constantly quitting the kernel and running the notebook from scratch. I don't want whatever cached artifacts there are from previous runs causing errors.

Compare Matlab, where I just run the script again and whatever values I set overwrite the values that exist. Why doesn't Mathematica work this way?

Quitting the kernel all the time can't possibly be the proper workflow.

What am I missing?

7 Comments

2024/05/16

01:47 UTC

01:47 UTC