Vector as an exponent in Julia - vector

I have very basic question. I am new to Julia and used to code in R a lot. I need to take a scalar to the multiple powers, represented by a vector: 3^[2,3]. I got an error "Method error: no method matching ^...". I tried 3^Array([2,3]), but got the error again. At the same time, 3*[2,3] works as expected. Is there any way to do it in Julia without using for loop?

I think you are looking for the . or broadcast functions that allow you to apply any other functions elementwise!
3 .^ [2,3] or broadcast(^, 3, [2,3])

Small edit: you'll need a space after the number to be exponentiated, e.g. 3 .^[2,3].

Related

Factorial digit sum in APL (Project Euler 20)

First I found +/⍎¨⍕(!8) and it gave me the result 9. But if I do 100!, as the number is big, I am not able to get that.
With ⍎¨⍕(!100) I am getting a syntax error: ⍎SYNTAX ERROR
Is there any other way to solve the problem or can you suggest me some modifications?
!100 is a large number and when you format it's result you'll get a string representing a number in E notation.
⍕!100 → '9.332621544E157', when you attempted to eval (⍎) each character you ran into a syntax error since E has no meaning.
There are two ways to split a large integer into it's digits:
Firstly with inverse decode, examples can be found on the APLcart
10⊥⍣¯1!100
This is vulnerable to floating point imprecision, however.
The second and preferred option is using big from the dfns library, which can be imported using the quad function CY.
'big'⎕CY'dfns'
Examples here
And thankfully the last example covers your exact case! Factorial 100 is ↑×big/⍳100
The final solution to the problem could look like this:
+/⍎¨↑×big/⍳100

How does one perform the exp() operation element-wise in Juila?

I'm new to Julia and this seems like a straight-forward operation but for some reason I am not finding the answer anywhere.
I have been going through some tutorials online and they simply use exp(A) where A is a nxm matrix but this gives me a DimensionMismatch error.
I looked through the documentation on the official website in the elementary functions as well as the linear algebra section and googled it multiple times but can't find it for the life of me.
In julia, operations on matrices treat the matrix as an object rather than a collection of numbers. As such exp(A) tries to perform the matrix exponential which is only defined for square matrices. To get element-wise operations on matrices, you use broadcasting which is done with the dot operator. Thus here, you want exp.(A).
This design is used because it allows any scalar operation to be done on arrays
rather than just the ones built in to the language.
The broadcasting operator . always changes a function to "element-wise". Therefore the answer is exp.(A), just like sin.(A), cos.(A), or f.(A) for any user-defined f.
In addition to the above answer, one might also wish to consider the broadcast operator with function piping:
A = rand(-10:10, 3, 3)
A .|> sin .|> inv

Multiplication in R without using the multiplication sign

I like solving my math problems(high school) using R as it is faster than writing on a piece of paper. One problem I'm having is that I have to keep writing the multiplication sign, example:
9x^2 + 24x + 16 yields = Error: unexpected symbol in "9x"
Is there any way in R to multiply 4x, without having to write 4*x but only 4x?
Would save me some time in having to write one extra character the whole time! Thanks
No. Having a number in front of a character without any space simply isn't valid syntax in R.
Take a step back and look at the syntax rules for, say, Excel, Matlab, Python, Mathematica. Every language has its rules, generally (:-) ) with good reason. For example, in R, the following are legal object names:
foo
foo.bar
foo1
foo39
But 39foo is not legal. So if you wanted any sequence [0-9][Letters] or the reverse to indicate multiplication, you'd have a conflict with naming rules.

What is the command of output superfunction in mathematica?

I have two questions:
What is the command for a superfunction in Mathematica?
What is the difference between above superfunction and function in superspace which is odd variables times ordinary function? Are they the same thing?
In wikipedia, a superfunction S(z) of f is defined as S(z)=f(f(f(...f(t)))) (z total f's).
At 1: The command you're probably looking for is Nest:
In[1]:= Nest[f, x, 3]
Out[1]= f[f[f[x]]]
At 2: This doesn't look like a question for the Mathematica tag. It seems more physics/math related. I have added tags accordingly.
To address part 2 of your question:
Besides the prefix super-, there is no relation between superfunction (meaning an iterated function) and functions in super vector spaces.
Also, a superfunction is normally defined to be a map from a superspace to a supernumber, it does not have to be an odd element as stated in your question. See, e.g., section 1.10 of Ideas and methods of supersymmetry and supergravity.

Solve Physics exercise by brute force approach

Being unable to reproduce a given result. (either because it's wrong or because I was doing something wrong) I was asking myself if it would be easy to just write a small program which takes all the constants and given number and permutes it with a possible operators (* / - + exp(..)) etc) until the result is found.
Permutations of n distinct objects with repetition allowed is n^r. At least as long as r is small I think you should be able to do this. I wonder if anybody did something similar here..
Yes, it has been done here: Code Golf: All +-*/ Combinations for 3 integers
However, because a formula gives the desired result doesn't guarantee that it's the correct formula. Also, you don't learn anything by just guessing what to do to get to the desired result.
If you're trying to fit some data with a function whose form is uncertain, you can try using Eureqa.

Resources