Ask Your Question
1

Plot real to complex function

asked 2024-06-16 18:27:38 +0100

ThePirate42 gravatar image

I have a function that has real domain and a complex co-domain. I want to plot the real and imaginary parts together, like this: imgur.com/a/yb7g5Ce

The code that I used to generate that plot (plot(real(F(x)),(-2,2)) + plot(imag(F(x)),(-2,2),color="red")) works, but I think every value is being calculated two times, discarding either the real or the imaginary part. Is there any way to get this effect more efficiently, without doing useless calculations?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2024-06-17 08:17:32 +0100

Emmanuel Charpentier gravatar image

updated 2024-06-17 10:35:33 +0100

FrédéricC gravatar image

From the Python documentation :

@functools.cache(user_function)

Simple lightweight unbounded function cache. Sometimes called “memoize”.

Returns the same as lru_cache(maxsize=None), creating a thin wrapper around a dictionary lookup for the function arguments. Because it never needs to evict old values, this is smaller and faster than lru_cache() with a size limit.

HTH,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-06-16 18:23:19 +0100

Seen: 150 times

Last updated: Jun 17