maxima

How to evaluate logarithms in Maxima?

こ雲淡風輕ζ 提交于 2019-12-10 10:25:11
问题 Following examples from here, and here I tried this: log2(x) := log(x) / log(2); log2(8), float; But this doesn't give 3, instead I get log(8)/log(2) . 回答1: You have to simplify radicals: (%i1) log2(x) := log(x) / log(2); log(x) (%o1) log2(x) := ------ log(2) (%i2) radcan(log2(8)); (%o2) 3 回答2: or use float : float(log(8)/log(2)); gives: 2.999999999999999 来源: https://stackoverflow.com/questions/36271504/how-to-evaluate-logarithms-in-maxima

Maxima: how to replace common subexpressions with symbols

血红的双手。 提交于 2019-12-09 06:31:29
问题 Suppose I have an expression like (actually mine is much more complex, thousands of characters) expr:a+b*c+b*c*d; and I want to replace an internal sub-expression with a symbol (useful to avoid recomputation of common subexpressions), say k in place of b*c : subst(b*c=k,expr); returns k+b*c*d+a How I can make Maxima calculate the "right" substitution so to return (apart from obviuos simplification, here) k+k*d+a ? 回答1: Take a look at let and letsimp . E.g.: (%i2) expr : a + b*c + b*c*d; (%o2)

Find maximum value and index in a Maxima list?

大城市里の小女人 提交于 2019-12-08 05:30:31
I have a list in maxima like: x:[1,3,7,98,211,3,2.44,23] I need to find the maximun value of the list and on which position(s) the maximum value is situated. The only thing that has occurred to me is to rewrite the list as a sequence and apply the 'max' command max(first(x),second(x),...,last(x)) But it is not efficient, and I don't know get the index of the maximum value. Can anybody help me? Robert Dodier lmax returns the maximum value of a list . Given x is a list, then lmax(x) returns its minimum value. Getting the index of the maximum value is a little more involved. The most relevant

Find maximum value and index in a Maxima list?

余生长醉 提交于 2019-12-08 04:00:42
问题 I have a list in maxima like: x:[1,3,7,98,211,3,2.44,23] I need to find the maximun value of the list and on which position(s) the maximum value is situated. The only thing that has occurred to me is to rewrite the list as a sequence and apply the 'max' command max(first(x),second(x),...,last(x)) But it is not efficient, and I don't know get the index of the maximum value. Can anybody help me? 回答1: lmax returns the maximum value of a list . Given x is a list, then lmax(x) returns its minimum

Maxima - differentiating a piecewise function

百般思念 提交于 2019-12-07 19:03:16
问题 Suppose you have a function defined by intervals, such as f(x):=block(if x<0 then x^2 else x^3); When we differentiate it with diff(f(x),x); we get d/dx (if x<0 then x^2 else x^3) whereas I'd like to get (if x<0 then 2*x else 3*x^2) Is there a way to obtain such result? 回答1: This may help in a simple case: (%i1) f(x):= charfun(x<0)*x^2 + charfun(x>=0)*x^3$ (%i2) gradef(charfun(y), 0)$ (%i3) diff(f(x),x); 2 (%o3) 2 x charfun(x < 0) + 3 x charfun(x >= 0) charfun, gradef You can try also Pw.mac

Assign Taylor expansion to function

偶尔善良 提交于 2019-12-07 05:18:25
问题 When I use Maxima to calculate the Taylor series: f(x,y) := taylor((x+y)^3, [x, y], [2, 3], 2); f(2,3); /* error: wrong number of arguments */ Basically I want to define a function as a expansion of (x+y)^3 , which takes in x,y as parameter. How can I achieve this? 回答1: Try (%i1) f(x,y) := ''(ratdisrep(taylor(('x+'y)^3, ['x, 'y], [2, 3], 2))) $ (%i2) f(2, 3); (%o2) 125 or (%i1) define(f(x, y), ratdisrep(taylor(('x+'y)^3, ['x, 'y], [2, 3], 2)))$ (%i2) f(2, 3); (%o2) 125 来源: https:/

Maxima - differentiating a piecewise function

醉酒当歌 提交于 2019-12-06 05:56:30
Suppose you have a function defined by intervals, such as f(x):=block(if x<0 then x^2 else x^3); When we differentiate it with diff(f(x),x); we get d/dx (if x<0 then x^2 else x^3) whereas I'd like to get (if x<0 then 2*x else 3*x^2) Is there a way to obtain such result? This may help in a simple case: (%i1) f(x):= charfun(x<0)*x^2 + charfun(x>=0)*x^3$ (%i2) gradef(charfun(y), 0)$ (%i3) diff(f(x),x); 2 (%o3) 2 x charfun(x < 0) + 3 x charfun(x >= 0) charfun , gradef You can try also Pw.mac package from Richard Hennessy. Here's a different approach using a simplification rule for "if" expressions

How to make the output of Maxima cleaner?

≯℡__Kan透↙ 提交于 2019-12-06 03:47:03
问题 I want to make use of Maxima as the backend to solve some computations used in my LaTeX input file. I did the following steps. Step 1 Download and install Maxima. Step 2 Create a batch file named cas.bat (for example) as follows. rem cas.bat echo off set PATH=%PATH%;"C:\Program Files (x86)\Maxima-5.31.2\bin" maxima --very-quiet -r %1 > solution.tex Save the batch in the same directory in which your input file below exists. It is just for the sake of simplicity. Step 3 Create the input file

Assign Taylor expansion to function

夙愿已清 提交于 2019-12-05 11:27:53
When I use Maxima to calculate the Taylor series: f(x,y) := taylor((x+y)^3, [x, y], [2, 3], 2); f(2,3); /* error: wrong number of arguments */ Basically I want to define a function as a expansion of (x+y)^3 , which takes in x,y as parameter. How can I achieve this? Try (%i1) f(x,y) := ''(ratdisrep(taylor(('x+'y)^3, ['x, 'y], [2, 3], 2))) $ (%i2) f(2, 3); (%o2) 125 or (%i1) define(f(x, y), ratdisrep(taylor(('x+'y)^3, ['x, 'y], [2, 3], 2)))$ (%i2) f(2, 3); (%o2) 125 来源: https://stackoverflow.com/questions/23294656/assign-taylor-expansion-to-function

Maxima: convert matrix to list

旧街凉风 提交于 2019-12-05 02:01:52
I convert list to matrix in Maxima in following way: DataL : [ [1,2], [2,4], [3,6], [4,8] ]; DataM: apply('matrix,DataL); How to do it the other way ? How to convert given matrix DataM into list DataL ? I know it's late in the game, but for what it's worth, there is a simpler way. my_matrix : matrix ([a, b, c], [d, e, f]); my_list : args (my_matrix); => [[a, b, c], [d, e, f]] Simon I'm far from a Maxima expert, but since you asked me to look at this question , here's what I have after a quick look through the documentation . First, looking at the documentation on matrices yielded only one way