Message Boards Message Boards

0
|
7863 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Limitations of Wolfram|Alpha concerning mathematics?

Posted 8 years ago

Hi, I have some questions about abilities and limitations of Wolfram Alpha concerning mathematics: 1) Can I use programming structures (loops, assigning commands)? (If yes then how - can you please give some basic example of assigning a value to variable and using it and can you also give an example of using loop statement?) 2) Is there some list saying what from Mathematica language is and what is not implemented in Wolfram Alpha? 3) (Concrete example) Having list consisting of lists (eg {{1,2},{3,4,5}}) how can I write a function to get a list containig sums of elements of the containing lists? So for my example the result will be {3,12} (because we have two lists containing in our list - {1,2} and {3,4,5} - and sum of elements in first, resp. second list is 3, resp. 12).

POSTED BY: Jan Pernicka
2 Replies

Specifically to the question of summing the sub-lists of a list of lists like {{1,2}, {3,4,5}}, in Mathematica (with Wolfram Language), the full form of this would be List[List[1,2], List[3,4,5]]. For the task at hand, we want to operate on the sub-Lists themselves (by doing Plus on their arguments instead of List) while leaving the outer List essentially intact. The WL function Apply (operator form: @@) is used for swapping out an expression's head, so: Apply[Plus, List[1,2]] or Plus @@ {1,2} Would be the first step to sum a single given list.

The other step is to realize that we have a higher level List structure which we want to keep essentially intact, and only operate on its arguments (the sub-Lists). To do that, you want to use a common idea in WL of "level specification" which many functions support, to act specifically at certain "levels" of the expression: https://reference.wolfram.com/language/ref/Apply.html

We want Apply to act at level 1 of the overall expression (e.g. on the sub-Lists), so we can do: Apply[Plus, List[List[1,2], List[3,4,5]], {1}] ...which conveniently has a shorthand but not at all obvious operator form of "@@@" !

So, shortest form (I think) would be: Plus @@@ {{1,2},{3,4,5}} ...which returns the desired: {3,12}

POSTED BY: Andrew Walters

For that kind of things you may consider trying the free Wolfram programming lab http://www.wolfram.com/programming-lab/

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract