## invalid if statement termination...

Hi,

While running a maple code, I am getting a "invalid if statement termination" error. Most of time when I use nested for loop and if statement inside the loop, I am getting this error. Another error I get frequently is "Error, unterminate loop". I am using "shift+Enter" instead of Enter to avoid blanks but still such error appears. Can any one provide some rules which I should keep in mind to avoid these errors. My maple worksheet is enclosed-

invalid-if-stat-term-error.mw

Thanks and Regards,

Nilesh

## if condition inside eval and sum...

I really want to use if condition inside of eval and sum, example as below:

sum(eval(y=x^(j),(if j=1 then x=2 else x=3 fi)),j=1..2)

The reason is: the value of x to be evaluated depends on the value of j which differs inside of the sum (in the context of B-spline functions).

Any lights? Thanks,

## Problem with indices in Maple for the for/if comma...

I have a function which calculates a number for [x,y] inside a matrix, which depends on the values surrounding said initial cell (from [x-1,y-1] yo [x+1,y+1]). However, for the values on the border, the idea is to go around to the opposite side, creating a Torus of the sort.
The solution I seemed to have found was to create 4 indices: 2 controled with 'for' and 2 which were modified accordingly to be used as imputs for the function:

x:=x0;y:=y0;
for r from x-1 to x+1 do
print("r",r);
for t from y-1 to y+1 do
print("t",t);
if r=0 then i:=N; else i:=r; fi;
if t=0 then j:=N; else j:=t; fi;
if r=N+1 then i:=1; else i:=r; fi;
if t=N+1 then j:=1; else j:=t; fi;
print("i",i);print("j",j);
function(i,j);
od; od;

(the print commands are for the tests I have been running so see where the potential error lied).
If you run this script, you can clearly see for x0,y0<>1 that it works perfectly, even for x0,y0=N where it succesfully goes around and changes to 1. However, for x0,y0=1 it isn't able to detect that r&t=0 and so it doesn't change it to N; creating an error where it tries to find the value 0 of an Array.

Enrique

## How do I make the result of Result_Eva_GB_X2[3] :=...

I have attached the problem here. I need to say sorry, because I did not provide the whole code. So, automatically It will be error if you execute it.

If you see the attachement, you will see "Result_Eva_GB_X2[3] := []". It makes a problem if I want to make comparison. So I want the result of "Result_Eva_GB_X2[3] := []" is [0].

Actually the result of Result_Eva_GB_X2[3] := [] is complex number, because I did not want the complex I made select(x->is(0<x<1)....) to eliminate the complex number and negative result. So the question is How do I make the result of Result_Eva_GB_X2[3] := [] is [0]?

I have tried to add "Selection Statement (if)" (If the result is Undefined ([]) then Result_Eva_GB_X2[3] := [0]) But it can not work. Or maybe the selection statement that I made was wrong.

## How do I check a row is zero vector?...

```restart; with(LinearAlgebra); with(Student[LinearAlgebra]);
Z := Matrix([[3, 1, 5, 4, 5], [0, 0, 0, 0, 0], [28, 6, 4, 5, 9], [98, 5, 82, 2, 4], [24, 55, 23, 22, 90]]);
B := Matrix([[0], [0], [0], [0], [0]]);
A := <Z|B>:
if Row(A, 2) = ZeroVector[row](6) then A; end if;```

I used the code above but it didn't work...any help appreciated

## If condition with loop...

When I write an conditional command I come back and press enter again and again but I need only last one for example

>f:=x->x^2+x+1

>g:=y->y^2+2*y+6

>x:=0;y:=0

>if f(x) <g(x) then;

>x:=x+1 elif f(x) >g(x) then;

>y:=y+1 elif f(x)=g(x) then;

>x;

>y;

>f(x) end if;

I push enter and it write x:=1 then I click if command and push enter again and it writes x:=2 and continues like y:=1, x:=3, y:=2, x:=4,  y:=3 and lastly

4

3

21

But I only need last one. Can I do this only push enter once. Of course my problem is more complicated than this f(x) , g(x) . Thanks

## Conditional statements...

I have the following question:

Illustrate how the sequence N->R de fined by n ->n^2/n^2 + 31n + 228 can be shown to be
within a given epsilon > 0 of its limiting value x0.
(a) use an appropriate conditional statement to find N such that abs (xn -􀀀 x0) < epsilon for every n>=N
and produce an appropriate list of the data points (n,xn) to illustrate
this

I found N but without using any CONDITIONAL STATEMENT.Can you help me find N using IF FOR WHILE?

## Error, cannot determine if this expression is true...

i am trying to execute the following code but i am having the following error:

A:=Matrix(21,4):A(1,2):=0:A(2,2):=0:t:=2: thetasec:=-8.724679300*10^(20):  for z from 0.1 by 0.05 to 1 do  t:=t+1: A[t,1]:=z:  x:=2*A[t-1,2]-A[t-2,2]+thetasec*0.05^(2):  theta2:=evalf(arctan(sin(x-Pi),cos(x-Pi))+Pi):    if theta2>Pi/(2)and theta2<=(3*Pi)/(2)then   A[t,2]:=theta2-Pi   elif theta2>(3*Pi)/(2)then A[t,2]:=theta2-2*Pi else  A[t,2]:=theta2 fi:  A[t,3]:=cos(A[t,2]):  A[t,4]:=sin(A[t,2]):od

Error, cannot determine if this expression is true or false: (1/2)*Pi < 3.535344555 and 3.535344555 <= (3/2)*Pi

what is causing this error and how can i fix it

## if conditional then ?...

i have a conditional expression like this

for i from ... do

if .... then
exp1:
exp2:
exp3:
.......

else

exp4:
exp5:
exp6:
....

end if;

od;

i face this error during caculation:
Error, reserved word `else` unexpected

what should i do?

## Programming Error Message...

Hi everyone, I'm new to the forum and also new to Maple.

I am trying to do the following:

"Write a procedure, marks, to take a student’s mark and output the appropriate grade, based on the following table:"

 Mark 0   – 39.99

## Solve equation with parameters....

I just found out something which I don't understand.

Why am I getting this answer?

solve(a*x = 0, {x});
{x = 0}

When I try some similar expressions I see it behaves differently for equality and inequality.

solve(a*x <= 0, {x});...

## Help with plotting...

Hi Guys, I hope you can help!

I am stuck trying to plot a function that has a conditional based on 'x' the plotted variable.

e.g.

`> pltx := proc (num1::integer, num2::integer, x) if 1 < x then return 0 elif x < 0 then return 0 else return num1*x^num2 end if end proc;`
`> d := plot(pltx(2, 5, x), x = 0.1 .. 0.4);Error, (in pltx) cannot determine if this expression is true or false: 1 < x`

## Simple Conditionals...

Hello and thank you in advance,

I am used to Mathematica and am looking to switch, conditionals in Mathematica seem easy, like say

How do you replicate this in an easy to read way without lots of nested if statements?

## Condition of Jacobi Iteration...

Hello, I'm Tam and I had a problem with Conditional of Jacobi Iteration.

So, the proplem is:

>restart;

>with(LinearAlgebra):

A:=Matrix([[5,1,-1],[0,4,2],[-1,2,-7]]);

And I want to check the condition

with the maple program.

Fisrt, I typed

b:=sum(abs('A'[1,j]),j=1..ColumnDimension(A)); and I got b:=7

## how to use command "if" in command "for"...

I meet a problem. When I use command "if" in command "for", there is nothing.I don't know reason. Can anyone tell me the reason?

 1 2 Page 1 of 2
﻿