symbolic-math

How to get partial expression from symbolic expression containing specific variable MAPLE?

孤街醉人 提交于 2019-12-19 10:04:49
问题 I have a symbolic expressions as below y1 = (1/a)-(b/a^2)+x*a*b-x/b y2 = a*b+a*x+b*sqrt(x) now I need to get the partial expressions which have specific term. Like xFunction(y1, x) # should return x*a*b-x/b xFunction(y2,x) # should return a*x+b*sqrt(x) any suggestions or idea are very healpful Thank you 回答1: restart; y1 := (1/a)-(b/a^2)+x*a*b-x/b: y2 := a*b+a*x+b*sqrt(x): K := (ee,x) -> `if`(ee::`+`,select(depends,ee,x),ee): K( y1, x ); x x a b - - b K( y2, x ); (1/2) a x + b x # # Leave

R: trouble making package Ryacas to work on Windows

筅森魡賤 提交于 2019-12-19 08:39:23
问题 I am trying to use the package Ryacas in R . Here what is going on: > install.packages("Ryacas") --- Please select a CRAN mirror for use in this session --- trying URL 'http://www.stats.bris.ac.uk/R/bin/windows/contrib/2.14/Ryacas_0.2-11.zip' Content type 'application/zip' length 263424 bytes (257 Kb) opened URL downloaded 257 Kb package ‘Ryacas’ successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\yogcal\Local Settings\Temp\RtmpKeuu7m\downloaded

Turn user input string into mathematical function

随声附和 提交于 2019-12-19 03:58:31
问题 For the purposes of what I want to do I need to take a user input as a string and convert it into an unevaluated function. For example, if the user input was "x^2*sin(x)" I would need a function that took a double input x and returned Math.Pow(x, 2)*Math.Sin(x) I need the function, I can't pass in a value for x and I will be calling the function many times (hundreds possibly) so I can't parse the string each time I am making a calculation. How would I implement this? I take it from the

How can I give a number to a symbolic variable in MATLAB?

£可爱£侵袭症+ 提交于 2019-12-19 03:25:18
问题 I try to declare a symbolic variable in MATLAB with this code: syms a; I do my computation on this variable and all thing is fine. But my problem is that, I don't know how can I give a number to variable and get the result as a number. For example the answer of my code is answer=exp(-10*a); For instance I want to give 40 to "a" and get the answer as answer = 1.9152e-174 I really appreciate any suggestion. 回答1: use eval syms a; answer = exp(-10*a); a=40; eval(answer) ans = 1.9152e-174 回答2: You

How to have MATLAB display answer in decimals with e instead of fractions

亡梦爱人 提交于 2019-12-18 09:29:20
问题 So im using MATLAB to calculate the coefficient of an equation and it keeps displaying fractions as the constants instead of decimal form like xxe-x My code is below bt = 0.03175; bpzt = 0.0078; ht = 0.003; w = 50; % frequency in Hz pnic = 8908; % density of nickel Enic = 200e9; % Young's modulus of nic L = 0.3048; % Length of canitlever beam in m syms hn inertia = (1/12)*bt*ht^3 + (1/2)*bpzt*ht^2*hn - (1/2)*bpzt*ht*hn^2 + (2/3)*bpzt*hn^3 area = (bt*ht - 2*hn*bt + 2*bpzt*hn); 回答1: You are

How to implement a derivative of a symbolic function by a 'symfun' in Matlab?

谁说我不能喝 提交于 2019-12-18 08:55:12
问题 Here is my Matlab program: syms x(t) t; f = x^2 + 5; And the result of f : f(t) = x(t)^2 + 5 Both f and x are of class symfun in Matlab. I want the result of df/dx, which is equal to 2*x(t) . I tried this in Matlab: diff(f, x); and got the following errors: Error using mupadmex Error in MuPAD command: The variable is invalid. [stdlib::diff] Error in sym/diff (line 57) R = mupadmex('symobj::diff', S.s, x.s, int2str(n)); How can df/dx be obtained in Matlab? 回答1: In newer versions of Matlab (I'm

Constructing piecewise symbolic function in Matlab

大城市里の小女人 提交于 2019-12-18 03:31:08
问题 I am trying to generate a piecewise symbolic function in Matlab. The reason it has to be symbolic is I want to be able to integrate/differentiate the function afterwards and/or insert actual values. I have the following function: x^3/6 -> 0 < x <= 1 (1/6)*(-3*x^3+12*x^2-12x+4) -> 1 < x <= 2 (1/6)*(3*x^3-24*x^2+60x-44) -> 2 < x <= 3 (1/6)*(4-x)^3 -> 3 < x <= 4 0 -> otherwise For example, I want to put this function in a variable (let's say f) and then call int(diff(f, 1)^2, x, 0, 4) % numbers

Function for polynomials of arbitrary order (symbolic method preferred)

ぃ、小莉子 提交于 2019-12-17 20:14:22
问题 I've found polynomial coefficients from my data: R <- c(0.256,0.512,0.768,1.024,1.28,1.437,1.594,1.72,1.846,1.972,2.098,2.4029) Ic <- c(1.78,1.71,1.57,1.44,1.25,1.02,0.87,0.68,0.54,0.38,0.26,0.17) NN <- 3 ft <- lm(Ic ~ poly(R, NN, raw = TRUE)) pc <- coef(ft) So I can create a polynomial function: f1 <- function(x) pc[1] + pc[2] * x + pc[3] * x ^ 2 + pc[4] * x ^ 3 And for example, take a derivative: g1 <- Deriv(f1) How to create a universal function so that it doesn't have to be rewritten for

How to convert a string containing math expression into an integer? [duplicate]

寵の児 提交于 2019-12-14 03:36:47
问题 This question already has answers here : How to evaluate a math expression given in string form? [closed] (24 answers) Closed 3 years ago . I have an array named questions array for String type that stores in the questions. I want to convert the questionArray[0] to an int . I have used the following statement to do that. int aa = Integer.parseInt(questionArray[0]); But when I implement this statement and when I run the application I get an error saying : invalid int: "10-4" . Note that the 10

Matlab: How to specify input in matlabFunction?

泄露秘密 提交于 2019-12-14 02:37:16
问题 matlabFunction() is a function that can convert symbolic to anonymous function. But how to specify what input arguments to be appeared on the anonymous function? For example, x = sym('x', [3, 1]) func = matlabFunction(x) It returns a handle with: func = function_handle with value: @(x1,x2,x3)[x1;x2;x3] But how to make this to be returned:? @(x) [x(1); x(2); x(3)] that the whole x is the input arguments, not every element of it. This could be extremely useful when x has very long colums. 回答1: