# define function on two sets

Hi. I have two sets: X, Y. I want to define a function

F : X ->Y

and I have the values of f(x). I searched the net but found nothing. thanks.

define function on two sets

asked
**
2017-11-10 02:53:26 -0500
**

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi. I have two sets: X, Y. I want to define a function

F : X ->Y

and I have the values of f(x). I searched the net but found nothing. thanks.

Asked: **
2017-11-10 02:53:26 -0500
**

Seen: **24 times**

Last updated: **Nov 10 '17**

Function with Matrix input [closed]

defining function for graph (help needed)

Create multivariate function of a list of variables

How to dynamically substitute a variable in a callable function?

defining multivariate piecewise function

how to convert a named function to sympy

Function value at parametric path

What's wrong with my function syntax?

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

Your question is not very clear to me. I suppose that $X$ and $Y$ are finite sets. If you know a map from $X$ to $Y$ and you want to define it in SageMath, you may define a dictionary with keys $X$ and values $Y$ : define

`d = dict()`

and then`d[x] = y`

for all pairs $(x,y)$ such that $y = f(x)$. If on the other hand you have $f$ defined insomeway, such as a dictionary or something similar, and you want it truly as a function, you may write (I use the dictionary, known globally):Could you please provide the sets and the function you want to deal with in Sage ?