Perl 6 (146|150)
The easiest way to do this is to just swap out the subroutines that implement the operators for new ones.
sub infix:«+» ($a,$b) { "(+ $a $b)" }
sub infix:«-» ($a,$b) { "(- $a $b)" }
sub infix:«*» ($a,$b) { "(* $a $b)" }
sub infix:['/'] ($a,$b) { "(/ $a $b)" } # stupid highlighter
sub infix:«**» ($a,$b) { "(^ $a $b)" }
# currently there seems to be a bug that
# prevents this from modifying the parser correctly
# probably because there is already a different operator with this name
# which has nothing to do with exponentiation
my &infix:«^» := &[**];
say 'a' ** (2 / 3) * 9 * 3 - 4 * 6;
# (- (* (* (^ a (/ 2 3)) 9) 3) (* 4 6))
The absolute minimum amount of bytes for doing it this way is:
sub infix:<+>{"(+ $^a $^b)"} # 29
sub infix:<->{"(- $^a $^b)"} # + 29
sub infix:<*>{"(* $^a $^b)"} # + 29
sub infix:<**>{"(^ $^a $^b)"} # + 30
sub infix:</>{"(/ $^a $^b)"} # + 29
146 bytes, although it makes more sense to count graphemes in Perl 6.
This assumes that "output the same expression in prefix notation" could just refer to the result of the expression, not necessarily the output of the program.
You would have to add say
in front of the expression to get the program to print it to STDOUT. (150 bytes)
3+4-5+6 = (((3+4)-5)+6)
or((3+4)-(5+6))
? \$\endgroup\$*
and/
have the same precedence, as do+
amd-
. \$\endgroup\$