How do you define a symbolic multiplicative function?

asked 2024-02-06 17:20:46 +0100

anonymous user

Anonymous

I would like to define a symbolic function $f$ from $\mathbb{Z}$ which takes values in $-1,1$. This function $f$ is completely multiplicative (i.e: $f(mn) = f(m) f(n)$ for all $m,n \in \mathbb{Z}$). I know how to define a symbolic function in Sage:

f = function('f')

But I don't know:

  1. How do I specify to Sage that I want $f$ to be multiplicative? For example, I want $f(6) = f(2)f(3)$ to hold true, and so on.
  2. How do I specify to Sage that $f$ takes values in $-1,1$? That is, I need $f(n)^2 = 1$ for all $n \in \mathbb{N}$. How do I specify this?
edit retag flag offensive close merge delete

Comments

You could make an ExpressionTreeWalker to do substitutions. What is your end goal?

rburing gravatar imagerburing ( 2024-02-08 11:15:18 +0100 )edit