1

I'm figuring out complex algebraic calculation in gnu-calc.

Suppose: after many long calculation I got following algebraic expression:

-8 * a - 2 * b + 2 * b * i - 40 * i - 8

and I want the imaginary part of above expression so I do f i (M-x calc-im) .

-8 * im(a) - 2 * im(b) + 2 * re(b) - 40

Of course above is correct, However I want to a,b have a Real Values (i.e. im(a) = 0, im(b) = 0) for further calculations. So desired output for above is: 2 * b - 40.


Question: How to declare variables (in this case a and b) in Real number such that their imaginary part is 0 (for algebraic calculation)?

1 Answer 1

1

According to Gnu-Calc manual 6.6.1: calc-declare-variable (keybinding: s d) is used for declaring variable to be real, int, pos or within range of something e.g [0 .. inf).

In above case:

  • s d a RET real RET: makes variable a to be real
  • s d b RET real RET: makes variable b to be real.

After that, the imaginary part of -8 * a - 2 * b + 2 * b * i - 40 * i - 8 evaluates to 2 b - 40.


Apparently, another more convenient option is calc-edit-Decls (keybinding: s D). It will take you to matrix where you can edit all variable-declarations in one place:

Editing variable ‘Decls’Press ‘C-c C-c’ to finish, ‘C-x k RET’ to cancel.

[ [a, real],
  [b, real],
  [C, pos] ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.