在python和mpmath.plot

问题描述 投票:0回答:1
考虑以下代码:

from math import cos, sin
import mpmath as mp

mp.plot([sin, cos], [0, 3]) # this is fine

l = [sin, cos]
mp.plot([lambda x: f(2*x) for f in l], [0, 3])
# this only plots sin(2x)!

我在这里缺少什么,或者是

plot

函数中的错误?
	

在此处查看相关的

文献。这是一个快速的修复程序,可以完成您想要的工作。
from math import cos, sin import mpmath as mp mp.plot([sin, cos], [0, 3]) # this is fine l = [sin, cos] mp.plot([lambda x, f=f: f(2*x) for f in l], [0, 3])

python lambda mpmath
1个回答
0
投票

© www.soinside.com 2019 - 2024. All rights reserved.