Ask Your Question

Plot real to complex function

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

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:

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

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

Emmanuel Charpentier gravatar image

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

FrédéricC gravatar image

From the Python documentation :


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.


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


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

Seen: 86 times

Last updated: Jun 17