65 Reputation

5 Badges

5 years, 309 days

MaplePrimes Activity

These are replies submitted by Rohith

@Carl Love 

I need to have output as 1 if the coefficient is nothing

Also I have been trying your line of code from other question.

C:= coeffs(lhs(Eq), indets(Eq, function));

I am almost getting the answer with few unrequired extra elemtents and most importentaly not in functional order as it in expression

@Carl Love 

In most of my cases I will have higher order equations with multiple variables. In my case I need to validate the variable limits. I will be given an equation and limits for all variables. Also I need to be careful with the equation value. I have to choose those variable combinations that cause the equation failure. It is something related to safety applications.

once I got those cases in which the equation fails either I have take care that this cases are skiped or modify equation.

equation value always with in the range [fmin..fmax]

Through optimization:Interactive I am able to find out the maximum and minimum possible value for equation at specific variable selection. But I really need to check for all possible critical cases.

@vv Thank you very much for the solution. It works perfect when I have ranges incrementing 1.

In actual I have variables values in a range incrementing by 0.1. I do not know How exactly I can define them.

In other tools like matlab I do simple as 1:0.1:10, but in maple Is there any way we can do the same?

Thank you very much for the quick response. But, I explained the problem in simple terms. It is my mistake to not give proper information.

Now my range a:=1..10->this implies only intergers but in actual problem I need to find for floating points till one decimal.

which meansvariable a is from 1 by 0.1 to 10. Size of 'a' is 1*100(hundred values).Similarly all other variables and expression limits are in incremetal step of 0.1.

Thank you for pointing out other possibilities, But in my case I have exactly two operands and one operators. Hence, I would expect how I asked in my question. I want to have the out put telling me exactly what operation I am having between two operands

@Carl Love 

Hello Carl, Sorry that I could not explain you in correct way.
Please find the below lines

expr := a-c*d:
asString := convert(expr,string):
test :=termExtract(asString);

Now the output is {-c*d}.

lprint(kernelopts(version), InertForm:-Parse(test));

`Maple 2018.1, X86 64 WINDOWS, Jun 8 2018, Build ID 1321769`, `%+`(`%*`(-c, d), b)

expr := a*b-c*d:
asString := convert(expr, string):

{a*b, c*d}

lprint(kernelopts(version), InertForm:-Parse(test));
`Maple 2018.1, X86 64 WINDOWS, Jun 8 2018, Build ID 1321769`, `%+`(`%*`(a, b), -`%*`(c, d))

I always have to convert the expression into string and use it for extracting simple two variable(atomic) expression.Now I
observe that the expression in the first case is changing from a-c*d to -c*d+a. Though both are same some how our module is changing its behaviour.

Now Coming to the all expressions

expression1 := s + (a/b)*log((a+c/b));
expression2 := a+(c/d)*log(1+b)+sin(a-b)+a^c;
expression3 := a+(c/d)*log(1-b)+exp((a*b)/d);
expression4 := x^y-a;
expression5 := a*b*c-(x+a+y)/2*a;
expression6 := a-c*d;

once I get the two variable(expressions) and work individually on each expression and in place of each two variable Expression I substituate single Variable and continue the process until I completely solve the expression. Hence I always must convert the expression to string before working.

Regarding OP: In the above mentioned Error related to Fold, In that line of code only term that is new is OP, because I have seen using some terms like 'And' I was curious if OP has some functional activity.

Hoping I gave sufficient information. As am new to maple I am actually cannot think on broad view how things working on maple. But I am certain that I am getting more used to and able to exlore new things regularly.

I just found out that using assign and map we can map the elements of two list having same length

seq(assign(List2[i] = List1[i]), i = 1 ..numelems(List1))

@Carl Love I find there some different kind of response from the module based on input. It cannot be mentioned as an error. But, not completely dependable. For example for as below

When I give a Input as



I am getting the out puts as {a*b,c*d}, where as if I change the Input



My output is {-c*d} instead of {c*d}. In this case it is reading minus sign.


@Carl Love Hello carl. Thank you for the update. i have tested now and its is working finely. Hopefully if I use it for some times it doesnt throw me any errors.

Could you shortly explain me what is OP in the command related to variable Fold?

@Carl Love I am facing some errors that I cannot understand. Sometimes the above module works perfectly fine and some times it gives me an errors just like above.

If i close my maple and run it, it is working fine but if I run for few times I am getting above error.

