Hidden WordScanner
Private scans · No account required

DuckieDai Log Properties

Expand a log of a product, quotient, power, or root into simpler logs, or condense a sum of logs back into a single log, in log, a chosen base, or ln.

exponential functions · MIT License

Overview

Expand a log of a product, quotient, power, or root into simpler logs, or condense a sum of logs back into a single log, in log, a chosen base, or ln.

  • Owner-tested on a TI calculator
  • Version 1.0.0
  • 2851 bytes
  • Uses math

Before you run it

  • TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
  • TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
  • Every variable is assumed to be positive, so each log is defined.
  • Products are written with *, and sqrt( ) counts as a power of 1/2.
  • A sum or difference inside the log, such as x+1, is kept whole, because the log of a sum cannot be split.

Try the DuckieDai calculator screen

Follow the program's prompts and result flow before downloading.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

Learn the math

How to expand and condense logarithms

The idea

A logarithm turns multiplication into addition. Because of that, the log of a product, quotient, or power can be split into a sum of simpler logs, called expanding, and a sum of logs with numbers in front can be packed back into one log, called condensing.

Expanding helps when you need to differentiate or simplify; condensing helps when you solve an equation, because one log on each side can be undone. The same three rules work for log, ln, and a log in any base.

The formula

log(xy) = log(x) + log(y)

log(x/y) = log(x) - log(y)

log(x^n) = n log(x)

product rule
the log of a product is the sum of the logs
quotient rule
the log of a quotient is the log of the top minus the log of the bottom
power rule
a power inside a log moves to the front as a number; a square root is the power 1/2

Using the program

Worked example

Expand log((x^3*y^2)/z^4). Choose 1, then 1 for log, and type (x^3*y^2)/z^4.

log(x^3) + log(y^2) - log(z^4) = 3log(x) + 2log(y) - 4log(z)

The program shows RESULT: 3log(x) + 2log(y) - 4log(z).

Expand log_2(8x/sqrt(y)). Choose 1, then 2, base 2, and type 8*x/sqrt(y). log_2(8) is 3, so the program shows 3 + log_2(x) - (1/2)log_2(y).

Condense 2ln(x) + 3ln(y) - ln(z). Choose 2, then 3 for ln, type 3 terms, then 2 and x, 3 and y, and -1 and z. The program shows ln((x^2*y^3)/z).

Tips and common mistakes

Where this comes up

