asukumari

Mr. Abhilash Sukumari

50 Reputation

One Badge

1 years, 315 days

MaplePrimes Activity


These are questions asked by asukumari

What am I doing wrong here, or don't understand about Maple. I followed the 'IF' structure from Maple help. I am getting the wrong result.

a := 1:
b := 3:
if a > b then
    print(wrong)
else
    print(correct)
end if
                            correct
 

Is there a way for Maple to tell where the error occurs? For example I am not able to find the error that says 'Error, missing operator or `;'' in the following code.

 

# ctrl + del to delete a Maple cell
# golden search implementation
# chapra 7th ed
golden_search := proc(f, xl, xu, es100, maxiter)
description "find the optimal point using golden-search optimization method";
locals R, d, xopt, x1, x2, f1, f2, iter, ea, xint;
R := (sqrt(5)-1)/2;
d := R*(xu-xl);
x1 := xl + d;
x2 := xu - d;
f1 := evalf(eval(f, x = x1));
f2 := evalf(eval(f, x = x2));
# declare iterator and ea
iter := 1;
ea := 1.00;
# start while
while ea*100 > es100 and iter < maxiter do
    d := R*d; # new golden ratio
    xint := xu - xl;
    if f1 > f2 then
        xopt := x1;
        fx := f1;
        x1 := x2;
        x2 := x1;
        x1 := x1 + d;
        f2 := f1;
        f1 := evalf(eval(f, x = x1));
    else
        xopt := x2;
        fx := f2;
        xu := x1;
        x1 := x2;
        x2 := xu - d;
        f1 := f2;
        f2 := evalf(eval(f, x = x2));
    end if
    # calculate new ea
    if xopt <> 0 then
        ea := (1 - R)* abs(xint/xopt);
    end if
    iter = iter + 1;
end do;
# return xopt and fx here
xopt;
end proc:
 

How does one look through the Maple 2017 help for a code structure. I have been looking for how to construct a While loop and I am not able to find any example that implements while loop nor the code structure for it.

Any help is appreciated.

How do you evaluate a function expression at given variable values?

f := 2*sin(x)-x^2/10.00:

eval(f, x = 5) gives 2*sin(5)-2.500000000

evalf(eval(f, x = 5)) gives -4.417848549

So is there a way we can just numerically calculate f(x) where x = 5?

This question caught my eye on Mathematics Stack Exchange forum and doesnt seem to be resolved even with Mapel 2017.3:

Please follow the question and the discussion here

The question simply is to find the Fourier Transform of arctan(x)/x and use its inverse to verify if the solution provided by Maple was consistent.

The same sequence was tested on Wolfram Mathematica, and correct result was obtained.

Experienced users on this forum please advise what could be the possible explaination for this result.

Maple test:

1 2 3 4 Page 1 of 4