Hi Arben,
Would please clarify the following terms: vector, array, matrix, expression?
And regarding the docs, what’s the difference between options and properties in a function?
Hi Arben,
Would please clarify the following terms: vector, array, matrix, expression?
And regarding the docs, what’s the difference between options and properties in a function?
PROBLEM PROBLEM PROBLEM
When I create a notebook and try y = ax^2 + bx + c, then
Expand[y^2] gives
ax^4 + 2 ax^2 bx + bx^2 + 2 ax^2 c + 2 bx c + c^2
in my notebook, which is incorrect,
while yours has
c^2 + 2 b c x + b^2 x^2 + 2 a c x^2 + 2 a b x^3 + a^2 x^4
which is correct.
I’m, using Mathematica 14.0.0 on Mac silicon. Here is my notebook
If you want to create a new question on Wolfram Community, please use the button “Start a new Discussion” on the right side of Community’s homepage.
Then use the instructions here: http://wolfr.am/READ-1ST
More info:
When I do “y = ax^2 + bx + c”, with explicit asterisk, then Expand[y^2] is correct
c^2 + 2 b c x + b^2 x^2 + 2 a c x^2 + 2 a b x^3 + a^2 x^4
Note: The preview removes the explicit asterisks. What works is
y = a asterisk x^2 + b asterisk x + c
Write “a x” with a space between a and x. Mathematica interprets the space as a multiplication.
Steven/Arben - I too am getting the INCORRECT result. I am also running Mathematica 14.0.0 on Mac silicon. (This might also explain some of the results I have been getting!)
I create a notebook and set y = ax^2 + bx + c. I then try Expand[y^2] and get the following:
ax^4 + 2 ax^2 bx + bx^2 + 2 ax^2 c + 2 bx c + c^2
I have attached my notebook and an image making it clear what element is incorrect in Mathematica’s answer.
Addendum to Lara’s explanation: “ax” is read as one symbol, as opposed to “a x” which is read (in the example case) as two distinct symbols of a numeric type, so the space is interpreted by Mathematica as an implied multiplication.
I don’t believe this is a space issue. The notebook shows input (w/o spaces) and the incorrect output.
Hey Coe—I’m not sure what you mean. The attached notebook is missing the spaces between the coefficients and thus produces the incorrect output. You want:
y=a x^2+b x+c
or, explicitly:
y=a*x^2+b*x+c
in order to get the correct polynomial expansion.
@ Steve, you can type your code between two backticks to prevent it from formatting via markdown, which is why the asterisks are being used for formatting rather than displaying.
Steven - I get the correct answer when using explicit multiplication:
y = a*x^2 + b*x + c
Why is this? Arben?
When I enter everything without spaces I get the wrong answer. When I enter WITH explicit asterisks, I get the right solution. The attached image shows what is entered and the result.
To be absolutely clear: this is equivalent to asking why var^2 does not return v^2 a^2 r^2. If you don’t type a space or an asterisk between two letters, there’s no way for the system to know that you’re talking about two separate symbols.
Bang head with hand. I forgot. Thanks.
I know you touched on this, but in exp = 1 + x^2, exp[[2, 1]] returns x, yet exp[[1, 1]] is longer than the depth of the object, why again?
exp[[2, 2]] returns 2, the second part of the second part, I’d expect exp[[1, 1]] to return the first and only part of the first.
In Wolfram Language, the structure of expressions and how they are indexed can sometimes be counterintuitive if you’re not familiar with the underlying representation. Let’s break down your example to understand it better.
Consider the expression exp = 1 + x^2. In Wolfram Language, this is internally represented as Plus[1, Power[x, 2]]. The head of this expression is Plus, and it has two arguments: 1 and Power[x, 2].
exp[[2, 1]] returns x because it’s accessing the first part (x) of the second argument (Power[x, 2]) of exp.
exp[[2, 2]] returns 2 because it’s accessing the second part (2) of the second argument (Power[x, 2]) of exp.
Now, regarding exp[[1, 1]], the confusion arises because 1 is an atomic expression in Wolfram Language (it does not have a head and arguments structure like Power[x, 2] does). Atomic expressions include things like numbers, symbols, and strings. When you try to access a part of an atomic expression, it results in an error or an unexpected result because atomic expressions are considered as having no parts.
So, exp[[1, 1]] is trying to access a part of the atomic expression 1, which doesn’t have any parts, hence the issue. In Wolfram Language, the parts of atomic expressions are not accessible in the same way as the parts of composite expressions.
When I’m using those terms, I mean:
vec[[n]].mat[[1,3]].a,b. a is an expression, Plot[x,{x,0,5}] is an expression, and so on.You can see more of the fun of conflicting definitions here.
It can happen even after a decade of using the language—I was once thwarted for an entire day by an errant curly/(“”“smart”“”) quote breaking a string expression when I first start working here!
[redacted]
Is anyone else experiencing problems with the question submission bar in bigmarker on Chrome? When I go to type, the text box turns white, with white text, rendering the text unreadable.