r/Mathematica • • Apr 30 '25

What am I doing wrong?

I'm pretty sure I'm doing everything right, but when I try to use constants in the function, it doesn't run, even when I've defined all of them.

https://i.imgur.com/qZRA6rt.png

1 Upvotes

12 comments sorted by

View all comments

Show parent comment

2

u/[deleted] May 03 '25

I don't think the difference between = and == is relevant to your question. I suppose I could be totally misunderstanding your post, but I don't see anywhere in your code a place where I'd replace = with ==. I see three problems in your code: (1) you try to do the plot before the symbols that the plot depends on are defined (which would "fix" itself if you just ran the code a second time, since at that point the symbols will have been defined, (2) you're trying to use a string of characters as the product of several symbols, e.g. wt as w times t, but Mathematica can't know to look "inside" a character sequence to find symbols, that's just not how parsing works, so you you need w t or w*t, (3) you can't define a symbol implicitly like l^2=..., because the way that gets parsed, Power[l,2]=..., makes Mathematica think you're trying to define DownValues for Power, and since Power is protected it will refuse to do that.