Python - 函数乘法的积分 [英] Python -the integral from function multiplication

查看:58
本文介绍了Python - 函数乘法的积分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 python 中,我有两个函数 f1(x)f2(x) 返回一个数字.我想在它们相乘后计算一个定积分,即:

In python, I have two functions f1(x) and f2(x) returning a number. I would like to calculate a definite integral after their multiplication, i.e., something like:

scipy.integrate.quad(f1*f2, 0, 1)

最好的方法是什么?在python中甚至可能吗?

What is the best way to do it? Is it even possible in python?

推荐答案

我刚刚发现我可以使用 lambda :)

I found out just a second ago, that I can use lambda :)

scipy.integrate.quad(lambda x: f1(x)*f2(x), 0, 1)

无论如何,我要把它留在这里.也许它会帮助某人.

Anyway, I'm leaving it here. Maybe it will help somebody out.

这篇关于Python - 函数乘法的积分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