How to solve equation using math symbolic and get erfinv as output?

1 回表示 (過去 30 日間)
Caio
Caio 2012 年 4 月 19 日
Hi,
When I type this code:
syms x y
solve(erf(x) - y,x)
I get the following
ans =
[ empty sym ]
When it's clear that the answer is x = erfinv(y), if we assume that y belongs to (0,1).
Is there some way in which I can get erfinv(y)as an answer? I guess the problem is that I didn't specify that y is between 0 and 1. If so, how can I do that?
Thanks,
Caio

採用された回答

Alexander
Alexander 2012 年 4 月 20 日
Hi Caio,
If you have MATLAB R2012a you can simpliy use the assume command to say that y belongs to (0, 1):
assume(0<y<1)
>> solve(erf(x) - y,x)
ans =
erfinv(y)
If you have an older version, you need to use evalin:
evalin(symengine, 'assume(0<y<1)')
You can also try to use the option IgnoreAnalyticConstraints. With this option, the symbolic engine is a little less restrictive when doing calculations:
syms y clear
solve(erf(x) - y,x, 'IgnoreAnalyticConstraints', true)
ans =
erfinv(y)

その他の回答 (1 件)

Caio
Caio 2012 年 4 月 20 日
Thanks! It keeps not working here, but I'll have a closer on this. If it worked on yours matlab it should work on mine. I have the R2011a.

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by