Work with functionsLesson 21 of 48 · 8 min

Respect logarithm branches

Use positivity assumptions when expanding logarithms and identify a complex counterexample.

Maths refresher: Inverse rules have conditions

For positive real numbers, exponentials and logarithms obey familiar inverse rules. Complex logarithms require a branch convention.

log⁡(ab)=log⁡a+log⁡b(a,b>0)\log(ab)=\log a+\log b\quad(a,b>0)
Worked example

For a=b=−1a=b=-1, log⁡(ab)=log⁡1=0\log(ab)=\log1=0 but the sum of the principal logarithms is 2πi2\pi i. Positivity is doing real work in the identity.

Maths prerequisite map ↗

A logarithm reverses exponentiation, but its domain and branch matter. For positive real inputs, log⁡(ab)=log⁡a+log⁡b\log(ab)=\log a+\log b. Extending that rule carelessly to complex values can change the answer by multiples of 2πi2\pi i.

Principal logarithms keep a branch
  1. Multiply first
    (−1)(−1)=1(-1)(-1)=1
  2. Then take log
    log⁡1=0\log1=0
  3. Take logs first
    log⁡(−1)+log⁡(−1)=2πi\log(-1)+\log(-1)=2\pi i
Starter reference. Over complex inputs, principal logarithms need not split across a product. The two paths differ by a full turn.

SymPy uses the principal logarithm for complex inputs. A branch specifies which value to use when several complex numbers have the same exponential. The principal branch uses a particular angle for each nonzero input. A rule for positive reals can give a different value on that branch. State assumptions before expanding a logarithm.

The counterexample uses a=b=−1a=b=-1. The product is one, whose principal log is zero, while each principal log of −1-1 is iπi\pi. Avoid force=True unless you have separately justified the missing conditions and will preserve them in the result.

Is the real-positive product rule automatically valid for every complex pair?

Write a prediction (optional)

Exact symbolic investigation

Select Run Python with the code unchanged.

Tools
About Python

Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗

Ctrl+Enter or ⌘+Enter runs Python.

Compare with the worked example

Executed from the published Python during the site build. Your own run appears above. Build environment ↗

Positive product expanded
log⁡(a)+log⁡(b)\log{\left(a \right)} + \log{\left(b \right)}
Power inside logarithm
12\frac{1}{2}
Unrestricted input rule
log⁡(z)2\frac{\log{\left(z \right)}}{2}
Positive input rule
log⁡(a)2\frac{\log{\left(a \right)}}{2}
Log of product (-1)(-1)
00
Sum of principal logs
2iπ2 i \pi
Worked text output
Positive product expanded: log(a) + log(b)
Power inside logarithm: 1/2
Unrestricted input rule: log(z)/2
Positive input rule: log(a)/2
Log of product (-1)(-1): 0
Sum of principal logs: 2*I*pi

Read the starter result

Compare Unrestricted input rule with Positive input rule. The positivity assumption allows the latter expansion. The two principal-log counterexample results show why multiplication alone does not justify a complex rewrite.

Edit and compare

Replace power = sp.Rational(1,2) with power = 2. Select Run Python and compare Unrestricted input rule with Positive input rule. Why can SymPy split off an exponent for a and still keep the log of a power for z?

Return to the editor

Scope. Complex branch cuts are a larger topic; this example establishes why forced rewrites need explicit justification.

Try a fresh case

What justifies splitting log⁡(ab)\log(ab) into log⁡a+log⁡b\log a+\log b in this lesson?

Choose an answer
Need a hint?
Hint 1

Test the negative pair in the example.

Hint 2

Identify which assumption rules that pair out.

Your notesNotes save in this browser when storage is available.