在 Maxima中求解分段函数

我试图解决 Maxima 中的分段函数,但没有返回函数的解决方案:

我试图解决 Maxima 中的分段函数,但没有返回函数的解决方案:

piecewiseExample(x) := if (x < 5) then x*2 else x/2;
solve([piecewiseExample(x) = 4], [x]);
//result: [(if x<5 then 2*x else x/2)=4]

Maxima 是否有可能获得像这样的方程的解?

3

在简单的情况下,你可以解决每一个分支无处不在和过滤解决方案:

solve_and_filter(eq, var, p):= block([so: solve(eq, var), prederror: true],
  sublist(so, lambda([c], p(rhs(c))))) $
pw_solve(pw, var):= map(lambda([L],
    solve_and_filter(first(L), var, second(L))), pw) $
/* represent piecewise equation as a list of equation-predicate pairs
   [ [eq1, pred1], [eq2, pred2], ... ] */
pw: [ [x*2 = 4, lambda([x], x< 5)],
      [x/2 = 4, lambda([x], x>=5)]] $
/* solve every `eq' and filter solutions using `pred' */
pw_solve(pw, x);
0

一种选择是使用数值方法:

(%i1) f(x) := if (x < 5) then x*2 else x/2;
                                                      x
(%o1)                  f(x) := if x < 5 then x 2 else -
                                                      2
(%i9) find_root(f(x)-4,x,-1000,1000);
(%o9)                                 8.0

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(372)
如何使用CSS反转颜色
上一篇
如何使用vite将tailwindcss样式应用于Laravel9中的电子邮件
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(15条)