but, As a normal command as explained at first it is working perfectly(but is cannot perform  folding (fodl)).
Where am I doing wrong ?? Is it possible to do as a normal command line rather than a module?
Below Fold command is really complex line to understand atleast to me. Here, what is OP exactly?

I have just pasted your code with variable name changed.

Fold:= E-> subsindets(E, AssocOps, OP-> foldl(op(0,OP), op(OP))),


Error, (in Fold) type `AssocOps` does not exist

termExtract:= module()
uses TT= TypeTools, IN= InertForm;
   TryRemoveType:= (T::name)-> if TT:-Exists(T) then TT:-RemoveType(T) else fi,
   TryAddType:= (TH::(name= anything))-> (TryRemoveType(lhs(TH)), TT:-AddType(op(TH))),
   ModuleUnload:= proc()
      :-`print/Expression`:= ':-`print/Expression`';
   end proc,
   ModuleLoad:= proc()
         (AddedTypes:= [
            #With recursive types, put base cases at beginning to avoid infinite loops!
            'Atomic'=     'Or'('name', 'numeric', 'InertRecip', 'Negated'),
            'InertRecip'= 1 %/ 'Atomic',
            'Negated'=    (-1) &* 'Atomic',
            'AssocOps'=   'And'('specfunc'({`%+`, `%*`}), 'patfunc'('anything'$4)),
            'Operators'=  'specfunc'('Atomic', {`%+`, `%*`, `%/`, `%^`}),
            'Expression'=     'And'('Operators', 'Not'('InertRecip'), 2 &under nops)
      :-`print/Expression`:= Expression-> value({args});
   end proc,

   #Associative operators with > 2 operands are regrouped pairwise.
   Fold:= E-> subsindets(E, AssocOps, OP-> foldl(op(0,OP), op(OP))),
   ModuleApply:= (E::string)-> 'Expression'(indets(Fold(IN:-Parse(E)), 'Expression')[])
end module:


@Carl Love 13607  
I am very gratefull for the commands and explanation given, Your explanation is quite detail with respect to sqrt function. But, I observed that in my expression abs function is used.

my actual intension is to ignore abs as function. for example

expression :=log(sin(abs(a+b*c)));

I want to work on above expression and I want to extract the term sin(abs(a+b*c))

by using indets(expr, function(Not(function)))[]; I could get abs(a+b*c)

Is it possible to  get sin(
abs(a+b*c)), In short I want to ignore abs as a function where ever it appears. I have tried using %. but, it is not working

Thank you

@Carl Love Though I am using maple 2018 I need to alter little bit to make the above code to work.

need to change

1 %/ 'Atomic' to `%/`(1, Atomic)

But it is work as I was expecting. This one just for information. Thank you once again

@Carl Love it is very useful and detail explanation that going to be very helpful for me in future works. I have understood how eval and & can be used for special cases. I would like to express, am very grateful for the time and effort spent to educate us all.

coming to the above simplified model after solving complx expressions using above mentioned methd, I have end up with an expression which is quite simple but could not be solved.

I absolutely not expectede that I would end up at this stage. I would like to say sorry for extending this and kindly, excuse me.

I got end up with an expression like below. Cleary there is no exact operatoe operating on two atomic operands. But, I exprect My code to solve either solve a+b or b+c.

expression := a+b+c
expression := a*b*c+a+b+c

in my case the result of a+b(or b+c) will be filtered and added to c(or a) and proccessed.
Thank you once again. I am using Maple 2018.

RohithExtract("a+b+c"); gives an null set({}). I expect a+b or b+c as an output. Is it possible anyway?

Carl Love Thank you for the explanation and solution..

I have now some different condition. I have tried to change the code according but some how it is not working. Please see the below condition.



      And(specfunc({name, numeric, `&*`(-1, name), `&/`(1, name)}, {`%*`, `%+`, `%/`, `%^`}), `&under`(2, nops))));

I am exprecting the result as V1/v[0] but my solution is 1/V[0], my basic understanding is is not taking my condition.
Is there something I can do before Parse(). ?

@ Carl Love 13480 Thank You for the Solution provided.

Now I have a complex expression as below

"a+(c/d)*log(1+b)+sin(a-b)+a^c".  Now I have 4 subexpression where each operator exactly operated on two operands.

those are: c/d, 1+b, a-b, a^c

I solution you have earlier mentioned is able to extract two as you explained : c/d and 1+b

kindly could you please provide how I can get other two conditions. Thanks in advance

1 2 Page 2 of 2