## 12780 Reputation

8 years, 300 days

## characteristic...

Adding to what user acer said:

Gcd in Algebraic has a distinct syntax; it is not inert any more.
If you want the result mod 3 then use

Gcd(f, g, characteristic=3);

Note that without characteristic=3, the gcd is computed in the ring Z[x]; if mod 3 is included (as you did), the mod 3 is applied to this polynomial.

## It depends...

It depends on what the procedure actually does.E.g., p could be a local variable.

f:=proc(i)
local p;
end:
eq1 := f(1);

rhs(eq1): is(%=p[1]);
false

If you comment out the local declaration, ==> true.

## Explanation...

Any procedure P can be called "indexed" P[abc](arguments), instead of the usual P(arguments)
In the body of the procedure, the index can be retrieved and used as an extra argument, or can be simply ignored. Most library procedures ignore the index (mainly if it is not expected).
See a simple standard example with  showstat(log);

Examples:

sin[xxx](Pi/2); # ignored
1

max[abc](22,33,11); # not ignored, for obvious reasons
Error, invalid input: unrecognized max/min[option] abc

It would be convenient to have always warnings when calling an indexed procedure which ignores the index, but it would be inefficient; anyway, this "feature" is as old as Maple I think.

## remember...

Some commands have option remember, so these are not re-executed next time.

## W(x)...

@Johan159 You should be aware that W(x) is not a regular variable, and it is not a good idea to use it this way.

An assignment W(x) := a produces a procedure W and creates/extends its remember table. When W(x) is accessed, it is not evaluated, that's why in your case _C1 was displayed; if you want evaluation, it must be accessed via eval(W(x)). So, don't use it, unless you know these details.

## With a little help...

 > restart;
 > f:= (n,x) -> piecewise(x <-1/n, -1, x<1/n,n*x, 1); plot([f(3,x), f(7,x)], x=-2..2, color=[red,blue]);
 > simplify(int( abs(f(n,x)-f(m,x)), x=-1..1)) assuming 1<=m, m
 (1)
 > ans:=simplify(2*int(f(n,x)-f(m,x), x=0..1)) assuming m>1,n>m; # Using that x->f(n,x) is odd and f(m,x)<=f(n,x) for x>=0
 (2)
 > map(evalf@eval, Int(abs(f(n,x)-f(m,x)), x=-1..1) = ans, [m=3,n=7] ); # numeric check
 (3)
 >

## There are several problems with your cod...

There are several problems with your code:

--  x is used both as a table (indexed) and as a real number. Use another name for one of them.

-- The arguments of piecewise are in a wrong order

--  You must use unapply when defining phi (otherwise the arguments of piecewise are not evaluated).

## Workaround...

You may define (inside or outside the mpl)

Dy := t -> eval(diff(y(t_),t_), t_=t);
D2y := t -> eval(diff(y(t_),t_\$2), t_=t);

and then

```ode:=D2y(x)+Dy(x)=sin(x);
ic:=y(0)=1,Dy(0)=0;
dsolve([ode,ic],y(x));```

## Erdos...

For n=4, we may take the points O(0,0), A(3,0), B(3,4), C(0,4); I don't know whether the radius (5/2 here) is minimal.
For a general n, Erdos and Anning have a construction (1945), see Erdős–Anning theorem - Wikipedia

Edit. The minimal radius is 8/sqrt(15) = 2.06...  and corresponds to a cyclic quadrilateral having the lengths of the edges: 2, 3, 2, 4.

## A 3d line is determined by a point P and...

A 3d line is determined by a point P and a direction V.
We need a necessary and sufficient condition for the concurrency of two (non-parallel)  lines.
Let's represent P and V as lists.

```restart;
conc:=(P1,V1,P2,V2) -> LinearAlgebra:-Determinant(Matrix([P1-P2,V1,V2])):
d1:= [1,0,-3], [2,1,-2]:
d2:= [1,0, 3], [-1,1,2]:
solve( [ conc(A, [p,q,r], d1), conc(A, [p,q,r], d2) ], [p,q,r] );
#                 [[p = 6/5*q, q = q, r = -12/5*q]]
TheLine = A, eval([p,q,r], %[]); # the wanted line
#               TheLine = [1, -2, 3], [6/5*q, q, -12/5*q]
eval(%,q=5); #Or,
#               TheLine = [1, -2, 3], [6, 5, -12]
```

So, you may write it as:  (x-1)/6 = (y+2)/5 = (z-3)/(-12)

## It depends...

- If you want just the plot:

`plots:-intersectplot(f - z, g - z, x = 0 .. 1, y = 0 .. 2, z = -0.01 .. 0.01, thickness = 3)`

- If you want its projection, use Ruben's approach or

`plots:-implicitplot(f-g, x=0..1,y=0..2)`

- For a numeric parametrization see above, or use a system of ODEs.

## Idea for a proof...

Your sum can be written as

The numerator represents the finite difference of order 2*k+2 of a monic polynomial of degree 2*k+4.
So, it's a polynomial of degree 2, the coefficients depending on k. The leading coefficient is (2*k+4)!/2.
The remaining two coefficients can be computed by recurrence Δⁿ⁺¹ = Δ(Δⁿ).

## T[x], T__x...

You are making a mess by using two kinds of variables such as T[1] and T__1.
They are displayed almost the same, and you are usind 2D input and document mode (a good choice only for presentations).

Execute indets(equation_set);   to see the variables. Then correct your equations.

## floats...

It's a bad idea to use floats in symbolic computations. The discriminant B^2-4*A*C  is very close to 0, but not 0, so the conic will not be recognized as a parabola.
Try G:=convert(G, rational)  to see this.

Hence, use rational coefficients as above; you may use evalf at the end.

## Explanation...

Let S1 and S2 be two spheres of radii r1 and r2  and centers O1 and O2. Denote by d the distance between their centers.

If A is in the intersection of S1 and S2, the angle O1AO2 equals

arccos((r1^2 + r2^2 - d^2)/(2*r1*r2)).      [1]

Of course this makes sense only if S1 and S2 intersects (so, abs(r1-r2) <= d <= r1 + r2).

In your case d=0.  Applying blindly [1] it results a complex number (if r1 <> r2). This is not unexpected, and I don't consider it a bug; however a warning would be nice.

Note that Maple uses some equations instead of [1].
It is strange that for r1=2, r2=3, O1=O2=[-1.-1.-1],   FindAngle gives arccos(31/12) and [1] gives arccos(13/12).
Both are complex, but are not the same. However, when O1=O2=[0,0,0] (which should not matter), FindAngle gives  arccos(13/12) too!

 First 11 12 13 14 15 16 17 Last Page 13 of 114
﻿