简体   繁体   English

实现多个嵌套函数

[英]Implementing multiple nested functions

I have a interesting equation I want to defined that has a Fourier transform with two equations inside of it. 我想定义一个有趣的方程式,其中包含一个带有两个方程式的傅立叶变换。

在此处输入图片说明

I'm not trying to solve for the differential equation, I can just represent as a normal function, L. 我并不想求解微分方程,我可以将其表示为一个正态函数L。

The other equations in this large equation are 这个大方程中的其他方程是

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Now as you can, these are some hefty functions to correlate. 现在,您可以将这些重要功能关联起来。 I'm not very experienced with nested functions and I don't know how to define what in order. 我对嵌套函数不是很有经验,也不知道如何定义顺序。 When i say in order, i mean that the most efficient way possible that computer understands correctly. 我说的是指计算机正确理解的最有效方法。

I would think to start out by defining my first function, L, but i don't know what to implement first, my first function, the fourier transform, or the functions inside the fourier transform then the fourier transfrom. 我想首先定义我的第一个函数L,但是我不知道首先要实现什么,我的第一个函数是Fourier变换,或者是Fourier变换内部的函数,然后是Fourier变换。 Any similar examples and tips will be greatly appreciated. 任何类似的例子和技巧将不胜感激。

Thank you. 谢谢。

Edit: I'm not asking anybody to code it all for me, i just want to understand what will be more efficient. 编辑:我不是要任何人为我编写全部代码,我只是想了解什么会更有效。 And yes there are values that have meaning, but you can treat them as constants. 是的,有些值具有含义,但是您可以将它们视为常量。

Generally: Start with the innermost parts that doesn't actually need to call any custom functions anymore. 通常:从最里面的部分开始,这些部分实际上不再需要调用任何自定义函数。 Ideally test them by executing them with some mock data, to ensure they work as expected. 理想情况下,通过使用一些模拟数据执行它们来测试它们,以确保它们按预期工作。 Then move on to the functions that require only the functions that you already defined. 然后转到仅需要已定义功能的功能。 Again, test run if possible. 同样,如果可能,请进行测试。 Rinse and repeat until you have defined the outermost function. 冲洗并重复直到定义了最外面的功能。

In your particular case, the three sub-equations are all independent, so you can implement them in any order (though I'd still start with whatever you feel is simplest). 在您的特定情况下,这三个子方程式都是独立的,因此您可以按任何顺序实现它们(尽管我仍然从您觉得最简单的东西开始)。 Then just plug them into the Fourier transform. 然后将它们插入傅里叶变换。

Pardon me for not using Latex features. 请原谅我不使用乳胶功能。 Let's say I have two equations 假设我有两个方程式

a/b = c
c+d = e

If you need to find e , you need to arrange equation 2 and plug it into equation 1 如果需要找到e ,则需要排列方程式2并将其插入方程式1

a/b = e-d

then rearrange 然后重新排列

e = d + a/b

then define your function 然后定义你的功能

def get_var_e(a, b, d):
   return d + a/b

Now if you need to get out a , the representation and choice of top-level equation will be completely different. 现在,如果需要找出a ,则顶级方程的表示形式和选择将完全不同。 You get the idea. 你明白了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM