
数函:L=L_1 e^(-t/t1)+L_2 e^(-t/t2)+L_3 e^(-t/t3) 已知 L,L1 、L2 、L3 、t1 、t2 、t3 () 求:t 小弟不才,请大佬帮忙看一下 是否有软件可以计算
1 douglas1997 2020-05-07 09:36:25 +08:00 我个人感觉用牛顿法或者梯度下降法应该可以解决这个问题吧,可以尝试一下。给定一个 t,然后看 L(t),再看 L(t)-L 以及 L'(t),之后不断迭代即可。 |
2 douglas1997 2020-05-07 09:38:39 +08:00 哈哈突然想到一个想法,你用 PyTorch,将这个式子写出来,然后用梯度下降去优化,只有一个可导参数 t,估计迭代 20 次就能得到结果。存在的问题可能是解不是唯一的问题。 随便想想,如果有专业的软件还是用专业的软件吧。 |
3 xcstream 2020-05-07 09:43:07 +08:00 wolfarmalpha |
4 zst 2020-05-07 09:44:04 +08:00 via Android mathematica 吧 |
5 douglas1997 2020-05-07 09:58:30 +08:00 哈哈随手写了一个,仅供参考~ ``` import torch import math # y = 0.11, t=20 def fx2(t): return 2*math.exp(-t)+3*math.exp(-t/2)+6*math.exp(-t/5) def fx(inputs): return inputs[0]*torch.exp(inputs[1]*t)+inputs[2]*torch.exp(inputs[3]*t)+inputs[4]*torch.exp(inputs[5]*t) inputs = torch.Tensor([2, -1, 3, -0.5, 6, -0.2]) t = torch.ones(1, requires_grad=True) y = 0.11 optimizer = torch.optim.SGD(params=(t,), lr=0.5) criterion = torch.nn.MSELoss() for i in range(2000): optimizer.zero_grad() y_pred = fx(inputs) loss = criterion(y_pred, torch.Tensor([y])) loss.backward() optimizer.step() print (i, loss) print (t) final_t = t.item() print ("t: {}, y: {}, y_pred: {}".format(final_t, y, fx2(final_t))) ``` 最后结果`t: 20.136356353759766, y: 0.11, y_pred: 0.10706461213461692`。 |
6 douglas1997 2020-5-07 10:00:18 +08:00 |
7 noqwerty 2020-05-07 10:10:18 +08:00 |
8 princelai 2020-05-07 10:39:56 +08:00 看起来像连续复利贴现公式 |
9 847272105 OP @douglas1997 我测试一下谢谢 |
13 fancy111 2020-05-07 10:55:27 +08:00 方程求解,有现成的网站和程序可以做到。 |
15 c416593819 2020-05-07 11:52:13 +08:00 Reduce[L_ 1 e^(-t/t1) + L_ 2 e^(-t/t2) + L_ 3 e^(-t/t3) - L == 0, t, Reals] Mathematic 或者 matlab 都行 |