Wolfram mathematica Mathematica,用代换法简化方程

Wolfram mathematica Mathematica,用代换法简化方程,wolfram-mathematica,substitution,simplification,Wolfram Mathematica,Substitution,Simplification,有以下公式: s = R*(lat - lat0) rho = R/Tan[lat] f = (x^2 + (rho + s - y)^2 - rho^2)*(Sin[lat])^2 及其衍生物 fd = D[f, lat] 在哪里 我想用s,rho的代换来表示fd FullSimplify[fd, TransformationFunctions -> {Automatic, # /. R (lat - lat0) -> s &, # /. R/Tan[lat] ->

有以下公式:

s = R*(lat - lat0)
rho = R/Tan[lat]
f = (x^2 + (rho + s - y)^2 - rho^2)*(Sin[lat])^2
及其衍生物

fd = D[f, lat]
在哪里

我想用s,rho的代换来表示fd

FullSimplify[fd, TransformationFunctions -> {Automatic, # /. R (lat - lat0) -> s &, # /. R/Tan[lat] -> rho &}]
但是,仅出现没有任何替换的简化公式:

Output[2] = 2 Cos[lat] ((1 + (lat - lat0)^2) R^2 + x^2 + 2 (-lat + lat0) R y +   y^2 + R (lat R - lat0 R - y) Cot[lat]) Sin[lat]

谢谢您的帮助。

尝试替换并确认结果不变

s = R*(lat - lat0);
rho = R/Tan[lat];
f = (x^2 + (rho + s - y)^2 - rho^2)*(Sin[lat])^2;
fd = D[f, lat];
FullSimplify[fd, TransformationFunctions->{Automatic,
    #/.R(lat-lat0)->s&, #/.R/Tan[lat]->rho &}];
Simplify[% == fd]
输出为
True

请注意,您之前定义了
s=R*(lat-lat0)
,因此似乎要将
R(lat-lat0)
替换为
R(lat-lat0)

在进行替换之前,请尝试取消定义
s

s =.;
FullSimplify[fd, TransformationFunctions -> {Automatic,
    #/.R(lat-lat0)->s&, #/.R/Tan[lat]->rho&}]
结果是
2cos[lat](R(s-y)Cos[lat]+(R^2+x^2+(s-y)^2)Sin[lat])

现在,为什么在原来的
fd
中,
R/Tan[lat]
替换不起作用

D[f,lat]==2 Cos[lat](x^2-R^2 Cot[lat]^2+((lat-lat0)R-y+R Cot[lat])^2)Sin[lat]+(2 R^2 Cot[lat]Csc[lat]^2+2((lat-lat0)R-y+R Cot[lat])(R-R Csc[lat^2)Sin Sin[lat 2

请注意,其中没有
R/Tan[lat]
。Mathematica模式匹配是非常文字化的,无法理解多年前有一个家伙写的软件包,它是“数学替换”而不是Mathematica的“文字替换”,但这已经过时了,我不知道如何在当前版本中使用它

让我们尝试使用
R Cot[lat]
替换,并取消定义rho,使其不会撤消任何替换

s =.; rho =.
fd /. {R Cot[lat] -> rho}
结果是
2 Cos[lat](x^2+((lat-lat0)R+rho-y)^2-R^2 Cot[lat]^2)Sin[lat]+(2 R^2 Cot[lat]Csc[lat]^2+2((lat-lat0)R+rho-y)(R-R Csc[lat]^2))Sin[lat]^2

请注意,
R^2 Cot[lat]^2
仍然存在,而且文字替换不知道您可能希望
R Cot[lat]>rho
将其更改为
rho^2
,因此添加该规则

s=.; rho=.
fd /. {R Cot[lat] -> rho, R^2 Cot[lat]^2 -> rho^2}
请注意,
R^2 Cot[lat]
仍然存在,您可能想用
R rho
替换它,所以添加该规则

s =.; rho =.
fd /. {R Cot[lat]->rho, R^2 Cot[lat]^2->rho^2, R^2 Cot[lat]->R rho}
你是否开始意识到Mathematica中的模式替换会变成一个黑暗扭曲的走廊,通向一扇标有“沮丧”的门

有一个技巧你可能会用到

Simplify[fd, R Cot[lat] == rho]
这将试图简化fd,并且通常尝试用rho代替R Cot[lat]。在这个特殊的例子中,这甚至可以与

Simplify[fd, R/Tan[lat] == rho]
但不能保证这会一直起作用,或者做你想做的事情,在某些情况下,这会做更多奇怪的事情

也许这给了你足够的提示,你可以取得一些进展

Simplify[fd, R/Tan[lat] == rho]