Jump to content

Infix

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
26 replies to this topic

#1
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
Convert to forms pre-fixed and post-fixed

1)
A + B*C - 5

pre-fixed
-*+ ABC5
post-fixed
ABC*+5-

2)
A/(B + C/D)

pre-fixed
/+/ ABCD
post-fixed
A/CD/B+

3)
(-B+sqrt(B**2-4*A*C))/(2*A)

pre-fixed
*/**-**sqrt+-BB24AC2A
post-fixed
B-B2**4AC**-sqrt+2A*/

Is correct ?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
1) your prefix version doesn't look right
2) your postfix version isn't right.
3) your prefix version doesn't look right
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

WingedPanther said:

1) your prefix version doesn't look right
2) your postfix version isn't right.
3) your prefix version doesn't look right

1) New the prefix is correct ? +A+BC-5
2) postfix ? ABCD/+/
3) prefix ? B-B24AC****-+2A/

Correct ?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
1) Now it isn't the same operations
2) Yes.
3) no.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

WingedPanther said:

1) Now it isn't the same operations
2) Yes.
3) no.

1) ABC*+5-

3) I do not know where is my mistake

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
1) yes
3) start with putting in parenthesis around EVERY operation. ((-B)+sqrt((B**2)-((4*A)*C)))/(2*A)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
It is:
B-C*A*4-B2**sqrt+A2*

?

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
That looks like an attempt at postfix. It was the prefix version that was wrong.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

WingedPanther said:

That looks like an attempt at postfix. It was the prefix version that was wrong.

Oh yes.

-B+sqrt**B2-**4AC/*2A

It is ?

#10
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Closer:
I'll step you through the first couple steps of rewriting this: ((-B)+sqrt((B**2)-((4*A)*C)))/(2*A)

Start with the item OUTSIDE parenthesis, which is /, that has to go first. Remove the wrapping parenthesis for each operand (I'm using [] to mark them, however).
/ [(-B)+sqrt((B**2)-((4*A)*C))] [2*A]

Now, dealing with the first operand, which is (-B)+sqrt((B**2)-((4*A)*C)), the outside operation is +, resulting in:
/+ [-B] [sqrt((B**2)-((4*A)*C))] [2*A]

Now, dealing with the first operand, which is -B, the outside operand is -, resulting in:
/+- [B] [sqrt((B**2)-((4*A)*C))] [2*A]

Now the first operand is just a single value, so we can move it, resulting in:
/+-B [sqrt((B**2)-((4*A)*C))] [2*A]

Keep going like this.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#11
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
I came in:
/+-Bsqrt-**B2**4AC*2A

???

#12
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Yes.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog