maxima , Solving piecewise functions in Maxima
Solving piecewise functions in Maxima
I attempted to solve a piecewise function in Maxima, but none of the solutions of the functions were returned:
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]
Is it possible for Maxima to obtain the solutions of an equation like this one?
In simple cases you can solve every branch everywhere and filter solutions:
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' */
I am learning Maxima, but having hard time finding how to obtain the cpu time used in call to integrate, when inside a loop construct. The problem is that the function time(%o1) gives the CPU time used to compute line %o1. But inside a loop, the whole loop is taken...
I can execute Maxima code from Octave like this and it works: mm=maxima("diff(a*x^3-b*x^2+x+d,x,1)") but how can I execute multi line commands? Example code below that works in Maxima kill(all)$ numer:true$ ratprint:false$ angle_in_bits:3779$ total_fs:18136$ s:solve(angle_deg=(angle_in_bits/total_fs*360),angle_deg)$ round(s); [round(angle_deg)=75] When I try the code below in Octave I get syntax errors mm=maxima("kill(all)$ numer:true$...
I use the following to save screen output to a file writefile("file.txt"), tex(expression), closefile() The above sends the output of the tex() to the file automatically. which is all and well and what I want. (side-point: It also sends an annoying NIL line each time to the file, which I...
Maxima's simpsum seems to be lacking some basic identities for infinite series. It has : sum(x^k, k, 0, inf), simpsum=true; but doesn't even have identities for: sum(k * x^k, k, 0, inf), simpsum = true; Is there a more comprehensive series summation in maxima beyond simpsum=true?...
I can do this : (%i1) myFunc(x) := x^2 + 1; myList : [1,2,3]; myFunc(myList); (%o1) myFunc(x):=x^2+1 (%o2) [1,2,3] (%o3) [2,5,10] and this as well : (%i1) kill(all); load("pdiff"); myFunc(x) := ratdisrep(taylor(diff(q('dst),'dst,x),'dst,0,5)); myFunc(1); myFunc(2); myFunc(3); (%o1) myFunc(x):=ratdisrep(taylor(diff(q('dst),'dst,x),'dst,0,5)) (%o2) [1,2,3] (%o3) (q[(6)](0)*dst^5)/120+(q[(5)](0)*dst^4)/24+(q[(4)](0)*dst^3)/6+(q[(3)](0)*dst^2)/2+q[(2)](0)*dst+q[(1)](0) (%o4)...
I want to generate a list of subscripted nouns where the subscripts are "multi-dimensionnal". For instance, using the two following lists as input : [1,5,2] [3,5,1] I want to generate the following list : [a[3,1],a[5,5],a[1,2]] Here is a working example : (%i1) indexX : [1,5,2]; (%i2) indexY : [3,5,1]; (%i3)...
My own equation is a bit longer, but the following example shows perfectly where I struggle at the moment. So far I have been using the let() and letsimp() function to substitute longer terms in an equation, but in this example they have no effect: (%i1) eq: ((2*u+a^2+d) * y+x)/2*a...
I have two complicated mathematical expressions. How can I compare them, to find if they express the same using Maxima?
I am a bit confused ; I noticed that if I do : a[sqrt(2)] : 1; arrays; I would get : [a] So a is an array for Maxima… yet sqrt(2) is an irrational number. I use to think of an array as a collection of items sorted by indices,...
I am trying to solve equation sqrt(x)==sqrt(20*(1500-x)) in sage and getting the output as given bellow, sqrt(x) == sqrt(-20*x + 30000) Problem in the above solution is that there is x in both side. How can I solve this kind of question sot that I get proper solution. I have...
I have probably a very simple question. What returns in Maxima function chebyshev_t(n, t)? I mean the exact mathematical formula. Best Regards...
I attempted to solve a piecewise function in Maxima, but none of the solutions of the functions were returned: 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] Is it possible for Maxima to obtain the solutions of...