The properties of logarithms are a core part of the logarithmic functions unit of algebra 2, precalculus, and college algebra, and calculus uses them for logarithmic differentiation.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. from math import log
  2. def P(s):print(s);input("[enter]");print("\n"*11)
  3. def fmt(v):
  4. if abs(v-round(v))<1e-9:return str(int(round(v)))
  5. for d in range(2,101):
  6. n=round(v*d)
  7. if abs(v-n/d)<1e-8:return str(n)+"/"+str(d)
  8. return str(round(v,6))
  9. def st(s):
  10. while s[:1]=="(" and s[-1:]==")":
  11. d=0
  12. for i in range(len(s)):
  13. d+=(s[i]=="(")-(s[i]==")")
  14. if d<1 and i<len(s)-1:return s
  15. s=s[1:-1]
  16. return s
  17. def sp(s,o):
  18. r=[];l=0;d=0
  19. for i in range(len(s)):
  20. c=s[i];d+=(c=="(")-(c==")")
  21. if d==0 and c in o and i>l:r+=[s[l:i],c];l=i+1
  22. return r+[s[l:]]
  23. def val(s):
  24. s=st(s)
  25. if "/" in s:a,b=s.split("/");v=float(a)/float(b)
  26. else:v=float(s)
  27. if v-v:raise ValueError("Not a number")
  28. return v
  29. def bi(s):
  30. d=0
  31. for i in range(len(s)):
  32. c=s[i];d+=(c=="(")-(c==")")
  33. if d==0 and i and c in"+-" and s[i-1] not in"^*/(" and not(i>1 and s[i-1] in"eE" and s[i-2] in"0123456789."):return 1
  34. return 0
  35. def at(s,c=1):
  36. s=st(s)
  37. if bi(s):return [(s,c)]
  38. p=sp(s,"*/")
  39. if len(p)>1:
  40. r=[];g=1
  41. for q in p:
  42. if q=="*":g=1
  43. elif q=="/":g=-1
  44. else:r+=at(q,c*g)
  45. return r
  46. p=sp(s,"^")
  47. if len(p)==3:return at(p[0],c*val(p[2]))
  48. if s[:5]=="sqrt(" and s[-1:]==")":return at(s[5:-1],c/2)
  49. if not s:raise ValueError("Missing factor")
  50. return [(s,c)]
  51. def ex(s,L,b):
  52. k=0;T={};O=[]
  53. for t,c in at(s.replace(" ","")):
  54. try:
  55. n=val(t)
  56. if b:
  57. e=round(log(n)/log(b))
  58. if abs(b**e-n)<1e-8*max(1,n):k+=c*e;continue
  59. except Exception:pass
  60. if t not in T:O.append(t);T[t]=0
  61. T[t]+=c
  62. o=fmt(k) if abs(k)>1e-10 else ""
  63. for t in O:
  64. c=T[t]
  65. if abs(c)<1e-9:continue
  66. f=fmt(abs(c));v=("" if f=="1" else "("+f+")" if "/" in f else f)+L+"("+t+")"
  67. o+=((" - " if c<0 else " + ")+v) if o else ("-" if c<0 else "")+v
  68. return o or "0"
  69. def cn(L):
  70. n=int(input("# of terms? "));t=[];u=[]
  71. for i in range(n):
  72. c=val(input("Term "+str(i+1)+" coef? "));a=input(" Inside? ").strip()
  73. if not a or c==0:continue
  74. p=a if not any(h in a for h in "+-*/^") else "("+a+")"
  75. f=fmt(abs(c))
  76. if abs(c)!=1:p+="^"+("("+f+")" if "/" in f else f)
  77. (t if c>0 else u).append(p)
  78. s="*".join(t) or "1"
  79. if u:s=(s if len(t)<2 else "("+s+")")+"/"+(u[0] if len(u)<2 else "("+"*".join(u)+")")
  80. return L+"("+s+")"
  81. def ch():
  82. while 1:
  83. c=input("1 log 2 log_b 3 ln? ").strip()
  84. if c=="1":return "log",10
  85. if c=="3":return "ln",None
  86. if c=="2":
  87. try:
  88. b=val(input("Base? "))
  89. if b>0 and b!=1:f=fmt(b);return "log_"+("("+f+")" if "/" in f else f),b
  90. except Exception:pass
  91. print("Base >0, not 1")
  92. P("DuckieDai TM\nLOG PROPERTIES\n __(o )> quack!\nhiddenwordscanner.com")
  93. while 1:
  94. c=input("1 Expand 2 Condense\n3 Quit? ").strip()
  95. if c=="3":break
  96. if c not in("1","2"):continue
  97. L,b=ch()
  98. try:
  99. if c=="1":print("Use * : (x^3*y^2)/z^4");a=ex(input("Inside log? "),L,b)
  100. else:a=cn(L)
  101. print("\n"*11);P("RESULT:\n"+a)
  102. except Exception as e:P("INPUT ERROR:\n"+str(e))
Filename
LOGPROPU.py
Size
2851 bytes
SHA-256
7e06684afae5a8f5adeafffa3cd173dbdcc61bb92b6715b16c642542995a145d

Usage

Inputs

  • 1 to expand or 2 to condense
  • The log: 1 log, 2 log with a base you choose, or 3 ln
  • To expand, what is inside the log, written with * and / such as (x^3*y^2)/z^4
  • To condense, how many terms, then each term's number in front and what is inside

Outputs

  • The expanded expression, such as 3log(x) + 2log(y) - 4log(z)
  • The condensed single log, such as log(x^3/y^2)
  • Whole numbers in place of logs of exact powers of the base, such as 3 for log_2(8)

Units: Pure expressions; no units.

Assumptions and limitations

Assumptions

  • Every variable is assumed to be positive, so each log is defined.
  • Products are written with *, and sqrt( ) counts as a power of 1/2.

Constraints

  • A sum or difference inside the log, such as x+1, is kept whole, because the log of a sum cannot be split.
  • Numbers may be decimals or fractions such as 1/2; a base must be greater than 0 and not 1.

Known failures

  • Two factors written side by side without *, such as 2x, are treated as one factor.
  • Typing something other than a whole number for the number of terms shows INPUT ERROR with Python's own message.

Compatibility and review

Review status
Owner-tested on a TI calculator
Tested on
Owner reports personally running this program on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
What happened
Owner reported pass on the calculator before two fixes: a sum or difference inside the log, such as x+1*y, is now kept whole instead of being split at the *, which gave a wrong answer, and inf or nan typed as a number now shows INPUT ERROR: Not a number. Every other step is unchanged; this exact file has not yet been rerun on a calculator.
Dependencies
math
Suggested calculator name
LOGPROPU — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Transfer and launch

Download the .py file, send it to your calculator with TI Connect CE as LOGPROPU or another name, then open the Python App and try the worked example on this page first. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.

Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.

Version history

Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.